Fishpigs_Wordpress_Integration - Version 0.8.8

Version Notes

Upgraded for Magento 1.5.1

Download this release

Release Info

Developer Magento Core Team
Extension Fishpigs_Wordpress_Integration
Version 0.8.8
Comparing to
See all releases


Version 0.8.8

Files changed (188) hide show
  1. app/code/community/Fishpig/Wordpress/Block/Abstract.php +18 -0
  2. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin.php +25 -0
  3. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Form.php +19 -0
  4. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tab/Form.php +51 -0
  5. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tabs.php +24 -0
  6. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Category/Grid.php +66 -0
  7. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Grid/Abstract.php +80 -0
  8. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Post/Grid.php +68 -0
  9. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support.php +21 -0
  10. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Form.php +19 -0
  11. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/Form/Abstract.php +7 -0
  12. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/RequestForm.php +66 -0
  13. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tabs.php +54 -0
  14. app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Column/Result.php +21 -0
  15. app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Grid.php +76 -0
  16. app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Wrapper.php +44 -0
  17. app/code/community/Fishpig/Wordpress/Block/Adminhtml/Template.php +38 -0
  18. app/code/community/Fishpig/Wordpress/Block/Archive/List.php +38 -0
  19. app/code/community/Fishpig/Wordpress/Block/Archive/View.php +42 -0
  20. app/code/community/Fishpig/Wordpress/Block/Author/View.php +42 -0
  21. app/code/community/Fishpig/Wordpress/Block/Category/List.php +51 -0
  22. app/code/community/Fishpig/Wordpress/Block/Category/View.php +62 -0
  23. app/code/community/Fishpig/Wordpress/Block/Feed/Rss2.php +54 -0
  24. app/code/community/Fishpig/Wordpress/Block/Homepage.php +40 -0
  25. app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php +12 -0
  26. app/code/community/Fishpig/Wordpress/Block/Post/List.php +142 -0
  27. app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php +61 -0
  28. app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php +39 -0
  29. app/code/community/Fishpig/Wordpress/Block/Post/List/Recent.php +51 -0
  30. app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php +147 -0
  31. app/code/community/Fishpig/Wordpress/Block/Post/View.php +52 -0
  32. app/code/community/Fishpig/Wordpress/Block/Post/View/Abstract.php +66 -0
  33. app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php +72 -0
  34. app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php +82 -0
  35. app/code/community/Fishpig/Wordpress/Block/Tag/List.php +15 -0
  36. app/code/community/Fishpig/Wordpress/Block/Tag/View.php +55 -0
  37. app/code/community/Fishpig/Wordpress/Controller/Abstract.php +258 -0
  38. app/code/community/Fishpig/Wordpress/Controller/Adminhtml/Abstract.php +29 -0
  39. app/code/community/Fishpig/Wordpress/Controller/Router.php +347 -0
  40. app/code/community/Fishpig/Wordpress/Docs/Example-XML-Blocks.xml +205 -0
  41. app/code/community/Fishpig/Wordpress/Docs/readme.txt +24 -0
  42. app/code/community/Fishpig/Wordpress/Helper/Abstract.php +283 -0
  43. app/code/community/Fishpig/Wordpress/Helper/Adminhtml.php +32 -0
  44. app/code/community/Fishpig/Wordpress/Helper/Catalog/Product.php +67 -0
  45. app/code/community/Fishpig/Wordpress/Helper/Curl.php +75 -0
  46. app/code/community/Fishpig/Wordpress/Helper/Data.php +36 -0
  47. app/code/community/Fishpig/Wordpress/Helper/Db.php +179 -0
  48. app/code/community/Fishpig/Wordpress/Helper/Debug.php +163 -0
  49. app/code/community/Fishpig/Wordpress/Helper/Debug/EnvironmentReport.php +124 -0
  50. app/code/community/Fishpig/Wordpress/Helper/Debug/Test.php +65 -0
  51. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Abstract.php +83 -0
  52. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/BlogRoute.php +62 -0
  53. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Connection.php +22 -0
  54. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Query.php +26 -0
  55. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/ResultCollection.php +14 -0
  56. app/code/community/Fishpig/Wordpress/Helper/Debug/Test/WpUrls.php +56 -0
  57. app/code/community/Fishpig/Wordpress/Helper/Filter.php +73 -0
  58. app/code/community/Fishpig/Wordpress/Helper/Filter/Abstract.php +147 -0
  59. app/code/community/Fishpig/Wordpress/Helper/Filter/AutoParagraph.php +64 -0
  60. app/code/community/Fishpig/Wordpress/Helper/Filter/RemoveHtml.php +15 -0
  61. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Abstract.php +12 -0
  62. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/AssociatedProducts.php +50 -0
  63. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Caption.php +35 -0
  64. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Product.php +56 -0
  65. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/SyntaxHighlighter.php +43 -0
  66. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Youtube.php +41 -0
  67. app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcodes.php +51 -0
  68. app/code/community/Fishpig/Wordpress/Helper/Object.php +105 -0
  69. app/code/community/Fishpig/Wordpress/Helper/Plugin/Abstract.php +6 -0
  70. app/code/community/Fishpig/Wordpress/Helper/Plugin/AllInOneSeo.php +30 -0
  71. app/code/community/Fishpig/Wordpress/Helper/Post.php +225 -0
  72. app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Abstract.php +61 -0
  73. app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Caption.php +31 -0
  74. app/code/community/Fishpig/Wordpress/Model/Abstract.php +82 -0
  75. app/code/community/Fishpig/Wordpress/Model/Admin/User.php +35 -0
  76. app/code/community/Fishpig/Wordpress/Model/Archive.php +50 -0
  77. app/code/community/Fishpig/Wordpress/Model/Category/Abstract.php +78 -0
  78. app/code/community/Fishpig/Wordpress/Model/Image.php +66 -0
  79. app/code/community/Fishpig/Wordpress/Model/Link.php +7 -0
  80. app/code/community/Fishpig/Wordpress/Model/Link/Category.php +13 -0
  81. app/code/community/Fishpig/Wordpress/Model/Mysql4/Abstract.php +107 -0
  82. app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User.php +37 -0
  83. app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User/Collection.php +10 -0
  84. app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Abstract.php +23 -0
  85. app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Collection/Abstract.php +66 -0
  86. app/code/community/Fishpig/Wordpress/Model/Mysql4/Collection/Abstract.php +64 -0
  87. app/code/community/Fishpig/Wordpress/Model/Mysql4/Image.php +10 -0
  88. app/code/community/Fishpig/Wordpress/Model/Mysql4/Image/Collection.php +16 -0
  89. app/code/community/Fishpig/Wordpress/Model/Mysql4/Link.php +9 -0
  90. app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category.php +9 -0
  91. app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category/Collection.php +12 -0
  92. app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Collection.php +19 -0
  93. app/code/community/Fishpig/Wordpress/Model/Mysql4/Option.php +9 -0
  94. app/code/community/Fishpig/Wordpress/Model/Mysql4/Option/Collection.php +10 -0
  95. app/code/community/Fishpig/Wordpress/Model/Mysql4/Page.php +32 -0
  96. app/code/community/Fishpig/Wordpress/Model/Mysql4/Page/Collection.php +48 -0
  97. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post.php +51 -0
  98. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Abstract.php +6 -0
  99. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Collection/Abstract.php +16 -0
  100. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category.php +10 -0
  101. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category/Collection.php +9 -0
  102. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection.php +165 -0
  103. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection/Abstract.php +102 -0
  104. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment.php +10 -0
  105. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment/Collection.php +29 -0
  106. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag.php +10 -0
  107. app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag/Collection.php +20 -0
  108. app/code/community/Fishpig/Wordpress/Model/Mysql4/User.php +9 -0
  109. app/code/community/Fishpig/Wordpress/Model/Mysql4/User/Collection.php +9 -0
  110. app/code/community/Fishpig/Wordpress/Model/Observer/Abstract.php +58 -0
  111. app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/Catalog/Product/SaveAssociations.php +114 -0
  112. app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/System/Config/SaveAfter.php +26 -0
  113. app/code/community/Fishpig/Wordpress/Model/Observer/DatabaseSetup.php +70 -0
  114. app/code/community/Fishpig/Wordpress/Model/Option.php +15 -0
  115. app/code/community/Fishpig/Wordpress/Model/Page.php +10 -0
  116. app/code/community/Fishpig/Wordpress/Model/Post.php +109 -0
  117. app/code/community/Fishpig/Wordpress/Model/Post/Abstract.php +102 -0
  118. app/code/community/Fishpig/Wordpress/Model/Post/Attachment/Abstract.php +31 -0
  119. app/code/community/Fishpig/Wordpress/Model/Post/Category.php +68 -0
  120. app/code/community/Fishpig/Wordpress/Model/Post/Comment.php +56 -0
  121. app/code/community/Fishpig/Wordpress/Model/Post/Tag.php +60 -0
  122. app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Encrypted.php +19 -0
  123. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Database/Location.php +13 -0
  124. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Content.php +16 -0
  125. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Excerpt.php +16 -0
  126. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Integration.php +12 -0
  127. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Shortcodes.php +17 -0
  128. app/code/community/Fishpig/Wordpress/Model/System/Config/Source/SyntaxHighlighter/Theme.php +19 -0
  129. app/code/community/Fishpig/Wordpress/Model/User.php +25 -0
  130. app/code/community/Fishpig/Wordpress/controllers/Adminhtml/DebugController.php +45 -0
  131. app/code/community/Fishpig/Wordpress/controllers/Adminhtml/RedirectController.php +123 -0
  132. app/code/community/Fishpig/Wordpress/controllers/Adminhtml/SupportController.php +106 -0
  133. app/code/community/Fishpig/Wordpress/controllers/Adminhtml/WpAdminController.php +49 -0
  134. app/code/community/Fishpig/Wordpress/controllers/Archive/ViewController.php +51 -0
  135. app/code/community/Fishpig/Wordpress/controllers/AuthorController.php +44 -0
  136. app/code/community/Fishpig/Wordpress/controllers/CategoryController.php +51 -0
  137. app/code/community/Fishpig/Wordpress/controllers/FeedController.php +21 -0
  138. app/code/community/Fishpig/Wordpress/controllers/HomepageController.php +37 -0
  139. app/code/community/Fishpig/Wordpress/controllers/PageController.php +20 -0
  140. app/code/community/Fishpig/Wordpress/controllers/Post/View/CommentController.php +84 -0
  141. app/code/community/Fishpig/Wordpress/controllers/Post/ViewController.php +65 -0
  142. app/code/community/Fishpig/Wordpress/controllers/RedirectController.php +21 -0
  143. app/code/community/Fishpig/Wordpress/controllers/SitemapController.php +34 -0
  144. app/code/community/Fishpig/Wordpress/controllers/TagController.php +69 -0
  145. app/code/community/Fishpig/Wordpress/etc/adminhtml.xml +51 -0
  146. app/code/community/Fishpig/Wordpress/etc/config.xml +374 -0
  147. app/code/community/Fishpig/Wordpress/etc/system.xml +385 -0
  148. app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-install-0.1.0.php +19 -0
  149. app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-0.3.2-0.3.3.php +22 -0
  150. app/design/adminhtml/default/default/layout/wordpress.xml +55 -0
  151. app/design/adminhtml/default/default/template/wordpress/admin-links-js.phtml +51 -0
  152. app/design/adminhtml/default/default/template/wordpress/config/js.phtml +39 -0
  153. app/design/adminhtml/default/default/template/wordpress/config/test/results.phtml +30 -0
  154. app/design/adminhtml/default/default/template/wordpress/support/index.phtml +38 -0
  155. app/design/adminhtml/default/default/template/wordpress/support/js.phtml +75 -0
  156. app/design/adminhtml/default/default/template/wordpress/support/tab/complete.phtml +46 -0
  157. app/design/adminhtml/default/default/template/wordpress/support/tab/debug-info.phtml +39 -0
  158. app/design/adminhtml/default/default/template/wordpress/support/tab/logs.phtml +23 -0
  159. app/design/frontend/base/default/layout/wordpress.xml +125 -0
  160. app/design/frontend/base/default/template/wordpress/archive/list.phtml +27 -0
  161. app/design/frontend/base/default/template/wordpress/archive/view.phtml +13 -0
  162. app/design/frontend/base/default/template/wordpress/author/view.phtml +13 -0
  163. app/design/frontend/base/default/template/wordpress/category/list.phtml +28 -0
  164. app/design/frontend/base/default/template/wordpress/category/view.phtml +16 -0
  165. app/design/frontend/base/default/template/wordpress/feed/rss2.phtml +48 -0
  166. app/design/frontend/base/default/template/wordpress/homepage.phtml +9 -0
  167. app/design/frontend/base/default/template/wordpress/links.phtml +17 -0
  168. app/design/frontend/base/default/template/wordpress/page/list.phtml +27 -0
  169. app/design/frontend/base/default/template/wordpress/page/view.phtml +47 -0
  170. app/design/frontend/base/default/template/wordpress/post/associated.phtml +15 -0
  171. app/design/frontend/base/default/template/wordpress/post/associated/list.phtml +15 -0
  172. app/design/frontend/base/default/template/wordpress/post/associated/product/list.phtml +28 -0
  173. app/design/frontend/base/default/template/wordpress/post/featured.phtml +17 -0
  174. app/design/frontend/base/default/template/wordpress/post/list.phtml +53 -0
  175. app/design/frontend/base/default/template/wordpress/post/recent.phtml +11 -0
  176. app/design/frontend/base/default/template/wordpress/post/recent/list.phtml +15 -0
  177. app/design/frontend/base/default/template/wordpress/post/syntaxhighlighter/trigger.phtml +46 -0
  178. app/design/frontend/base/default/template/wordpress/post/view.phtml +52 -0
  179. app/design/frontend/base/default/template/wordpress/post/view/comment/form.phtml +58 -0
  180. app/design/frontend/base/default/template/wordpress/post/view/comments.phtml +33 -0
  181. app/design/frontend/base/default/template/wordpress/shortcode/associated-products.phtml +28 -0
  182. app/design/frontend/base/default/template/wordpress/shortcode/product.phtml +16 -0
  183. app/design/frontend/base/default/template/wordpress/shortcode/youtube-video.phtml +14 -0
  184. app/design/frontend/base/default/template/wordpress/tag/list.phtml +19 -0
  185. app/design/frontend/base/default/template/wordpress/tag/view.phtml +16 -0
  186. app/etc/modules/Fishpig_Wordpress.xml +9 -0
  187. js/fishpig/wordpress/comments.js +37 -0
  188. package.xml +18 -0
app/code/community/Fishpig/Wordpress/Block/Abstract.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Block_Abstract extends Mage_Core_Block_Template
4
+ {
5
+ public function _helper($helper = null)
6
+ {
7
+ if ($helper != null) {
8
+ $helper = '/' . $helper;
9
+ }
10
+
11
+ return Mage::helper('wordpress' . $helper);
12
+ }
13
+
14
+ public function getParam($key, $default = null)
15
+ {
16
+ return Mage::app()->getRequest()->getParam($key, $default);
17
+ }
18
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Autologin extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'wordpress';
11
+ $this->_controller = 'adminhtml_autologin';
12
+ $this->_buttons = array();
13
+
14
+ $this->_addButton('save', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save'),
16
+ 'onclick' => 'editForm.submit();',
17
+ 'class' => 'save',
18
+ ), 1);
19
+ }
20
+
21
+ public function getHeaderText()
22
+ {
23
+ return $this->__('1-Click WordPress Login');
24
+ }
25
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Autologin_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $adminUser = Mage::registry('wordpress_admin_user');
8
+ $form = new Varien_Data_Form(array(
9
+ 'id' => 'edit_form',
10
+ 'action' => $this->getUrl('*/*/save', array('id' => ($adminUser) ? $adminUser->getId() : null)),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tab/Form.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Autologin_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ $form = new Varien_Data_Form();
9
+
10
+ $this->setForm($form);
11
+
12
+ $fieldset = $form->addFieldset('autologin_form', array('legend'=>'&nbsp;'));
13
+
14
+ $fieldset->addField('username', 'text', array(
15
+ 'label' => 'Username',
16
+ 'class' => 'required-entry',
17
+ 'required' => true,
18
+ 'name' => 'username',
19
+ ));
20
+
21
+ $fieldset->addField('password', 'password', array(
22
+ 'label' => 'Password',
23
+ 'class' => 'required-entry',
24
+ 'required' => true,
25
+ 'name' => 'password',
26
+ ));
27
+
28
+ $configUrl = $this->getUrl($this->helper('wordpress/adminhtml')->getWordpressConfigPath());
29
+
30
+ $text = new Varien_Data_Form_Element_Note();
31
+ $text->setText('
32
+ <input type="hidden" name="redirect_to" value="'.$this->_getRedirectTo().'"/>
33
+ <p style="font-weight:bold; padding:10px 5px;">
34
+ Before you attempt to use this feature it is recommended that you pass all integration tests in the <a href="'.$configUrl.'" style="text-decoration:none;">Magento/WordPress configuration</a> section
35
+ </p>
36
+ ');
37
+
38
+ $fieldset->addElement($text);
39
+
40
+ if (Mage::registry('wordpress_admin_user')) {
41
+ $form->setValues(Mage::registry('wordpress_admin_user')->getData());
42
+ }
43
+
44
+ return parent::_prepareForm();
45
+ }
46
+
47
+ protected function _getRedirectTo()
48
+ {
49
+ return Mage::app()->getRequest()->getParam('redirect_to');
50
+ }
51
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Autologin/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Autologin_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('autologin_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle($this->__('WP Admin Login'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => $this->__('Login Information'),
18
+ 'title' => $this->__('Login Information'),
19
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_autologin_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Category/Grid.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Category_Grid extends Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract
4
+ {
5
+ protected $_constructData = array('id' => 'wpCategoryGrid', 'default_sort' => 'name', 'default_dir' => 'asc');
6
+
7
+ /**
8
+ * Prepare the collection of posts to display
9
+ */
10
+ protected function _prepareCollection()
11
+ {
12
+ $collection = Mage::getResourceModel('wordpress/post_category_collection');
13
+ $collection->getSelect()->order('name ASC');
14
+
15
+ $this->setCollection($collection);
16
+
17
+ return parent::_prepareCollection();
18
+ }
19
+
20
+ /**
21
+ * Prepares the columns of the grid
22
+ */
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('term_id', array(
26
+ 'type' => 'checkbox',
27
+ 'field_name' => 'wp_category_id[]',
28
+ 'align' => 'center',
29
+ 'index' => 'term_id',
30
+ 'header' => '&nbsp;',
31
+ 'values' => $this->_getSelectedWpItems('category'),
32
+ ));
33
+
34
+ $this->addColumn('name', array(
35
+ 'header'=> 'Name',
36
+ 'index' => 'name',
37
+ ));
38
+
39
+ $this->addColumn('slug', array(
40
+ 'header'=> 'Slug',
41
+ 'index' => 'slug',
42
+ ));
43
+
44
+ return parent::_prepareColumns();
45
+ }
46
+
47
+ /**
48
+ * Retrieve the label used for the tab relating to this block
49
+ *
50
+ * @return string
51
+ */
52
+ public function getTabLabel()
53
+ {
54
+ return $this->__('Associated Blog Categories');
55
+ }
56
+
57
+ /**
58
+ * Retrieve the title used by this tab
59
+ *
60
+ * @return string
61
+ */
62
+ public function getTabTitle()
63
+ {
64
+ return $this->__('Associate WordPress blog categories (and children posts) with this product');
65
+ }
66
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Grid/Abstract.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid
4
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
5
+ {
6
+ /**
7
+ * Setup the grid
8
+ */
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setId($this->_constructData['id']);
13
+ $this->setDefaultSort($this->_constructData['default_sort']);
14
+ $this->setDefaultDir($this->_constructData['default_dir']);
15
+ $this->setSaveParametersInSession(true);
16
+
17
+ }
18
+
19
+ /**
20
+ * Returns an array of all of the product's currently associated post ID's
21
+ *
22
+ * @param string $type must be either post or category
23
+ * @return array
24
+ */
25
+ protected function _getSelectedWpItems($type)
26
+ {
27
+ $postIds = array();
28
+ $productId = $this->_getProduct()->getId();
29
+ if ($productId) {
30
+ $table = Mage::getSingleton('core/resource')->getTableName('wordpress_product_'.$type);
31
+ $sql = "SELECT {$type}_id FROM {$table} WHERE product_id = {$productId}";
32
+ $results = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($sql);
33
+
34
+ foreach($results as $result) {
35
+ $postIds[] = $result[$type.'_id'];
36
+ }
37
+ }
38
+
39
+ return $postIds;
40
+ }
41
+
42
+ /**
43
+ * Returns the current product model
44
+ *
45
+ * @return Mage_Catalog_Model_Product
46
+ */
47
+ protected function _getProduct()
48
+ {
49
+ return Mage::registry('product');
50
+ }
51
+
52
+ /**
53
+ * Displays the tab if integration is valid
54
+ *
55
+ * @return true
56
+ */
57
+ public function canShowTab()
58
+ {
59
+ try {
60
+ Mage::getSingleton('core/resource')
61
+ ->getConnection('wordpress_read')
62
+ ->query("SELECT ID from " . $this->helper('wordpress/db')->getTableName('posts') . " LIMIT 1");
63
+
64
+ return true;
65
+ }
66
+ catch (Exception $e) {
67
+ return false;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Stops the tab being hidden
73
+ *
74
+ * @return bool
75
+ */
76
+ public function isHidden()
77
+ {
78
+ return false;
79
+ }
80
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Catalog/Product/Edit/Tab/Post/Grid.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Post_Grid extends Fishpig_Wordpress_Block_Adminhtml_Catalog_Product_Edit_Tab_Grid_Abstract
4
+ {
5
+ protected $_constructData = array('id' => 'wpPostGrid', 'default_sort' => 'post_date', 'default_dir' => 'desc');
6
+
7
+
8
+ /**
9
+ * Prepare the collection of posts to display
10
+ */
11
+ protected function _prepareCollection()
12
+ {
13
+ $collection = Mage::getResourceModel('wordpress/post_collection')
14
+ ->addIsPublishedFilter();
15
+ $this->setCollection($collection);
16
+
17
+ return parent::_prepareCollection();
18
+ }
19
+
20
+ /**
21
+ * Prepares the columns of the grid
22
+ */
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('ID', array(
26
+ 'type' => 'checkbox',
27
+ 'field_name' => 'wp_post_id[]',
28
+ 'align' => 'center',
29
+ 'index' => 'ID',
30
+ 'header' => '&nbsp;',
31
+ 'values' => $this->_getSelectedWpItems('post'),
32
+ ));
33
+
34
+ $this->addColumn('post_title', array(
35
+ 'header'=> 'Post Title',
36
+ 'index' => 'post_title',
37
+ ));
38
+
39
+ $this->addColumn('post_date', array(
40
+ 'header'=> 'Post Date',
41
+ 'index' => 'post_date',
42
+ 'type' => 'date',
43
+ 'format' => 'd MMMM YYYY',
44
+ ));
45
+
46
+ return parent::_prepareColumns();
47
+ }
48
+
49
+ /**
50
+ * Retrieve the label used for the tab relating to this block
51
+ *
52
+ * @return string
53
+ */
54
+ public function getTabLabel()
55
+ {
56
+ return $this->__('Associated Blog Posts');
57
+ }
58
+
59
+ /**
60
+ * Retrieve the title used by this tab
61
+ *
62
+ * @return string
63
+ */
64
+ public function getTabTitle()
65
+ {
66
+ return $this->__('Associate WordPress blog posts with this product');
67
+ }
68
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Support extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'wordpress';
11
+ $this->_controller = 'adminhtml_support';
12
+ $this->_buttons = array();
13
+ }
14
+
15
+ public function getHeaderText()
16
+ {
17
+ return 'Fishpig\'s Magento WordPress Integration Extension';
18
+ }
19
+
20
+
21
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Support_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/send', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ // 'enctype' => 'multipart/form-data'
12
+ ));
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/Form/Abstract.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Block_Adminhtml_Support_Tab_Form_Abstract extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+
7
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tab/RequestForm.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Support_Tab_RequestForm extends Fishpig_Wordpress_Block_Adminhtml_Support_Tab_Form_Abstract
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+
9
+ $this->setForm($form);
10
+ $fieldset = $form->addFieldset('question_form', array('legend'=>'<span class="enquirytype">Support Ticket</span> Details'));
11
+
12
+ $fieldset->addField('sender_name', 'text', array(
13
+ 'label' => 'Your Name',
14
+ 'name' => 'sender_name',
15
+ 'required' => true,
16
+ ));
17
+
18
+ $fieldset->addField('sender_email', 'text', array(
19
+ 'label' => 'Email Address',
20
+ 'name' => 'sender_email',
21
+ 'class' => 'validate-email',
22
+ 'required' => true,
23
+ ));
24
+
25
+ $fieldset->addField('enquiry_type', 'select', array(
26
+ 'label' => 'Enquiry Type',
27
+ 'name' => 'enquiry_type',
28
+ 'required' => 'true',
29
+ 'values' => $this->_getEnquiryTypeOptions(),
30
+ ));
31
+
32
+ $fieldset->addField('subject', 'text', array(
33
+ 'label' => 'Subject',
34
+ 'name' => 'subject',
35
+ 'required' => true,
36
+ ));
37
+
38
+ $fieldset->addField('content', 'textarea', array(
39
+ 'label' => 'Details',
40
+ 'name' => 'content',
41
+ 'required' => true,
42
+ ));
43
+
44
+ $fieldset->addField('buttons', 'note', array(
45
+ 'text' => '<div style="height:1%;overflow:hidden;"><button type="button" class="scalable back left support-previous" id="content_previous"><span>' . $this->__('Previous') . '</span></button><button type="button" class="scalable add right support-next" id="content_next"><span>' . $this->__('Next') . '</span></button></div>',
46
+ ));
47
+
48
+ if ($supportData = Mage::getSingleton('adminhtml/session')->getSupportData()) {
49
+ $form->setValues($supportData);
50
+ }
51
+
52
+ return parent::_prepareForm();
53
+ }
54
+
55
+
56
+ protected function _getEnquiryTypeOptions()
57
+ {
58
+ $options = array();
59
+
60
+ foreach(array($this->__('Support Ticket'), $this->__('Bug Report')) as $value) {
61
+ $options[] = array('value' => $value, 'label' => $this->__($value));
62
+ }
63
+
64
+ return $options;
65
+ }
66
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Support/Tabs.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Support_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('support_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle($this->_wrapEnquiryType('Support Ticket'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('dashboard', array(
17
+ 'label' => $this->_wrapEnquiryType('Support Ticket'),
18
+ 'title' => 'Enquiry Type',
19
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/index.phtml')->toHtml(),
20
+ ));
21
+
22
+ $this->addTab('content', array(
23
+ 'label' => $this->__('Details'),
24
+ 'title' => $this->__('Details'),
25
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_support_tab_requestForm')->toHtml(),
26
+ ));
27
+
28
+ $this->addTab('debug', array(
29
+ 'label' => $this->__('System Information'),
30
+ 'title' => '- '.$this->__('System Information'),
31
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/debug-info.phtml')->toHtml(),
32
+ ));
33
+
34
+ $this->addTab('log_files', array(
35
+ 'label' => $this->__('Log Files'),
36
+ 'title' => $this->__('Log Files'),
37
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/logs.phtml')->toHtml(),
38
+ ));
39
+
40
+ $this->addTab('complete', array(
41
+ 'label' => $this->__('Send Your ').$this->_wrapEnquiryType('Support Ticket'),
42
+ 'title' => $this->__('Send'),
43
+ 'content' => $this->getLayout()->createBlock('wordpress/adminhtml_template')->setTemplate('wordpress/support/tab/complete.phtml')->toHtml(),
44
+ ));
45
+
46
+ return parent::_beforeToHtml();
47
+ }
48
+
49
+ protected function _wrapEnquiryType($text)
50
+ {
51
+ return '<span class="enquirytype" style="background:none; display:inline;padding:0;">'.$this->__($text).'</span>';
52
+ }
53
+
54
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Column/Result.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FIshpig_Wordpress_Block_Adminhtml_System_Config_Test_Results_Column_Result extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+
6
+
7
+ public function _getValue(Varien_Object $row)
8
+ {
9
+ $data = parent::_getValue($row);
10
+ $styles = array(
11
+ 'background-color:transparent',
12
+ 'background-position:3px 1px',
13
+ 'border:0px solid', 'display:block',
14
+ 'width:23px',
15
+ );
16
+
17
+ return '<span class="'.$data.'" style="'.implode(' !important;', $styles).'">&nbsp</span>';
18
+ }
19
+
20
+
21
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Test/Results/Grid.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_System_Config_Test_Results_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ protected function _afterToHtml($html)
6
+ {
7
+ if (Mage::helper('wordpress/debug_test')->hasResults()) {
8
+ return $html;
9
+ }
10
+ }
11
+
12
+ /**
13
+ * Prepare the collection of posts to display
14
+ */
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = $this->_getResultCollection();
18
+ $this->setCollection($collection);
19
+
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _getResultCollection()
24
+ {
25
+ return Mage::helper('wordpress/debug_test')->performIntegrationTests();
26
+ }
27
+
28
+ /**
29
+ * Prepares the columns of the grid
30
+ */
31
+ protected function _prepareColumns()
32
+ {
33
+ $this->addResultColumn();
34
+
35
+ $this->addColumn('title', array(
36
+ 'header'=> 'Test Title',
37
+ 'index' => 'title',
38
+ 'width' => '260px',
39
+ ));
40
+
41
+ $this->addColumn('response', array(
42
+ 'header'=> 'Server Response',
43
+ 'index' => 'response',
44
+ ));
45
+
46
+ return parent::_prepareColumns();
47
+ }
48
+
49
+ protected function addResultColumn()
50
+ {
51
+ $column = $this->addColumn('result', array('header'=> '&nbsp;', 'index' => 'result', 'width' => '23px'))->getColumn('result');
52
+ $render = $this->getLayout()->createBlock('wordpress/adminhtml_system_config_test_results_column_result')->setColumn($column);
53
+ $column->setRenderer($render);
54
+
55
+ return $this;
56
+ }
57
+
58
+ protected function _prepareLayout()
59
+ {
60
+ $result = parent::_prepareLayout();
61
+
62
+ $this->unsetChild('reset_filter_button');
63
+ $this->unsetChild('search_button');
64
+ $this->unsetChild('export_button');
65
+
66
+ $this->_pagerVisibility = false;
67
+ $this->_filterVisibility = false;
68
+
69
+ // $this->setGridHeader('WordPress Integration Results');
70
+
71
+ return $result;
72
+ }
73
+
74
+
75
+
76
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Wrapper.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_System_Config_Wrapper extends Fishpig_Wordpress_Block_Adminhtml_Template
4
+ {
5
+ /**
6
+ * Used to ensure ACL message is only displayed once
7
+ *
8
+ * @var int
9
+ */
10
+ static protected $_aclNoticeIssued = 0;
11
+
12
+ /**
13
+ * Message to display when ACL isn't correct
14
+ *
15
+ * @var const string
16
+ */
17
+ const _ACTION_MSG = 'To finish installing Fishpig\'s Magento WordPress integration extension, log out of Magento and log back in.';
18
+
19
+ /**
20
+ * This adds a message to the settings page if the 'Access denied' message is displayed
21
+ */
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+
26
+ if (!$this->isAclValid()) {
27
+ if (self::$_aclNoticeIssued < 2) {
28
+ Mage::getSingleton('adminhtml/session')->addNotice(self::_ACTION_MSG);
29
+ self::$_aclNoticeIssued = (self::$_aclNoticeIssued + 1);
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Returns true if the ACL is registered correctly
36
+ *
37
+ * @return bool
38
+ */
39
+ public function isAclValid()
40
+ {
41
+ return $this->_helper('debug')->isAclValid();
42
+ }
43
+
44
+ }
app/code/community/Fishpig/Wordpress/Block/Adminhtml/Template.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Template
4
+ {
5
+ /**
6
+ * Returns true if this is the WordPress section
7
+ *
8
+ * @return bool
9
+ */
10
+ public function isWordpressSection()
11
+ {
12
+ return strtolower(trim($this->getParam('section'))) == 'wordpress';
13
+ }
14
+
15
+ /**
16
+ * Gets the Adminhtml session
17
+ * @return Mage_Adminhtml_Model_Session
18
+ */
19
+ public function getSession()
20
+ {
21
+ return Mage::getSingleton('adminhtml/session');
22
+ }
23
+
24
+ public function getParam($param, $default = null)
25
+ {
26
+ return Mage::app()->getRequest()->getParam($param, $default);
27
+ }
28
+
29
+ public function _helper($helper = null)
30
+ {
31
+ if ($helper != null) {
32
+ $helper = '/' . $helper;
33
+ }
34
+
35
+ return Mage::helper('wordpress' . $helper);
36
+ }
37
+
38
+ }
app/code/community/Fishpig/Wordpress/Block/Archive/List.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Archive_List extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ /**
6
+ * Cache for archive collection
7
+ *
8
+ * @var null|Varien_Data_Collection
9
+ */
10
+ protected $_archiveCollection = null;
11
+
12
+ /**
13
+ * Returns a collection of valid archive dates
14
+ *
15
+ * @return Varien_Data_Collection
16
+ */
17
+ public function getArchives()
18
+ {
19
+ if (is_null($this->_archiveCollection)) {
20
+ $sql = "SELECT COUNT(ID) AS post_count, CONCAT(SUBSTRING(post_date, 1, 4), '/', SUBSTRING(post_date, 6, 2)) as archive_date"
21
+ . Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter()->getSelect()->setPart('columns', array())
22
+ . " GROUP BY archive_date";
23
+ $dates = $this->_helper('db')->getWordpressRead()->fetchAll($sql);
24
+ $collection = new Varien_Data_Collection();
25
+
26
+ foreach($dates as $date) {
27
+ $obj = Mage::getModel('wordpress/archive')->load($date['archive_date']);
28
+ $obj->setPostCount($date['post_count']);
29
+ $collection->addItem($obj);
30
+ }
31
+
32
+ $this->_archiveCollection = $collection;
33
+ }
34
+
35
+ return $this->_archiveCollection;
36
+ }
37
+
38
+ }
app/code/community/Fishpig/Wordpress/Block/Archive/View.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Archive_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Caches and returns the archive model
7
+ *
8
+ * @return Fishpig_Wordpress_Model_Archive
9
+ */
10
+ public function getArchive()
11
+ {
12
+ if (!$this->hasData('archive')) {
13
+ $this->setData('archive', Mage::registry('wordpress_archive'));
14
+ }
15
+
16
+ return $this->getData('archive');
17
+ }
18
+
19
+ public function getArchiveId()
20
+ {
21
+ if ($archive = $this->getArchive()) {
22
+ return $archive->getId();
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Generates and returns the collection of posts
28
+ *
29
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
30
+ */
31
+ protected function _getPostCollection()
32
+ {
33
+ if (is_null($this->_postCollection)) {
34
+ $this->_postCollection = parent::_getPostCollection()
35
+ ->addArchiveDateFilter($this->getArchiveId());
36
+ }
37
+
38
+ return $this->_postCollection;
39
+ }
40
+
41
+
42
+ }
app/code/community/Fishpig/Wordpress/Block/Author/View.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Author_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Caches and returns the current category
7
+ *
8
+ * @return Fishpig_Wordpress_Model_User
9
+ */
10
+ public function getAuthor()
11
+ {
12
+ if (!$this->hasData('wordpress_author')) {
13
+ $this->setData('wordpress_author', Mage::registry('wordpress_author'));
14
+ }
15
+
16
+ return $this->getData('wordpress_author');
17
+ }
18
+
19
+ public function getAuthorId()
20
+ {
21
+ if ($author = $this->getAuthor()) {
22
+ return $author->getId();
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Generates and returns the collection of posts
28
+ *
29
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
30
+ */
31
+ protected function _getPostCollection()
32
+ {
33
+ if (is_null($this->_postCollection)) {
34
+ $this->_postCollection = parent::_getPostCollection()
35
+ ->addAuthorIdFilter($this->getAuthorId());
36
+ }
37
+
38
+ return $this->_postCollection;
39
+ }
40
+
41
+
42
+ }
app/code/community/Fishpig/Wordpress/Block/Category/List.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Category_List extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ /**
6
+ * Cache for category collection
7
+ *
8
+ * @var Fishpig_Wordpress_Model_Mysql4_Category_Collection $_categoryCollection
9
+ */
10
+ protected $_categoryCollection = null;
11
+
12
+ /**
13
+ * Returns the current category collection
14
+ */
15
+ public function getCategories()
16
+ {
17
+ if (is_null($this->_categoryCollection)) {
18
+ $collection = Mage::getResourceModel('wordpress/post_category_collection')
19
+ ->addParentIdFilter($this->getParentId());
20
+
21
+ $collection->getSelect()->order('name ASC');
22
+
23
+ $this->setCollection($collection);
24
+ }
25
+
26
+ return $this->_categoryCollection;
27
+ }
28
+
29
+ /**
30
+ * Manually set the category collection
31
+ *
32
+ * @param Fishpig_Wordpress_Model_Mysql4_Category_Collection $collection
33
+ */
34
+ public function setCollection(Fishpig_Wordpress_Model_Mysql4_Category_Collection_Abstract $collection)
35
+ {
36
+ $this->_categoryCollection = $collection;
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Returns the parent ID used to display categories
42
+ * If parent_id is not set, 0 will be returned and root categories displayed
43
+ *
44
+ * @return int
45
+ */
46
+ public function getParentId()
47
+ {
48
+ return number_format($this->getData('parent_id'), 0, '', '');
49
+ }
50
+
51
+ }
app/code/community/Fishpig/Wordpress/Block/Category/View.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Category_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Returns the current Wordpress category
7
+ * This is just a wrapper for getCurrentCategory()
8
+ *
9
+ * @return Fishpig_Wordpress_Model_Post_Categpry
10
+ */
11
+ public function getCategory()
12
+ {
13
+ return $this->getCurrentCategory();
14
+ }
15
+
16
+ /**
17
+ * Caches and returns the current category
18
+ *
19
+ * @return Fishpig_Wordpress_Model_Post_Categpry
20
+ */
21
+ public function getCurrentCategory()
22
+ {
23
+ if (!$this->hasData('wordpress_category')) {
24
+ if ($categoryId = $this->getData('category_id')) {
25
+ $category = Mage::getModel('wordpress/post_category')->load($categoryId);
26
+
27
+ if ($category->getId() == $categoryId) {
28
+ $this->setData('category', $category);
29
+ }
30
+ }
31
+ else {
32
+ $this->setData('category', Mage::registry('wordpress_category'));
33
+ }
34
+ }
35
+
36
+ return $this->getData('category');
37
+ }
38
+
39
+ public function getCurrentCategoryId()
40
+ {
41
+ if ($category = $this->getCurrentCategory()) {
42
+ return $category->getId();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Generates and returns the collection of posts
48
+ *
49
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
50
+ */
51
+ protected function _getPostCollection()
52
+ {
53
+ if (is_null($this->_postCollection)) {
54
+ $this->_postCollection = parent::_getPostCollection()
55
+ ->addCategoryIdFilter($this->getCurrentCategoryId());
56
+ }
57
+
58
+ return $this->_postCollection;
59
+ }
60
+
61
+
62
+ }
app/code/community/Fishpig/Wordpress/Block/Feed/Rss2.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Feed_Rss2 extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->setTemplate('wordpress/feed/rss2.phtml');
8
+ }
9
+
10
+ public function getPosts()
11
+ {
12
+ $collection = Mage::getResourceModel('wordpress/post_collection')
13
+ ->addIsPublishedFilter()
14
+ ->setOrderByPostDate()
15
+ ->setPageSize($this->_helper()->getCachedWpOption('posts_per_rss', 10));
16
+
17
+ return $collection;
18
+ }
19
+
20
+ public function getDocType()
21
+ {
22
+ return '<?xml version="1.0" encoding="'.$this->getBlogCharset().'"?>'."\n";
23
+ }
24
+
25
+ public function getBlogCharset()
26
+ {
27
+ return $this->_helper()->getCachedWpOption('blog_charset');
28
+ }
29
+
30
+ public function getRssTitle()
31
+ {
32
+ return $this->decode($this->_helper()->getCachedWpOption('blogname'));
33
+ }
34
+
35
+ public function getFeedUrl()
36
+ {
37
+ return $this->_helper()->getUrl('feed');
38
+ }
39
+
40
+ public function getRssLanguage()
41
+ {
42
+ return $this->_helper()->getCachedWpOption('rss_language');
43
+ }
44
+
45
+ public function displayExceprt()
46
+ {
47
+ return $this->_helper()->getCachedWpOption('rss_use_excerpt');
48
+ }
49
+
50
+ public function decode($value)
51
+ {
52
+ return html_entity_decode($value, ENT_NOQUOTES, $this->getBlogCharset());
53
+ }
54
+ }
app/code/community/Fishpig/Wordpress/Block/Homepage.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Homepage extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Get's the blog title
7
+ *
8
+ * @return string
9
+ */
10
+ public function getBlogTitle()
11
+ {
12
+ return $this->_helper()->getCachedWpOption('blogname');
13
+ }
14
+
15
+ /**
16
+ * Returns the blog homepage URL
17
+ *
18
+ * @return string
19
+ */
20
+ public function getBlogHomepageUrl()
21
+ {
22
+ return $this->_helper()->getUrl();
23
+ }
24
+
25
+ /**
26
+ * Generates and returns the collection of posts
27
+ *
28
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
29
+ */
30
+ protected function _getPostCollection()
31
+ {
32
+ if (is_null($this->_postCollection)) {
33
+ $this->_postCollection = parent::_getPostCollection();
34
+ }
35
+
36
+ return $this->_postCollection;
37
+ }
38
+
39
+
40
+ }
app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_Associated_Products extends Fishpig_Wordpress_Block_Post_View_Abstract
4
+ {
5
+ public function getProducts($attributes = '*')
6
+ {
7
+ return $this->_helper('catalog_product')
8
+ ->getAssociatedProducts($this->getPost())
9
+ ->addAttributeToSelect($attributes)
10
+ ->load();
11
+ }
12
+ }
app/code/community/Fishpig/Wordpress/Block/Post/List.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_List extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ /**
6
+ * Cache for post collection
7
+ *
8
+ * @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
9
+ */
10
+ protected $_postCollection = null;
11
+
12
+ /**
13
+ * Block wrapper (category, tag, author etc)
14
+ *
15
+ * @var Fishpig_Wordpress_Block_Post_List_Abstract
16
+ */
17
+ protected $_wrapperBlock = null;
18
+
19
+ /**
20
+ * Amount of posts to display on a page
21
+ * If this is left null then this value is taken form the WP-Admin config
22
+ *
23
+ * @var int
24
+ */
25
+ protected $_pagerLimit = null;
26
+
27
+ /**
28
+ * Name of the pager block
29
+ *
30
+ * @var string
31
+ */
32
+ protected $_pagerBlockName = 'wordpress_post_list_pager';
33
+
34
+ /**
35
+ * Returns the collection of posts
36
+ *
37
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
38
+ */
39
+ public function getPosts()
40
+ {
41
+ return $this->_getPostCollection();
42
+ }
43
+
44
+ /**
45
+ * Generates and returns the collection of posts
46
+ *
47
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
48
+ */
49
+ protected function _getPostCollection()
50
+ {
51
+ if (is_null($this->_postCollection)) {
52
+ if (is_null($this->getWrapperBlock()) == false) {
53
+ $this->_postCollection = $this->getWrapperBlock()->getPostCollection();
54
+ }
55
+ }
56
+
57
+ return $this->_postCollection;
58
+ }
59
+
60
+ /**
61
+ * Sets the parent block of this block
62
+ * This block can be used to auto generate the post list
63
+ *
64
+ * @param Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper
65
+ */
66
+ public function setWrapperBlock(Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper)
67
+ {
68
+ $this->_wrapperBlock = $wrapper;
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Returns the block wrapper object
74
+ *
75
+ * @return Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
76
+ */
77
+ public function getWrapperBlock()
78
+ {
79
+ return $this->_wrapperBlock;
80
+ }
81
+
82
+ /**
83
+ * Get the pager block
84
+ * If the block isn't set in the layout XML, it will be created and will use the default template
85
+ *
86
+ * @return Fishpig_Wordpress_Post_List_Pager
87
+ */
88
+ public function getPagerBlock()
89
+ {
90
+ $pagerBlock = $this->getChild($this->_pagerBlockName);
91
+
92
+ if (!$pagerBlock) {
93
+ $pagerBlock = $this->getLayout()
94
+ ->createBlock('wordpress/post_list_pager', $this->_pagerBlockName.microtime().rand(1,9999));
95
+ }
96
+
97
+ $pagerBlock->setLimit($this->_getPagerLimit())
98
+ ->setPageVarName('page')
99
+ ->setAvailableLimit($this->_getPagerAvailableLimit());
100
+
101
+ $pagerBlock->setCollection($this->_getPostCollection());
102
+
103
+ return $pagerBlock;
104
+ }
105
+
106
+ /**
107
+ * Get the HTML for the pager block
108
+ *
109
+ * @return string
110
+ */
111
+ public function getPagerHtml()
112
+ {
113
+ return $this->getPagerBlock()->toHtml();
114
+ }
115
+
116
+ /**
117
+ * Gets the posts per page limit
118
+ *
119
+ * @return int
120
+ */
121
+ protected function _getPagerLimit()
122
+ {
123
+ if (is_null($this->_pagerLimit)) {
124
+ $this->_pagerLimit = $this->getParam('limit', $this->_helper()->getCachedWpOption('posts_per_page', 10));
125
+ }
126
+
127
+ return (int)$this->_pagerLimit;
128
+ }
129
+
130
+ /**
131
+ * Returns the available limits for the pager
132
+ * As Wordpress uses a fixed page size limit, this returns only 1 limit (the value set in WP admin)
133
+ * This effectively hides the 'Show 4/Show 10' drop down
134
+ *
135
+ * @return array
136
+ */
137
+ protected function _getPagerAvailableLimit()
138
+ {
139
+ return array($this->_getPagerLimit() => $this->_getPagerLimit());
140
+ }
141
+
142
+ }
app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_List_Associated extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Set the number of posts to display to 5
7
+ * This can be overridden using self::setPostCount($postCount)
8
+ */
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->_pagerLimit = 5;
13
+ $this->setPostListTemplate('wordpress/post/associated/list.phtml');
14
+ $this->setTitle('Blog Posts Associated With This Product');
15
+ }
16
+
17
+ /**
18
+ * Sets the number of posts to display
19
+ *
20
+ * @param string $postCount
21
+ */
22
+ public function setPostCount($postCount = 5)
23
+ {
24
+ $this->_pagerLimit = $postCount;
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Adds on cateogry/author ID filters
30
+ *
31
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
32
+ */
33
+ protected function _getPostCollection()
34
+ {
35
+ $collection = $this->_helper('catalog_product')
36
+ ->getAssociatedPosts($this->getProduct())
37
+ ->setCurPage(1);
38
+
39
+ return $collection;
40
+ }
41
+
42
+ /**
43
+ * Get's the current product if 1 hasn't been set
44
+ *
45
+ * @return Mage_Catalog_Model_Product
46
+ */
47
+ public function getProduct()
48
+ {
49
+ if (!$this->hasData('product')) {
50
+ if (!$this->hasData('product_id')) {
51
+ $this->setData('product', Mage::Registry('product'));
52
+ }
53
+ else {
54
+ $this->setData('product', Mage::getModel('catalog/product')->load($this->getData('product_id')));
55
+ }
56
+ }
57
+
58
+ return $this->getData('product');
59
+ }
60
+
61
+ }
app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_List_Pager extends Mage_Page_Block_Html_Pager
4
+ {
5
+ /**
6
+ * Return the URL for a certain page of the collection
7
+ *
8
+ * @return string
9
+ */
10
+ public function getPagerUrl($params=array())
11
+ {
12
+ $pathInfo = explode('/', $this->_getPathInfo());
13
+ $parts = array();
14
+
15
+ for ($it = 1; $it < count($pathInfo); $it = $it+2) {
16
+ if (isset($pathInfo[$it+1])) {
17
+ $key = (binary) $pathInfo[$it];
18
+ $parts[$key] = $pathInfo[$it+1];
19
+ }
20
+ }
21
+
22
+ foreach($params as $key => $param) {
23
+ $parts[$key] = $param;
24
+ }
25
+
26
+ return Mage::helper('wordpress')->getUrl(null, $parts);
27
+ }
28
+
29
+ /**
30
+ * Gets the path info from the request object
31
+ *
32
+ * @return string
33
+ */
34
+ protected function _getPathInfo()
35
+ {
36
+ return trim(Mage::app()->getRequest()->getPathInfo(), '/');;
37
+ }
38
+
39
+ }
app/code/community/Fishpig/Wordpress/Block/Post/List/Recent.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_List_Recent extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Set the number of posts to display to 5
7
+ * This can be overridden using self::setPostCount($postCount)
8
+ */
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->_pagerLimit = 5;
13
+ $this->setPostListTemplate('wordpress/post/recent/list.phtml');
14
+ $this->setTitle('Recent Posts');
15
+ }
16
+
17
+ /**
18
+ * Sets the number of posts to display
19
+ *
20
+ * @param string $postCount
21
+ */
22
+ public function setPostCount($postCount = 5)
23
+ {
24
+ $this->_pagerLimit = $postCount;
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Adds on cateogry/author ID filters
30
+ *
31
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
32
+ */
33
+ protected function _getPostCollection()
34
+ {
35
+ $collection = parent::_getPostCollection()
36
+ ->setPageSize($this->_pagerLimit)
37
+ ->setCurPage(1);
38
+
39
+
40
+ if ($categoryId = $this->getData('category_id')) {
41
+ $collection->addCategoryIdFilter($categoryId);
42
+ }
43
+
44
+ if ($authorId = $this->getData('author_id')) {
45
+ $collection->addAuthorIdFilter($authorId);
46
+ }
47
+
48
+ return $collection;
49
+ }
50
+
51
+ }
app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ /**
6
+ * Cache for post collection
7
+ *
8
+ * @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
9
+ */
10
+ protected $_postCollection = null;
11
+
12
+ /**
13
+ * Block name for the post list block
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_postListBlockName = 'wordpress_post_list';
18
+
19
+ /**
20
+ * Instructs whether to set pagination and page size automatically
21
+ * collection size is set in the Wordpress Admin
22
+ * Page ID will be taken from the URL
23
+ *
24
+ * @var bool
25
+ */
26
+ protected $_autoPaginate = false;
27
+
28
+ /**
29
+ * Constructor
30
+ * This sets the default template for listing the posts
31
+ * This is not the template for this (wrapper)
32
+ *
33
+ */
34
+ public function __construct()
35
+ {
36
+ parent::__construct();
37
+ // Set the default template to list the posts
38
+ $this->setPostListTemplate('wordpress/post/list.phtml');
39
+ }
40
+
41
+ /**
42
+ * Returns the collection of posts
43
+ *
44
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
45
+ */
46
+ public function getPostCollection()
47
+ {
48
+ return $this->_getPostCollection();
49
+ }
50
+
51
+ /**
52
+ * Generates and returns the collection of posts
53
+ *
54
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
55
+ */
56
+ protected function _getPostCollection()
57
+ {
58
+ $collection = Mage::getResourceModel('wordpress/post_collection')
59
+ ->addIsPublishedFilter()
60
+ ->setPostsPerPage()
61
+ ->setPageFromUrl()
62
+ ->setOrderByPostDate();
63
+
64
+ return $collection;
65
+ }
66
+
67
+
68
+ /**
69
+ * Returns the HTML for the post collection
70
+ *
71
+ * @return string
72
+ */
73
+ public function getPostListHtml()
74
+ {
75
+ return $this->getPostListBlock()->toHtml();
76
+ }
77
+
78
+ /**
79
+ * Gets the post list block
80
+ *
81
+ * @return Fishpig_Wordpress_Block_Post_List
82
+ */
83
+ public function getPostListBlock()
84
+ {
85
+ if (!$this->hasData('post_list_block')) {
86
+ if ($block = $this->getChild($this->_postListBlockName)) {
87
+ $this->setData('post_list_block', $block->setWrapperBlock($this));
88
+ }
89
+ else {
90
+ $this->setData('post_list_block', $this->_createPostListBlock());
91
+ }
92
+ }
93
+
94
+ return $this->getData('post_list_block');
95
+ }
96
+
97
+ /**
98
+ * Dynamically create the post list block
99
+ *
100
+ * @return Fishpig_Wordpress_Block_Post_List
101
+ */
102
+ protected function _createPostListBlock()
103
+ {
104
+ return $this->getLayout()
105
+ ->createBlock('wordpress/post_list', $this->_postListBlockName.microtime().rand(1, 999))
106
+ ->setTemplate($this->getPostListTemplate())
107
+ ->setWrapperBlock($this);
108
+ }
109
+
110
+ /**
111
+ * Enables auto pagination
112
+ */
113
+ public function enableAutoPagination()
114
+ {
115
+ $this->_autoPaginate = true;
116
+ }
117
+
118
+ /**
119
+ * Disables auto pagination
120
+ */
121
+ public function disableAutoPagination()
122
+ {
123
+ $this->_autoPaginate = false;
124
+ }
125
+
126
+ /**
127
+ * Returns true if auto pagination set
128
+ *
129
+ * @return bool
130
+ */
131
+ public function isAutoPaginationEnabled()
132
+ {
133
+ return $this->_autoPaginate;
134
+ }
135
+
136
+ /**
137
+ * Sets the name of the child block that contains the post list
138
+ *
139
+ * @param string $blockName
140
+ */
141
+ public function setPostListBlockName($blockName)
142
+ {
143
+ $this->_postListBlockName = $blockName;
144
+ return $this;
145
+ }
146
+
147
+ }
app/code/community/Fishpig/Wordpress/Block/Post/View.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_View extends Fishpig_Wordpress_Block_Post_View_Abstract
4
+ {
5
+ /**
6
+ * The block name for the comments block
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_commentsBlockName = 'wordpress_post_comments';
11
+
12
+ /**
13
+ * Returns the HTML for the comments block
14
+ *
15
+ * @return string
16
+ */
17
+ public function getCommentsHtml()
18
+ {
19
+ return $this->getCommentsBlock()->toHtml();
20
+ }
21
+
22
+ /**
23
+ * Gets the comments block
24
+ *
25
+ * @return Fishpig_Wordpress_Block_Post_View_Comments
26
+ */
27
+ public function getCommentsBlock()
28
+ {
29
+ if (!$this->hasData('post_comments')) {
30
+ if ($block = $this->getChild($this->_commentsBlockName)) {
31
+ $this->setData('post_comments', $block->setPost($this->getPost()));
32
+ }
33
+ else {
34
+ $this->setData('post_comments', $this->_createCommentsBlock());
35
+ }
36
+ }
37
+
38
+ return $this->getData('post_comments');
39
+ }
40
+
41
+ /**
42
+ * Dynamically create the comments block
43
+ *
44
+ * @return Fishpig_Wordpress_Block_Post_View_Comments
45
+ */
46
+ protected function _createCommentsBlock()
47
+ {
48
+ return $this->getLayout()
49
+ ->createBlock('wordpress/post_view_comments', microtime().rand(1, 9999))
50
+ ->setPost($this->getPost());
51
+ }
52
+ }
app/code/community/Fishpig/Wordpress/Block/Post/View/Abstract.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Block_Post_View_Abstract extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+ /**
6
+ * Returns the currently loaded post model
7
+ *
8
+ * @return Fishpig_Wordpress_Model_Post
9
+ */
10
+ public function getPost($d = false)
11
+ {
12
+ if (!$this->hasData('post')) {
13
+ if ($postId = $this->getData('post_id')) {
14
+ $post = Mage::getModel('wordpress/post')->load($postId);
15
+
16
+ if ($post->getId() == $postId) {
17
+ $this->setData('post', $post);
18
+ }
19
+ }
20
+ else {
21
+ $this->setData('post', Mage::registry('wordpress_post'));
22
+ }
23
+ }
24
+
25
+ return $this->getData('post');
26
+ }
27
+
28
+ /**
29
+ * Sets the current post object
30
+ *
31
+ * @param Fishpig_Wordpress_Model_Post $post
32
+ * @param bool $replaceIfExists
33
+ */
34
+ public function setPost(Fishpig_Wordpress_Model_Post $post, $replaceIfExists = true)
35
+ {
36
+ if (!$this->hasData('post') || $replaceIfExists) {
37
+ $this->setData('post', $post);
38
+ }
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Returns the ID of the currently loaded post
45
+ *
46
+ * @return int
47
+ */
48
+ public function getPostId()
49
+ {
50
+ if ($post = $this->getPost()) {
51
+ return $post->getId();
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Returns true if comments are enabled for this post
57
+ */
58
+ protected function canComment()
59
+ {
60
+ if ($post = $this->getPost()) {
61
+ return $post->getCommentStatus() == 'open';
62
+ }
63
+
64
+ return false;
65
+ }
66
+ }
app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_View_Comment_Form extends Fishpig_Wordpress_Block_Post_View_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setTemplate('wordpress/post/view/comment/form.phtml');
9
+ }
10
+
11
+ public function getCommentFormAction()
12
+ {
13
+ return $this->_helper()->getBaseUrl('wp-comments-post.php');
14
+ return $this->getUrl('wordpress/post_view_comment/post');
15
+ return $this->_helper()->getBaseUrl('wp-comments-post.php');
16
+ }
17
+
18
+ public function getCustomerName()
19
+ {
20
+ if ($customer = Mage::getSingleton('customer/session')->getCustomer()) {
21
+ return $customer->getName();
22
+ }
23
+ }
24
+
25
+ public function getCustomerEmail()
26
+ {
27
+ if ($customer = Mage::getSingleton('customer/session')->getCustomer()) {
28
+ return $customer->getEmail();
29
+ }
30
+ }
31
+
32
+ public function getRedirectTo()
33
+ {
34
+ return $this->hasData('redirect_to') ? $this->getData('redirect_to') : $this->getPost()->getPermalink();
35
+ }
36
+
37
+ public function getSuccessUrl()
38
+ {
39
+ if (!$this->hasData('success_url')) {
40
+ $permalink = $this->getPost()->getPermalink();
41
+
42
+ if (strpos($permalink, '?') === false) {
43
+ $permalink .= '?';
44
+ }
45
+ else {
46
+ $permalink = rtrim($permalink, '&') . '&';
47
+ }
48
+
49
+ $this->setSuccessUrl($permalink . 'cy='.rand(1111, 9999));
50
+ }
51
+
52
+ return $this->getData('success_url');
53
+ }
54
+
55
+ public function getErrorUrl()
56
+ {
57
+ if (!$this->hasData('error_url')) {
58
+ $permalink = $this->getPost()->getPermalink();
59
+
60
+ if (strpos($permalink, '?') === false) {
61
+ $permalink .= '?';
62
+ }
63
+ else {
64
+ $permalink = rtrim($permalink, '&') . '&';
65
+ }
66
+
67
+ $this->setErrorUrl($permalink . 'cx='.rand(1111, 9999));
68
+ }
69
+
70
+ return $this->getData('error_url');
71
+ }
72
+ }
app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Post_View_Comments extends Fishpig_Wordpress_Block_Post_View_Abstract
4
+ {
5
+ /**
6
+ * Cache for post comments
7
+ *
8
+ * @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
9
+ */
10
+ protected $_commentCollection = null;
11
+
12
+
13
+ /**
14
+ * Block name for the comments form block
15
+ *
16
+ * @var string
17
+ */
18
+ protected $_commentsFormBlockName = 'wordpress_post_comment_form';
19
+
20
+ public function __construct()
21
+ {
22
+ parent::__construct();
23
+ $this->setTemplate('wordpress/post/view/comments.phtml');
24
+ }
25
+
26
+ /**
27
+ * Returns a collection of comments for the current post
28
+ *
29
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
30
+ */
31
+ public function getComments()
32
+ {
33
+ if (is_null($this->_commentCollection)) {
34
+ if ($post = $this->getPost()) {
35
+ $this->_commentCollection = $post->getComments();
36
+ }
37
+ }
38
+
39
+ return $this->_commentCollection;
40
+ }
41
+
42
+ /**
43
+ * Returns the HTML for the comment form
44
+ *
45
+ * @return string
46
+ */
47
+ public function getCommentFormHtml()
48
+ {
49
+ return $this->getCommentFormBlock()->toHtml();
50
+ }
51
+
52
+ /**
53
+ * Gets a block for the comment form
54
+ *
55
+ * @return Fishpig_Wordpress_Block_Post_View_Comment_Form
56
+ */
57
+ public function getCommentFormBlock()
58
+ {
59
+ if (!$this->hasData('post_comment_form')) {
60
+ if ($block = $this->getChild($this->_commentsFormBlockName)) {
61
+ $this->setData('post_comment_form', $block->setPost($this));
62
+ }
63
+ else {
64
+ $this->setData('post_comment_form', $this->_createCommentsFormBlock());
65
+ }
66
+
67
+ return $this->getData('post_comment_form');
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Dynamically create the comments form block
73
+ *
74
+ * @return Fishpig_Wordpress_Block_Post_View_Comments_Form
75
+ */
76
+ protected function _createCommentsFormBlock()
77
+ {
78
+ return $this->getLayout()
79
+ ->createBlock('wordpress/post_view_comment_form', microtime().rand(1, 9999))
80
+ ->setPost($this->getPost());
81
+ }
82
+ }
app/code/community/Fishpig/Wordpress/Block/Tag/List.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Tag_List extends Fishpig_Wordpress_Block_Abstract
4
+ {
5
+
6
+ public function getTagCollection()
7
+ {
8
+ return Mage::getResourceModel('wordpress/post_tag_collection');
9
+
10
+
11
+ }
12
+
13
+
14
+
15
+ }
app/code/community/Fishpig/Wordpress/Block/Tag/View.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Block_Tag_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
4
+ {
5
+ /**
6
+ * Caches and returns the current category
7
+ *
8
+ * @return Fishpig_Wordpress_Model_Post_Categpry
9
+ */
10
+ public function getTag()
11
+ {
12
+ if (!$this->hasData('tag')) {
13
+ if ($categoryId = $this->getData('tag_id')) {
14
+ $category = Mage::getModel('wordpress/post_tag')->load($categoryId);
15
+
16
+ if ($category->getId() == $categoryId) {
17
+ $this->setData('tag', $category);
18
+ }
19
+ }
20
+ else {
21
+ $this->setData('tag', Mage::registry('wordpress_post_tag'));
22
+ }
23
+ }
24
+
25
+ return $this->getData('tag');
26
+ }
27
+
28
+ /**
29
+ * Returns the current tag's ID
30
+ *
31
+ * @return int
32
+ */
33
+ public function getTagId()
34
+ {
35
+ if ($tag = $this->getTag()) {
36
+ return $tag->getId();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Generates and returns the collection of posts
42
+ *
43
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
44
+ */
45
+ protected function _getPostCollection()
46
+ {
47
+ if (is_null($this->_postCollection)) {
48
+ $this->_postCollection = parent::_getPostCollection()
49
+ ->addTagIdFilter($this->getTagId());
50
+ }
51
+
52
+ return $this->_postCollection;
53
+ }
54
+
55
+ }
app/code/community/Fishpig/Wordpress/Controller/Abstract.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Controller_Abstract extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * Added for Magento 1.3 compatibility
7
+ *
8
+ * @var array
9
+ */
10
+ protected $_titles = array();
11
+
12
+ /**
13
+ * Loads layout and performs initialising tasls
14
+ *
15
+ */
16
+ protected function _init()
17
+ {
18
+ // $this->_checkRunnableStatus();
19
+ $this->_setNamesUtf8();
20
+
21
+ if ($this->_helper()->isLegacyMagento()) {
22
+ $this->loadLayout();
23
+ }
24
+ else {
25
+ if (!$this->_isLayoutLoaded) {
26
+ $this->loadLayout();
27
+ }
28
+ }
29
+
30
+ $this->_title()->_title($this->_helper()->getCachedWpOption('blogname'));
31
+
32
+ $this->_addCrumb('home', array('link' => Mage::getUrl(), 'label' => $this->__('Home')))
33
+ ->_addCrumb('blog', array('link' => $this->_helper()->getUrl(), 'label' => $this->_helper()->getPrettyBlogRoute()));
34
+
35
+ $this->_addRssFeed();
36
+
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Forces correct character encoding
42
+ *
43
+ */
44
+ protected function _setNamesUtf8()
45
+ {
46
+ if ($this->_helper()->isSeparateDatabase()) {
47
+ Mage::getSingleton('core/resource')->getConnection('core_read')->query('SET NAMES UTF8');
48
+ }
49
+ }
50
+
51
+ protected function _checkRunnableStatus()
52
+ {
53
+ if ($this->_helper()->isFullyIntegrated()) {
54
+ if (trim($this->_helper()->getUrl(), '/') == rtrim($this->_helper()->getCachedWpOption('home'), '/')) {
55
+ return true;
56
+ }
57
+ else {
58
+ throw new Exception($this->_helper()->__('The WordPress Site Address (URL) field does not match the blog route defined in the module configuration'));
59
+ }
60
+ }
61
+ else {
62
+ throw new Exception($this->_helper()->__('A controller has been dispatched that requires full-integration mode and semi-integrated is currently active'));
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Adds the Wordpress RSS feed into the Magento header
68
+ */
69
+ protected function _addRssFeed()
70
+ {
71
+ if ($headBlock = $this->_getBlock('head')) {
72
+ $headBlock->addItem('link_rel', $this->_helper()->getUrl('feed'), 'rel="alternate" type="application/rss+xml" title="' . $this->_helper()->getCachedWpOption('blogname'). ' - RSS Feed"');
73
+ }
74
+
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Adds a crumb to the breadcrumb trail
80
+ *
81
+ * @param string $crumbName
82
+ * @param array $crumbInfo
83
+ * @param string $after
84
+ */
85
+ protected function _addCrumb($crumbName, array $crumbInfo, $after = false)
86
+ {
87
+ if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
88
+ $breadcrumbs->addCrumb($crumbName, $crumbInfo, $after);
89
+ }
90
+
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Add a canonical link tag to the HTML head
96
+ *
97
+ * @param string $url
98
+ */
99
+ protected function _addCanonicalLink($url)
100
+ {
101
+ if ($headBlock = $this->_getBlock('head')) {
102
+ $headBlock->addItem('link_rel', $url, 'rel="canonical"');
103
+ }
104
+
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * Injects the JS and CSS needed to run the Syntax Highlighter
110
+ * Syntax Highlighter developed by Alex Gorbatchev (http://alexgorbatchev.com)
111
+ *
112
+ */
113
+ protected function _prepareSyntaxHighlighter()
114
+ {
115
+ if ($this->_helper('filter_shortcode_syntaxHighlighter')->isEnabled()) {
116
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
117
+ $theme = Mage::getStoreConfig('wordpress_blog/syntaxhighlighter/css_theme');
118
+
119
+ $headBlock->addJs('syntaxhighlighter/shCore.js');
120
+ $headBlock->addJs('syntaxhighlighter/shAutoloader.js');
121
+
122
+ foreach(array('shCore', 'shTheme') as $type) {
123
+ $headBlock->addCss('css' . DS . 'syntaxhighlighter' . DS . $type . $theme . '.css');
124
+ }
125
+
126
+ if ($beforeBodyEnd = $this->getLayout()->getBlock('before_body_end')) {
127
+ $triggerBlock = $this->getLayout()->createBlock('core/template', 'syntaxhighlighter.trigger', array('template' => 'wordpress/post/syntaxhighlighter/trigger.phtml'));
128
+
129
+ if ($triggerBlock) {
130
+ $beforeBodyEnd->insert($triggerBlock, '', false, 'syntaxhighlighter.trigger');
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Throws an exception indicating the page load failed
141
+ * This should cause a 404
142
+ *
143
+ * @param null|string $type
144
+ */
145
+ protected function throwInvalidObjectException($type = null)
146
+ {
147
+ throw new Exception($this->__('Unable to load a valid object ('.$type.')'));
148
+ }
149
+
150
+ /**
151
+ * Default index action
152
+ * Child controllers can use this simple action as
153
+ * most logic can be performed in _init()
154
+ */
155
+ public function indexAction()
156
+ {
157
+ try {
158
+ $this->_init();
159
+ $this->renderLayout();
160
+ }
161
+ catch (Exception $e) {
162
+ $this->_helper()->log($e->getMessage());
163
+ $this->_forward('noRoute');
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Generic functions
169
+ */
170
+ protected function _helper($helper = null)
171
+ {
172
+ if (is_null($helper) == false) {
173
+ $helper = '/' . $helper;
174
+ }
175
+
176
+ return Mage::helper('wordpress' . $helper);
177
+ }
178
+
179
+ /**
180
+ * Returns a layout block
181
+ *
182
+ * @param string $blockName
183
+ * @return Mage_Core_Block_Template
184
+ */
185
+ protected function _getBlock($blockName)
186
+ {
187
+ return $this->getLayout()->getBlock($blockName);
188
+ }
189
+
190
+ /**
191
+ * Dispatch a Magento event
192
+ *
193
+ * @param string $eventName
194
+ * @param array $params
195
+ */
196
+ protected function _event($eventName, array $params = array())
197
+ {
198
+ Mage::dispatchEvent($eventName, $params);
199
+ }
200
+
201
+ /**
202
+ * Wrapper for self::_title
203
+ * This wrapper was added for 1.3 backwards compatibility
204
+ *
205
+ * @string $text
206
+ * @bool $resetIfExists
207
+ */
208
+ protected function _title($text = null, $resetIfExists = true)
209
+ {
210
+ if ($this->_helper()->isLegacyMagento()) {
211
+ if ($text == null) {
212
+ $this->_titles = array();
213
+ $title = '';
214
+ }
215
+ else {
216
+ $this->_titles[] = $text;
217
+ $title = implode(' / ', array_reverse($this->_titles));
218
+ }
219
+
220
+ if ($head = $this->_getBlock('head')) {
221
+ $head->setTitle($title);
222
+ }
223
+
224
+ return $this;
225
+ }
226
+
227
+ return parent::_title($text, $resetIfExists);
228
+ }
229
+
230
+ public function register($key, $value)
231
+ {
232
+ Mage::register($key, $value);
233
+ return $this;
234
+ }
235
+
236
+ protected function _addCustomLayoutHandles(array $handles = array())
237
+ {
238
+ array_unshift($handles, array('default'));
239
+ $update = $this->getLayout()->getUpdate();
240
+
241
+ foreach($handles as $handle) {
242
+ $update->addHandle($handle);
243
+ }
244
+
245
+ $this->addActionLayoutHandles();
246
+ $this->loadLayoutUpdates();
247
+ $this->generateLayoutXml()->generateLayoutBlocks();
248
+ $this->_isLayoutLoaded = true;
249
+
250
+ return $this;
251
+ }
252
+
253
+ public function getSeoPlugin()
254
+ {
255
+ return $this->_helper('plugin_allInOneSeo');
256
+ }
257
+
258
+ }
app/code/community/Fishpig/Wordpress/Controller/Adminhtml/Abstract.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Controller_Adminhtml_Abstract extends Mage_Adminhtml_Controller_action
4
+ {
5
+ /**
6
+ * Gets the Adminhtml session
7
+ * @return Mage_Adminhtml_Model_Session
8
+ */
9
+ public function getSession()
10
+ {
11
+ return Mage::getSingleton('adminhtml/session');
12
+ }
13
+
14
+ /**
15
+ * Get a Wordpress helper class
16
+ *
17
+ * @param null|string $helper
18
+ * @return Fishpig_Wordpress_Helper_Abstract
19
+ */
20
+ protected function _helper($helper = null)
21
+ {
22
+ if ($helper != null) {
23
+ $helper = '/' . $helper;
24
+ }
25
+
26
+ return Mage::helper('wordpress' . $helper);
27
+ }
28
+ }
29
+
app/code/community/Fishpig/Wordpress/Controller/Router.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Controller_Router extends Mage_Core_Controller_Varien_Router_Standard
4
+ {
5
+ /**
6
+ * Stores the current page. By default, this is 1
7
+ *
8
+ * @var int
9
+ */
10
+ protected $_currentPage = 1;
11
+
12
+ /**
13
+ * Stores the static routes used by WordPress
14
+ *
15
+ * @var array
16
+ */
17
+ protected $_staticRoutes = array();
18
+
19
+ /**
20
+ * Stores the key used to define the current page in the URL
21
+ *
22
+ * @var string
23
+ */
24
+ protected $_pageRoute = 'page';
25
+
26
+ /**
27
+ * Used to provide classwide access to the request object
28
+ *
29
+ * @var null|Zend_Controller_Request_Http
30
+ */
31
+ protected $_requestObject = null;
32
+
33
+ /**
34
+ * Create an instance of the router and add it to the queue
35
+ */
36
+ public function initController($observer)
37
+ {
38
+ $front = $observer->getEvent()->getFront();
39
+
40
+ $wp = new Fishpig_Wordpress_Controller_Router();
41
+ $front->addRouter('fishpig_wordpress', $wp);
42
+ }
43
+
44
+ /**
45
+ * Attempt to match the current URI to this module
46
+ * If match found, set module, controller, action and dispatch
47
+ *
48
+ * @param Zend_Controller_Request_Http $request
49
+ * @return bool
50
+ */
51
+ public function match(Zend_Controller_Request_Http $request)
52
+ {
53
+ try {
54
+ if ($this->_helper()->isFullyIntegrated()) {
55
+ $this->_requestObject = $request;
56
+ if ($this->_match($this->_getExplodedUri())) {
57
+ return $this->forceDispatch();
58
+ }
59
+ }
60
+ }
61
+ catch (Exception $e) { }
62
+
63
+ return false;
64
+ }
65
+
66
+ /**
67
+ * Performs the logic for self::match
68
+ *
69
+ * @param array $explodedUri
70
+ * @return bool
71
+ */
72
+ protected function _match(array $explodedUri)
73
+ {
74
+ $this->_initStaticRoutes();
75
+
76
+ if ($this->_isWordpressStaticRoute($explodedUri)) {
77
+ return $this->_autosetRequest($explodedUri);
78
+ }
79
+ else if ($post = $this->_getCurrentPost($explodedUri)) {
80
+ return $this->getRequest()->setControllerName('post_view')
81
+ ->setActionName('index');
82
+ }
83
+ else if ($this->_isArchiveRoute($explodedUri)) {
84
+ return $this->_setArchiveRoute($explodedUri);
85
+ }
86
+ return false;
87
+ }
88
+
89
+ protected function forceDispatch()
90
+ {
91
+ $this->getRequest()
92
+ ->setModuleName('wordpress')
93
+ ->setRouteName('wordpress');
94
+
95
+ if ($controllerClassName = $this->_validateControllerClassName('Fishpig_Wordpress', $this->getRequest()->getControllerName())) {
96
+ $controllerInstance = new $controllerClassName($this->getRequest(), $this->getFront()->getResponse());
97
+
98
+ if ($controllerInstance->hasAction($this->getRequest()->getActionName())) {
99
+ $this->getRequest()->setDispatched(true);
100
+ $controllerInstance->dispatch($this->getRequest()->getActionName());
101
+ return true;
102
+ }
103
+ }
104
+
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * Returns an array of the URI
110
+ *
111
+ * @return array
112
+ */
113
+ protected function _getExplodedUri()
114
+ {
115
+ $parts = explode('/', trim($this->getRequest()->getPathInfo(), '/'));
116
+
117
+ if (array_shift($parts) != $this->_helper()->getBlogRoute()) {
118
+ throw new Exception('The current route doesn\'t match the blog route set in the Magento admin');
119
+ }
120
+
121
+ return $parts;
122
+ }
123
+
124
+ /**
125
+ * Returns true if the array $explodedUri looks like it is made for a Wordpress page
126
+ *
127
+ * @param array $explodedUri
128
+ * @return bool
129
+ */
130
+ protected function _isWordpressStaticRoute(array $explodedUri)
131
+ {
132
+ if ($uriToken = array_shift($explodedUri)) {
133
+ return $this->_getRouteByAlias($uriToken) || $uriToken == $this->_pageRoute;
134
+ }
135
+
136
+ return !$this->getPostId();
137
+ }
138
+
139
+ /**
140
+ * Returns true if the array $explodedUri looks like it is made for a WordPress archive page
141
+ *
142
+ * @param array $explodedUri
143
+ * @return bool
144
+ */
145
+ protected function _isArchiveRoute($explodedUri)
146
+ {
147
+ if (count($explodedUri) >= 2) {
148
+ if ($this->_helper('object')->_match("/^[0-9]{4}$/", $explodedUri[0])
149
+ && $this->_helper('object')->_match("/^[0-9]{2}$/", $explodedUri[1])
150
+ && (!isset($explodedUri[2]) || (isset($explodedUri[2]) && $explodedUri[2] == 'page'))) {
151
+
152
+ if (isset($explodedUri[2])) {
153
+ $this->_setPartsAsParams(array_slice($explodedUri, 2));
154
+ }
155
+
156
+ return true;
157
+ }
158
+ }
159
+
160
+ return false;
161
+ }
162
+
163
+ protected function _setArchiveRoute($explodedUri)
164
+ {
165
+ return $this->getRequest()
166
+ ->setParam('archive', $explodedUri[0].'/'.$explodedUri[1])
167
+ ->setControllerName('archive_view')
168
+ ->setActionName('index');
169
+ }
170
+
171
+ /**
172
+ * Automatically set the module, controller and action based on the URI parts
173
+ *
174
+ * @param array $explodedUri
175
+ */
176
+ protected function _autosetRequest(array $explodedUri)
177
+ {
178
+ if (!isset($explodedUri[0]) || $explodedUri[0] == $this->_pageRoute) {
179
+ $controller = 'homepage';
180
+ $action = 'index';
181
+ }
182
+ else {
183
+ list($controller, $action) = $this->_getRouteByAlias($explodedUri[0]);
184
+ }
185
+
186
+ $this->getRequest()->setControllerName($controller)
187
+ ->setActionName($action);
188
+
189
+ return $this->_setPartsAsParams($explodedUri);
190
+ }
191
+
192
+ /**
193
+ * Cycles through parts setting every two key values as key => value
194
+ *
195
+ * @param array $explodedUri
196
+ */
197
+ protected function _setPartsAsParams(array $explodedUri)
198
+ {
199
+ $count = count($explodedUri);
200
+
201
+ if ($count > 0) {
202
+ for($it = 0; $it < $count; $it++) {
203
+ if (isset($explodedUri[($it+1)])) {
204
+ if ($route = $this->_getRouteByAlias($explodedUri[$it])) {
205
+ list($controller, $action) = $route;
206
+ $explodedUri[$it] = $controller;
207
+ }
208
+
209
+ $this->getRequest()->setParam($explodedUri[$it], $explodedUri[(++$it)]);
210
+ }
211
+ }
212
+ }
213
+
214
+ return $this;
215
+ }
216
+
217
+ /**
218
+ * Get a WordPress post based on the exploded URI
219
+ *
220
+ * @param array $explodedUri
221
+ * @return null|Fishpig_Wordpress_Model_Post
222
+ */
223
+ protected function _getCurrentPost(array $explodedUri)
224
+ {
225
+ $post = $this->_helper('post')->loadByPermalink($explodedUri);
226
+
227
+ if ($post instanceof Fishpig_Wordpress_Model_Post) {
228
+ if ($post->getId()) {
229
+ Mage::register('wordpress_post', $post);
230
+ return $post;
231
+ }
232
+ }
233
+ else {
234
+ // Preview a post
235
+ if ($postId = $this->getRequest()->getParam('p')) {
236
+ $post = Mage::getModel('wordpress/post')->load($postId);
237
+
238
+ if ($post->getId()) {
239
+ if ($this->getRequest()->getParam('preview') == 'true') {
240
+ Mage::register('wordpress_post', $post);
241
+ return $post;
242
+ }
243
+ else {
244
+ header("HTTP/1.1 301 Moved Permanently");
245
+ header("Location: " . $post->getPermalink());
246
+ exit;
247
+ }
248
+ }
249
+ }
250
+ }
251
+
252
+ return false;
253
+ }
254
+
255
+ /**
256
+ * STATIC ROUTES
257
+ * The following functions deal with static WordPress routes
258
+ */
259
+ /**
260
+ * Initliase the static routes used by WordPress
261
+ */
262
+ protected function _initStaticRoutes()
263
+ {
264
+ $this->addStaticRoute('category', $this->_helper()->getCachedWpOption('category_base', 'category'))
265
+ ->addStaticRoute('author', 'author')
266
+ ->addStaticRoute($this->_helper()->getCachedWpOption('tag_base', 'tag'), 'tag')
267
+ ->addStaticRoute('post_view_comment', 'post_view_comment')
268
+ ->addStaticRoute('feed', 'feed')
269
+ ->addStaticRoute('sitemap.xml', 'sitemap')
270
+ ->addStaticRoute('tags', 'tag', 'list')
271
+ ->addStaticRoute('wp-admin', 'redirect', 'wpAdmin');
272
+
273
+ Mage::app()->dispatchEvent('wordpress_init_static_routes_after', array('router' => $this));
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Register a static route
280
+ *
281
+ * @param string $route - internal token used by the controller
282
+ * @param string $alias - route used in the URL
283
+ */
284
+ public function addStaticRoute($alias, $controller, $action = 'index')
285
+ {
286
+ $this->_staticRoutes[trim($alias, '/')] = array($controller, $action);
287
+ return $this;
288
+ }
289
+
290
+ /**
291
+ * Returns the route for the given alias
292
+ *
293
+ * @param string $alias
294
+ * @return string
295
+ */
296
+ protected function _getRouteByAlias($alias)
297
+ {
298
+ if (isset($this->_staticRoutes[$alias])) {
299
+ return $this->_staticRoutes[$alias];
300
+ }
301
+
302
+ return false;
303
+
304
+ if ($key = array_search($alias, $this->_staticRoutes)) {
305
+ return $key;
306
+ }
307
+
308
+ return false;
309
+ }
310
+
311
+ /**
312
+ * Gets the post ID from the current URL
313
+ *
314
+ * @return int|null
315
+ */
316
+ protected function getPostId()
317
+ {
318
+ return $this->getRequest()->getParam('p');
319
+ }
320
+
321
+ /**
322
+ * Returns the current request object
323
+ *
324
+ * @return Zend_Controller_Request_Http
325
+ */
326
+ protected function getRequest()
327
+ {
328
+ return $this->_requestObject;
329
+ }
330
+
331
+ /**
332
+ * Gets a module helper
333
+ * If $helper not specified, the Data.php helper is returned
334
+ *
335
+ * @param null|string
336
+ * @return Fishpig_Wordpress_Helper_Abstract|Varien_Object
337
+ */
338
+ protected function _helper($helper = null)
339
+ {
340
+ if ($helper != null) {
341
+ $helper = '/' . $helper;
342
+ }
343
+
344
+ return Mage::helper('wordpress' . $helper);
345
+ }
346
+
347
+ }
app/code/community/Fishpig/Wordpress/Docs/Example-XML-Blocks.xml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+
5
+ <!---
6
+ - Displays a simple WordPress post list in Magento
7
+ - Allows you to set a custom list title and post limit
8
+ -
9
+ - Static Block equivalent:
10
+ -
11
+ - {{block type="wordpress/post_list_recent" template="wordpress/post/recent.phtml" title="Recent Posts" post_count="3"}}
12
+ -
13
+ -->
14
+ <reference name="left">
15
+ <block type="wordpress/post_list_recent" name="wp.recent-posts" template="wordpress/post/recent.phtml">
16
+ <action method="setTitle"><title>Recent Posts</title></action>
17
+ <action method="setPostCount"><post_count>3</post_count></action>
18
+ </block>
19
+ </reference>
20
+
21
+ <!---
22
+ - Filter your WordPress post list by a WordPress category ID
23
+ -
24
+ - Static Block equivalent:
25
+ -
26
+ - {{block type="wordpress/post_list_recent" template="wordpress/post/recent.phtml" title="Recent Posts" post_count="3" category_id="1"}}
27
+ -
28
+ -->
29
+ <reference name="left">
30
+ <block type="wordpress/post_list_recent" name="wp.recent-posts" template="wordpress/post/recent.phtml">
31
+ <action method="setTitle"><title>Recent Posts</title></action>
32
+ <action method="setPostCount"><post_count>3</post_count></action>
33
+ <action method="setCategoryId"><category_id>1</category_id></action>
34
+ </block>
35
+ </reference>
36
+
37
+ <!---
38
+ - Filter your WordPress post list by a WordPress user ID
39
+ -
40
+ - Static Block equivalent:
41
+ -
42
+ - {{block type="wordpress/post_list_recent" template="wordpress/post/recent.phtml" title="Recent Posts" post_count="3" author_id="1"}}
43
+ -
44
+ -->
45
+ <reference name="left">
46
+ <block type="wordpress/post_list_recent" name="wp.recent-posts" template="wordpress/post/recent.phtml">
47
+ <action method="setTitle"><title>Recent Posts</title></action>
48
+ <action method="setPostCount"><post_count>3</post_count></action>
49
+ <action method="setAuthorId"><author_id>1</author_id></action>
50
+ </block>
51
+ </reference>
52
+
53
+ <!---
54
+ - Displays a simple WordPress post list in Magento
55
+ - Allows you to set a custom list title and post limit
56
+ - Also sets a custom post list template. This allows you to customise the actual post list
57
+ -
58
+ - Static Block equivalent:
59
+ -
60
+ - {{block type="wordpress/post_list_recent" template="wordpress/post/recent.phtml" title="Recent Posts" post_count="3" post_list_template="wordpress/post/recent/list.phtml"}}
61
+ -
62
+ -->
63
+ <reference name="left">
64
+ <block type="wordpress/post_list_recent" name="wp.recent-posts" template="wordpress/post/recent.phtml">
65
+ <action method="setTitle"><title>Recent Posts</title></action>
66
+ <action method="setPostCount"><post_count>3</post_count></action>
67
+ <action method="setPostListTemplate"><post_list_template>wordpress/post/recent/list.phtml</post_list_template></action>
68
+ </block>
69
+ </reference>
70
+
71
+ <!---
72
+ - Display a single WordPress using the 'featured post' template
73
+ - The featured template only displays basic post information
74
+ - To display more information about the post, use the full post view template (wordpress/post/template.phtml)
75
+ -
76
+ - Static Block Equivalent
77
+ - {{block type="wordpress/post_view" template="wordpress/post/featured.phtml" post_id="1"}}
78
+ -
79
+ -->
80
+ <reference name="content">
81
+ <block type="wordpress/post_view" name="wp.featured-post" template="wordpress/post/featured.phtml">
82
+ <action method="setPostId"><post_id>1</post_id></action>
83
+ </block>
84
+ </reference>
85
+
86
+ <!---
87
+ - Display a single WordPress using the 'standard post' template
88
+ - This template will display all of the information about a post that would be displayed in WordPress
89
+ -
90
+ - Static Block Equivalent
91
+ - {{block type="wordpress/post_view" template="wordpress/post/view.phtml" post_id="1"}}
92
+ -
93
+ -->
94
+ <reference name="content">
95
+ <block type="wordpress/post_view" name="wp.featured-post" template="wordpress/post/view.phtml">
96
+ <action method="setPostId"><post_id>1</post_id></action>
97
+ </block>
98
+ </reference>
99
+
100
+ <!---
101
+ - Display posts associated with the current product on the product page
102
+ - This XML will work if you include the following line of PHP in your catalog/product/view.phtml
103
+ - <?php echo $this->getChildHtml('additional')
104
+ - If you do not include this block, move the block below into an appropriate reference
105
+ -
106
+ - Static Block Equivalent:
107
+ - {{block type="wordpress/post_list_associated" template="wordpress/post/associated.phtml" title="Related Blog Posts"}}
108
+ -
109
+ -->
110
+ <catalog_product_view>
111
+ <reference name="product.info.additional">
112
+ <block type="wordpress/post_list_associated" name="associated.posts" template="wordpress/post/associated.phtml">
113
+ <action method="setTitle"><title>Related blog posts</title></action>
114
+ </block>
115
+ </reference>
116
+ </catalog_product_view>
117
+
118
+
119
+ <!---
120
+ - Display posts associated with the current product on the product page
121
+ - This will display the posts in the left hand navigaiton. Change the reference from left to right if you are using 2columns-right.phtml
122
+ -
123
+ - Static Block Equivalent:
124
+ - {{block type="wordpress/post_list_associated" template="wordpress/post/associated.phtml" title="Related Blog Posts"}}
125
+ -
126
+ -->
127
+ <catalog_product_view>
128
+ <reference name="left">
129
+ <block type="wordpress/post_list_associated" name="associated.posts" template="wordpress/post/associated.phtml">
130
+ <action method="setTitle"><title>Related blog posts</title></action>
131
+ </block>
132
+ </reference>
133
+ </catalog_product_view>
134
+
135
+ <!---
136
+ - Display posts associated with the current product on the product page
137
+ - This will display the posts in the left hand navigaiton. Change the reference from left to right if you are using 2columns-right.phtml
138
+ -
139
+ - Static Block Equivalent:
140
+ - {{block type="wordpress/post_list_associated" template="wordpress/post/associated.phtml" title="Related Blog Posts"}}
141
+ -
142
+ -->
143
+ <reference name="content">
144
+ <block type="wordpress/post_list_associated" name="associated.posts" template="wordpress/post/associated.phtml">
145
+ <action method="setTitle"><title>Related blog posts</title></action>
146
+ <action method="setProductId"><product_id>1</product_id></action>
147
+ </block>
148
+ </reference>
149
+
150
+ <!---
151
+ - Display posts associated with the current product on the product page
152
+ - This will display the posts in the left hand navigaiton. Change the reference from left to right if you are using 2columns-right.phtml
153
+ - You can change the default post list template using the 'setPostListTemplate' action
154
+ -
155
+ - Static Block Equivalent:
156
+ - {{block type="wordpress/post_list_associated" template="wordpress/post/associated.phtml" title="Related Blog Posts" post_list_template="wordpress/post/associated/list.phtml"}}
157
+ -
158
+ -->
159
+ <reference name="content">
160
+ <block type="wordpress/post_list_associated" name="associated.posts" template="wordpress/post/associated.phtml">
161
+ <action method="setTitle"><title>Related blog posts</title></action>
162
+ <action method="setProductId"><product_id>1</product_id></action>
163
+ <action method="setPostListTemplate"><post_list_template>wordpress/post/associated/list.phtml</post_list_template></action>
164
+ </block>
165
+ </reference>
166
+
167
+ <!---
168
+ - Displays a list of categories
169
+ -
170
+ - Static block equivalent:
171
+ - {{type="wordpress/category_list" template="wordpress/category/list.phtml" title="Categories"}}
172
+ -
173
+ -->
174
+ <reference name="left">
175
+ <block type="wordpress/category_list" name="wp.category-list" template="wordpress/category/list.phtml" before="-">
176
+ <action method="setTitle"><title>Categories</title></action>
177
+ </block>
178
+ </reference>
179
+
180
+ <!---
181
+ - Displays a list of sub-categories
182
+ -
183
+ - Static block equivalent:
184
+ - {{type="wordpress/category_list" template="wordpress/category/list.phtml" parent_id="3" title="Sub-Categories"}}
185
+ -
186
+ -->
187
+ <reference name="left">
188
+ <block type="wordpress/category_list" name="wp.category-list" template="wordpress/category/list.phtml" before="-">
189
+ <action method="setTitle"><title>Sub-Categories</title></action>
190
+ <action method="setParentId"><parent_id>3</parent_id></action>
191
+ </block>
192
+ </reference>
193
+
194
+ <!--
195
+ - Displays a list of archive links
196
+ -
197
+ -
198
+ -->
199
+ <reference name="left">
200
+ <block type="wordpress/archive_list" name="wordpress_archive_list" template="wordpress/archive/list.phtml">
201
+ <action method="setTitle"><title>Archives</title></action>
202
+ </block>
203
+ </reference>
204
+
205
+ </layout>
app/code/community/Fishpig/Wordpress/Docs/readme.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ http://fishpig.co.uk/wordpress-magento-integration/
4
+
5
+ Be sure to copy over the following files to your theme:
6
+ app/design/frontend/base/default/layout/wordpress.xml
7
+ app/design/frontend/base/default/template/wordpress/
8
+
9
+
10
+ Please contact us if any of the following are true:
11
+
12
+ - you have a question about this module
13
+ - you have found a bug in this module
14
+ - you have improvements for this module
15
+ - you really like this module
16
+ - you need help with this module
17
+
18
+
19
+ Free support: wpmage@fishpig.co.uk
20
+
21
+ :)
22
+
23
+
24
+
app/code/community/Fishpig/Wordpress/Helper/Abstract.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Abstract extends Mage_Core_Helper_Abstract
4
+ {
5
+ protected $_cache = array();
6
+
7
+ /**
8
+ * Returns the URL used to access your Wordpress frontend
9
+ *
10
+ */
11
+ public function getUrl($extra = null, $params = array())
12
+ {
13
+ if ($this->isFullyIntegrated()) {
14
+ if (Mage::getStoreConfigFlag('web/seo/use_rewrites')) {
15
+ $url = Mage::getBaseUrl('web', false) . $this->getBlogRoute();
16
+ }
17
+ else {
18
+ $url = Mage::getBaseUrl('link', false) . $this->getBlogRoute();
19
+ }
20
+ }
21
+ else {
22
+ $url = $this->getCachedWpOption('home');
23
+ }
24
+
25
+ $url = $url . '/' . $extra;
26
+
27
+ if (count($params) > 0) {
28
+ $url = rtrim($url, '/') . '/';
29
+
30
+ foreach($params as $field => $value) {
31
+ $url .= "{$field}/{$value}/";
32
+ }
33
+ }
34
+
35
+ return htmlspecialchars($url);
36
+ }
37
+
38
+ public function getHomeUrl()
39
+ {
40
+ return $this->getCachedWpOption('home');
41
+ }
42
+
43
+ /**
44
+ * Returns the URL Wordpress is installed on
45
+ *
46
+ */
47
+ public function getBaseUrl($extra = '')
48
+ {
49
+ return rtrim($this->getCachedWpOption('siteurl'), '/') . '/' . $extra;
50
+ }
51
+
52
+ /**
53
+ * Get Wordpress Admin URL
54
+ *
55
+ */
56
+ public function getAdminUrl($extra = null)
57
+ {
58
+ return $this->getBaseUrl('wp-admin/' . $extra);
59
+ }
60
+
61
+ /**
62
+ * Returns the blog route selected in the Magento config
63
+ *
64
+ * Returns null if full integration is disbaled
65
+ *
66
+ */
67
+ public function getBlogRoute()
68
+ {
69
+ if ($this->isFullyIntegrated()) {
70
+ return Mage::getStoreConfig('wordpress/integration/route');
71
+ }
72
+
73
+ return null;
74
+ }
75
+
76
+ /**
77
+ * Returns the pretty version of the blog route
78
+ *
79
+ * @return string
80
+ */
81
+ public function getPrettyBlogRoute()
82
+ {
83
+ if ($route = $this->getBlogRoute()) {
84
+ $route = str_replace('-', ' ', $route);
85
+ return ucwords($route);
86
+ }
87
+
88
+ return null;
89
+ }
90
+
91
+ /**
92
+ * Returns true if Magento/Wordpress are installed in different DB
93
+ * This can be configured in the Magento admin
94
+ *
95
+ * @return bool
96
+ */
97
+ public function isSeparateDatabase()
98
+ {
99
+ return Mage::getStoreConfigFlag('wordpress/database/is_different_db');
100
+ }
101
+
102
+ /**
103
+ * Returns true if Magento/Wordpress are installed in the same DB
104
+ * This can be configured in the Magento admin
105
+ *
106
+ * @return bool
107
+ */
108
+ public function isSameDatabase()
109
+ {
110
+ return !$this->isSeparateDatabase();
111
+ }
112
+
113
+ /**
114
+ * Returns true if full integration is enabled
115
+ *
116
+ */
117
+ public function isFullyIntegrated()
118
+ {
119
+ return Mage::getStoreConfigFlag('wordpress/integration/full');
120
+ }
121
+
122
+ /**
123
+ * Returns true if semi-integration is enabled
124
+ * Function will always return the opposite of isFullyIntegrated()
125
+ *
126
+ */
127
+ public function isSemiIntegrated()
128
+ {
129
+ return !$this->isFullyIntegrated();
130
+ }
131
+
132
+ /**
133
+ * Gets a Wordpress option based on it's name
134
+ *
135
+ * If the value isn't found in the cache, it is fetched and added
136
+ *
137
+ */
138
+ public function getCachedWpOption($optionName, $default = null)
139
+ {
140
+ if (!isset($this->_cache['option'][$optionName])) {
141
+ $this->_cache['option'][$optionName] = $this->getWpOption($optionName, $default);
142
+ }
143
+
144
+ return $this->_cache['option'][$optionName];
145
+ }
146
+
147
+ /**
148
+ * Gets a Wordpress option based on it's name
149
+ *
150
+ */
151
+ public function getWpOption($optionName, $default = null)
152
+ {
153
+ $option = Mage::getModel('wordpress/option')->load($optionName, 'option_name');
154
+
155
+ if ($option->getOptionValue()) {
156
+ return $option->getOptionValue();
157
+ }
158
+
159
+ return $default;
160
+ }
161
+
162
+ /**
163
+ * Wrapper for getWpOption()
164
+ *
165
+ */
166
+ public function getOption($optionName, $default = null)
167
+ {
168
+ return $this->getWpOption($optionName, $default);
169
+ }
170
+
171
+ /**
172
+ * Formats a Wordpress date string
173
+ *
174
+ */
175
+ public function formatDate($date, $format = null, $f = false)
176
+ {
177
+ if ($format == null) {
178
+ $format = $this->getDefaultDateFormat();
179
+ }
180
+
181
+
182
+ $length = strlen($format);
183
+ $buffer = '';
184
+
185
+ for($i = 0; $i < $length; $i++) {
186
+ $buffer .= $this->__(date($format[$i], mktime(substr($date, 11, 2), substr($date, 14, 2), substr($date, 17, 2), substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4))));;
187
+ }
188
+
189
+
190
+ return $buffer;
191
+ }
192
+
193
+ /**
194
+ * Formats a Wordpress date string
195
+ *
196
+ */
197
+ public function formatTime($time, $format = null)
198
+ {
199
+ if ($format == null) {
200
+ $format = $this->getDefaultTimeFormat();
201
+ }
202
+
203
+ return $this->formatDate($time, $format);
204
+ }
205
+
206
+ /**
207
+ * Return the default date formatting
208
+ *
209
+ */
210
+ public function getDefaultDateFormat()
211
+ {
212
+ return $this->getCachedWpOption('date_format', 'F jS, Y');
213
+ }
214
+
215
+ /**
216
+ * Return the default time formatting
217
+ *
218
+ */
219
+ public function getDefaultTimeFormat()
220
+ {
221
+ return $this->getCachedWpOption('time_format', 'g:ia');
222
+ }
223
+
224
+ /**
225
+ * Logs an error to the Wordpress error log
226
+ *
227
+ */
228
+ public function log($message, $level = null, $file = 'wordpress.log')
229
+ {
230
+ if ($this->isLoggingEnabled()) {
231
+ if ($message = trim($message)) {
232
+ return Mage::log($message, $level, $file);
233
+ }
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Returns true if logging is enabled
239
+ *
240
+ */
241
+ public function isLoggingEnabled()
242
+ {
243
+ if (!isset($this->_cache['logging_enabled'])) {
244
+ $this->_cache['logging_enabled'] = Mage::getStoreConfigFlag('wordpress/debug/log_enabled');
245
+ }
246
+
247
+ return $this->_cache['logging_enabled'];
248
+ }
249
+
250
+ /**
251
+ * Returns the relevant Wordpress helper.
252
+ *
253
+ * If no parameter passed, returns the default (Data.php) helper
254
+ *
255
+ */
256
+ public function _helper($helper = null)
257
+ {
258
+ return Mage::helper('wordpress' . (($helper != null) ? "/{$helper}" : null));
259
+ }
260
+
261
+ /**
262
+ * Returns true if the current Magento version is below 1.4
263
+ *
264
+ * @return bool
265
+ */
266
+ public function isLegacyMagento()
267
+ {
268
+ return Mage::getVersion() < 1.4;
269
+ }
270
+
271
+ /**
272
+ * Shortcut to get Param
273
+ *
274
+ * @param string $field
275
+ * @param null|mixed $default
276
+ * @return mixed
277
+ */
278
+ public function getParam($field, $default = null)
279
+ {
280
+ return Mage::app()->getRequest()->getParam($field, $default);
281
+ }
282
+
283
+ }
app/code/community/Fishpig/Wordpress/Helper/Adminhtml.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Adminhtml extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+
6
+ public function redirectToWordpressConfig()
7
+ {
8
+ $this->_redirect($this->getWordpressConfigPath());
9
+ return;
10
+ }
11
+
12
+ public function getWordpressConfigPath()
13
+ {
14
+ return 'adminhtml/system_config/edit/section/wordpress';
15
+ }
16
+
17
+ public function addError($msg)
18
+ {
19
+ return Mage::getSingleton('adminhtml/session')->addError($msg);
20
+ }
21
+
22
+ public function addNotice($msg)
23
+ {
24
+ return Mage::getSingleton('adminhtml/session')->addNotice($msg);
25
+ }
26
+
27
+
28
+ public function getAutoLogin()
29
+ {
30
+ return Mage::getModel('wordpress/admin_user')->load(0, 'store_id');
31
+ }
32
+ }
app/code/community/Fishpig/Wordpress/Helper/Catalog/Product.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Catalog_Product extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /**
6
+ * Returns a collection of Wordpress posts that have been
7
+ * associated with the given product
8
+ *
9
+ * @param Mage_Catalog_Model_Product $product
10
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
11
+ */
12
+ public function getAssociatedPosts(Mage_Catalog_Model_Product $product)
13
+ {
14
+ $postIds = $this->getAssociatedPostIds($product);
15
+ $categoryIds = $this->getAssociatedCategoryIds($product);
16
+ $collection = Mage::getResourceModel('wordpress/post_collection')
17
+ ->addIsPublishedFilter();
18
+
19
+ if (count($postIds) > 0 || count($categoryIds) > 0) {
20
+ $collection->addCategoryAndPostIdFilter($postIds, $categoryIds);
21
+ }
22
+ else {
23
+ $collection->forceNoResults();
24
+ }
25
+
26
+ return $collection;
27
+ }
28
+
29
+ public function getAssociatedPostIds(Mage_Catalog_Model_Product $product)
30
+ {
31
+ return $this->_getAssociatedWpEntityIds($product->getId(), 'post', 'post');
32
+ }
33
+
34
+ public function getAssociatedCategoryIds(Mage_Catalog_Model_Product $product)
35
+ {
36
+ return $this->_getAssociatedWpEntityIds($product->getId(), 'category', 'category');
37
+ }
38
+
39
+ protected function _getAssociatedWpEntityIds($id, $field, $table, $fieldToMatch = 'product_id')
40
+ {
41
+ $entityIds = array();
42
+ $results = $this->_helper('db')
43
+ ->getMagentoRead()
44
+ ->fetchAll("SELECT DISTINCT {$field}_id FROM " . $this->_helper('db')->getMagentoTableName('wordpress_product_'.$table) . " WHERE {$fieldToMatch} = {$id}");
45
+
46
+ foreach($results as $result) {
47
+ $entityIds[] = $result[$field.'_id'];
48
+ }
49
+
50
+ return $entityIds;
51
+ }
52
+
53
+ public function getAssociatedProducts(Fishpig_Wordpress_Model_Post $post)
54
+ {
55
+ $productIds = $this->_getAssociatedWpEntityIds($post->getId(), 'product', 'post', 'post_id');
56
+
57
+ $collection = Mage::getResourceModel('catalog/product_collection')
58
+ ->addAttributeToFilter('entity_id', array('in' => $productIds));
59
+
60
+ if (count($productIds) == 0) {
61
+ $collection->getSelect()->where('1=2');
62
+ }
63
+
64
+ return $collection;
65
+ }
66
+
67
+ }
app/code/community/Fishpig/Wordpress/Helper/Curl.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Curl extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /**
6
+ * Send a HTTP Post request
7
+ *
8
+ * @param string $postUrl
9
+ * @param array $postData
10
+ * @param array $params = array()
11
+ * @param bool $throwException
12
+ * @return Varien_Object
13
+ */
14
+ public function post($postUrl, array $postData, array $params = array(), $throwException = false)
15
+ {
16
+ try {
17
+ return $this->_post($postUrl, $postData, $params);
18
+ }
19
+ catch (Exception $e) {
20
+ $this->log($e->getMessage());
21
+
22
+ if ($throwException) {
23
+ throw new Exception($e->getMessage());
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Send a HTTP Post request
30
+ *
31
+ * @param string $url
32
+ * @param array $postData
33
+ * @param array $params = array()
34
+ * @return Varien_Object
35
+ */
36
+ protected function _post($postUrl, array $postData, array $params = array())
37
+ {
38
+ $postString = '';
39
+ $params = new Varien_Object($params);
40
+
41
+ foreach($postData as $field => $value) {
42
+ $postString .= urlencode($field) .'='.urlencode($value).'&';
43
+ }
44
+
45
+ $postString = rtrim($postString, '&=?');
46
+
47
+ $ch = curl_init();
48
+ curl_setopt($ch,CURLOPT_URL, $postUrl);
49
+ curl_setopt($ch,CURLOPT_POST, count($postData));
50
+ curl_setopt($ch,CURLOPT_POSTFIELDS, $postString);
51
+
52
+ if ($params->getHeader()) {
53
+ curl_setopt($ch, CURLOPT_HEADER, 1);
54
+ }
55
+
56
+ if ($params->getFollowLocation()) {
57
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
58
+ }
59
+
60
+ if ($params->getReturnTransfer()) {
61
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
62
+ }
63
+
64
+ $result = curl_exec($ch);
65
+
66
+ if (curl_errno($ch)) {
67
+ throw new Exception('Curl error: ' . curl_error($ch));
68
+ }
69
+
70
+ $ch = curl_close($ch);
71
+
72
+ return new Varien_Object(array('channel' => $ch, 'result' => $result));
73
+ }
74
+
75
+ }
app/code/community/Fishpig/Wordpress/Helper/Data.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Data extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /**
6
+ * Returns the given string prefixed with the Wordpress table prefix
7
+ *
8
+ * @return string
9
+ */
10
+ public function getTableName($table)
11
+ {
12
+ return $this->_helper('db')->getTableName($table);
13
+ }
14
+
15
+ /**
16
+ * Converts the param to an exploded URI
17
+ * Blog route has been removed
18
+ *
19
+ * @param string|array $uri
20
+ * @return array
21
+ */
22
+ public function explodeUri($uri)
23
+ {
24
+ if (!is_array($uri)) {
25
+ $uri = explode('/', trim($uri, '/'));
26
+ }
27
+
28
+ if (isset($uri[0])) {
29
+ if ($uri[0] == $this->getBlogRoute()) {
30
+ array_shift($uri);
31
+ }
32
+ }
33
+
34
+ return $uri;
35
+ }
36
+ }
app/code/community/Fishpig/Wordpress/Helper/Db.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Db extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /*
6
+ * Stores mapped table names to stop remapping
7
+ */
8
+ protected $_mappedTableNames = array();
9
+
10
+ /**
11
+ * Connection flag
12
+ *
13
+ * @var bool
14
+ */
15
+ protected $_isConnected = null;
16
+
17
+ /*
18
+ * Returns the given table name with the Wordpress prefix
19
+ * Maps the table name in Magento to ensure correct prefix used
20
+ */
21
+ public function getTableName($table)
22
+ {
23
+ if (!in_array($table, $this->_mappedTableNames)) {
24
+ Mage::getSingleton('core/resource')->setMappedTableName($table, $this->_getTableName($table));
25
+ $this->_mappedTableNames[$this->_getTableName($table)] = $table;
26
+ }
27
+
28
+ return $this->_getTableName($table);
29
+ }
30
+
31
+ /*
32
+ * Returns the given table name and Wordpress table prefix
33
+ * This function doesn't map the table name
34
+ */
35
+ protected function _getTableName($table = '')
36
+ {
37
+ return $this->getTablePrefix().$table;
38
+ }
39
+
40
+ /*
41
+ * Returns the table prefix used by Wordpress
42
+ */
43
+ public function getTablePrefix()
44
+ {
45
+ return Mage::getStoreConfig('wordpress/database/table_prefix');
46
+ }
47
+
48
+ /*
49
+ *
50
+ */
51
+ public function mapTables()
52
+ {
53
+ $tables = array('commentmeta', 'comments', 'links', 'options', 'posts', 'terms', 'term_relationships', 'term_taxonomy', 'usermeta', 'users');
54
+
55
+ foreach($tables as $table) {
56
+ Mage::helper('wordpress')->getTableName($table);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Fetches a single value from a Wordpress table
62
+ *
63
+ * @param $query
64
+ * @param bool $graceful
65
+ * @return string
66
+ */
67
+ public function fetchOne($query, $graceful = true)
68
+ {
69
+ try {
70
+ if ($this->isSameDatabase()) {
71
+ return Mage::getSingleton('core/resource')->getConnection('core_read')->fetchOne($query);
72
+ }
73
+ else {
74
+ return Mage::getSingleton('core/resource')->getConnection('wordpress_read')->fetchOne($query);
75
+ }
76
+ }
77
+ catch (Exception $e) {
78
+ $this->log('Db.Helper->fetchOne: '.$e->getMessage());
79
+
80
+ if ($graceful == false) {
81
+ throw new Exception($e->getMessage());
82
+ }
83
+ }
84
+
85
+ return null;
86
+ }
87
+
88
+ /**
89
+ * Returns true if connected to DB
90
+ *
91
+ * @param bool $graceful
92
+ * @return bool
93
+ */
94
+ public function isConnected($graceful = true)
95
+ {
96
+ if (is_null($this->_isConnected)) {
97
+ $conn = $this->getWordpressRead();
98
+
99
+ try {
100
+ if (!is_object($conn)) {
101
+ /* Magento .1.3.2.4 */
102
+ throw new Exception('Error connecting to the WordPress database');
103
+ }
104
+
105
+ $conn->getConnection();
106
+
107
+ $this->_isConnected = $conn->isConnected();
108
+ }
109
+ catch (Exception $e) {
110
+ $this->log($e->getMessage());
111
+ $this->_isConnected = false;
112
+
113
+ if (!$graceful) {
114
+ throw $e;
115
+ }
116
+ }
117
+ }
118
+
119
+ return $this->_isConnected;
120
+ }
121
+
122
+ /**
123
+ * Returns true if it is possible to query the DB
124
+ *
125
+ * @bool
126
+ */
127
+ public function isQueryable($graceful = true)
128
+ {
129
+ if ($this->isConnected()) {
130
+ $conn = $this->_helper('db')->getWordpressRead();
131
+
132
+ try {
133
+ $conn->fetchRow('SELECT * FROM ' . $this->_helper('db')->getTableName('posts') . ' LIMIT 1');
134
+ return true;
135
+ }
136
+ catch (Exception $e) {
137
+ $this->log('Debug.canQuery: '.$e->getMessage());
138
+
139
+ if (!$graceful) {
140
+ throw $e;
141
+ }
142
+ }
143
+ }
144
+
145
+ return false;
146
+ }
147
+
148
+ /**
149
+ * Returns the default read connection for the WordPress DB
150
+ *
151
+ * @return
152
+ */
153
+ public function getWordpressRead()
154
+ {
155
+ return Mage::getSingleton('core/resource')->getConnection('wordpress_read');
156
+ }
157
+
158
+
159
+ /**
160
+ * Returns the default read connection for the Magento DB
161
+ *
162
+ * @return
163
+ */
164
+ public function getMagentoRead()
165
+ {
166
+ return Mage::getSingleton('core/resource')->getConnection('core_read');
167
+ }
168
+
169
+ /**
170
+ * Returns the table name for the Magento DB
171
+ *
172
+ * @param string $table
173
+ * @return string
174
+ */
175
+ public function getMagentoTableName($table)
176
+ {
177
+ return Mage::getSingleton('core/resource')->getTableName($table);
178
+ }
179
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+
6
+ public function performIntegrationTests()
7
+ {
8
+ return $this->_helper('debug_test')->performTests();
9
+ }
10
+
11
+
12
+
13
+ public function getIntegrationTestClasses()
14
+ {
15
+ return array('connection');
16
+ return array('connection', 'query', 'integration');
17
+ }
18
+
19
+ /**
20
+ * To go
21
+ */
22
+ const _integration_error_route_mismatch_advice = 'Go To WordPress > Settings > Reading and enter %s in the field \'Site Address (URL)\'';
23
+
24
+ const _matching_wp_urls = 'Matching WP URLs';
25
+ const _matching_blog_urls = 'Matching blog URLs';
26
+
27
+ const _not_applicable = 'N/A';
28
+
29
+ protected $_testResultsCollection = null;
30
+
31
+
32
+ public function getTestResultsCollection()
33
+ {
34
+ if (is_null($this->_testResultsCollection)) {
35
+ $collection = new Varien_Data_Collection();
36
+
37
+ foreach($this->_getCheckMethods() as $method => $title) {
38
+ $statusClass = 'success-msg';
39
+
40
+ try {
41
+ $response = $this->_performCheck($method);
42
+ }
43
+ catch (Exception $e) {
44
+ $response = $e->getMessage();
45
+ $statusClass = 'error-msg';
46
+ }
47
+
48
+ $collection->addItem(
49
+ new Varien_Object(array('title' => $title, 'response' => $response, 'result' => $statusClass))
50
+ );
51
+ }
52
+
53
+ $this->_testResultsCollection = $collection;
54
+ }
55
+
56
+ return $this->_testResultsCollection;
57
+ }
58
+
59
+
60
+ protected function _performCheck($method)
61
+ {
62
+ return call_user_func(array($this, $method));
63
+ }
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+ /**
74
+ * Test methods
75
+ *
76
+ */
77
+
78
+ public function canConnect()
79
+ {
80
+ try {
81
+ if ($this->_helper('db')->isConnected(false) == false) {
82
+ throw new Exception(self::_db_connection_error_advice);
83
+ }
84
+ }
85
+ catch (Exception $e) {
86
+ $this->log($e->getMessage());
87
+ throw $e;
88
+ }
89
+ }
90
+
91
+ public function canQuery()
92
+ {
93
+ if ($this->_helper('db')->isConnected() == true) {
94
+ try {
95
+ if ($this->_helper('db')->isQueryable(false)) {
96
+ return;
97
+ }
98
+ }
99
+ catch (Exception $e) {
100
+ $this->log($e->getMessage());
101
+ throw $e;
102
+ }
103
+ }
104
+
105
+ $this->_throwNotApplicableException();
106
+ }
107
+
108
+ public function isIntegrated()
109
+ {
110
+ if ($this->_helper('db')->isConnected() == false) {
111
+ throw new Exception('N/A');
112
+ }
113
+
114
+ if ($this->_helper('db')->isQueryable() == false) {
115
+ throw new Exception('N/A');
116
+ }
117
+
118
+ if ($this->isFullyIntegrated()) {
119
+ return $this->_isFullyIntegrated();
120
+ }
121
+
122
+ return $this->_isSemiIntegrated();
123
+ }
124
+
125
+ protected function _isSemiIntegrated()
126
+ {
127
+ return true;
128
+ }
129
+
130
+ protected function _isFullyIntegrated()
131
+ {
132
+ $blogUrlMagento = rtrim($this->getUrl(), '/');
133
+ $blogUrlWp = rtrim($this->getCachedWpOption('siteurl'), '/');
134
+ $wpUrl = trim($this->getCachedWpOption('home'), '/');
135
+
136
+ if ($blogUrlWp == $wpUrl) {
137
+ throw new Exception(self::_matching_wp_urls);
138
+ }
139
+ else if ($blogUrlMagento == $blogUrlWp) {
140
+ throw new Exception(self::_matching_blog_urls);
141
+ }
142
+
143
+ return;
144
+ }
145
+
146
+ protected function _throwNotApplicableException()
147
+ {
148
+ throw new Exception(self::_not_applicable);
149
+ }
150
+
151
+ public function isAclValid()
152
+ {
153
+ try {
154
+ $session = Mage::getSingleton('admin/session');
155
+ $resourceId = $session->getData('acl')->get("admin/system/config/wordpress")->getResourceId();
156
+ return $session->isAllowed($resourceId);
157
+ }
158
+ catch (Exception $e) { }
159
+
160
+ return false;
161
+ }
162
+
163
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/EnvironmentReport.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_EnvironmentReport extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ protected $_items = array();
6
+
7
+ public function getReport()
8
+ {
9
+ if (count($this->_items) == 0) {
10
+ $this->_collectModuleConfigs();
11
+ $this->_collectEnvironmentConfigs();
12
+ $this->_collectionIntegrationTestResults();
13
+ }
14
+
15
+ return $this->_items;
16
+ }
17
+
18
+ /**
19
+ * Collects the Magento environment data
20
+ */
21
+ protected function _collectEnvironmentConfigs()
22
+ {
23
+ $configPaths = array('web/unsecure/base_url','web/seo/use_rewrites', 'design/package/name', 'design/theme/template', 'design/theme/layout');
24
+ $configs = array();
25
+
26
+ foreach($configPaths as $configPath) {
27
+ $configs[$configPath] = Mage::getStoreConfig($configPath);
28
+ }
29
+
30
+ $configs['custom/magento/base_dir'] = Mage::getBaseDir();
31
+ $configs['custom/magento/version'] = Mage::getVersion();
32
+ $configs['custom/php/version'] = phpversion();
33
+
34
+ return $this->addItem('Magento Configuration', $configs);
35
+ }
36
+
37
+ /**
38
+ * Collects the module config values
39
+ */
40
+ protected function _collectModuleConfigs()
41
+ {
42
+ $configs = Mage::getModel('adminhtml/config_data')->setSection('wordpress')->load();
43
+
44
+ if (isset($configs['wordpress/database/dbname'])) {
45
+ $configs['wordpress/database/dbname'] = Mage::helper('core')->decrypt($configs['wordpress/database/dbname']);
46
+ }
47
+
48
+ foreach(array('wordpress/database/username', 'wordpress/database/password') as $path) {
49
+ if (isset($configs[$path])) {
50
+ if (Mage::helper('core')->decrypt($configs[$path])) {
51
+ $configs[$path] = '****';
52
+ }
53
+ else {
54
+ $configs[$path] = 'null';
55
+ }
56
+ }
57
+ }
58
+
59
+ $configs['wordpress/module/version'] = $this->getModuleVersion();
60
+
61
+ return $this->addItem('Module Configuration', $configs);
62
+ }
63
+
64
+ public function getModuleVersion()
65
+ {
66
+ $modules = (array) Mage::getConfig()->getNode('modules')->children();
67
+
68
+ if (isset($modules['Fishpig_Wordpress'])) {
69
+ $module = (array)$modules['Fishpig_Wordpress'];
70
+ return $module['version'];
71
+ }
72
+
73
+ return null;
74
+ }
75
+ /**
76
+ * Collects the results from the integration tests
77
+ */
78
+ protected function _collectionIntegrationTestResults()
79
+ {
80
+ $results = $this->_helper('debug_test')->performIntegrationTests();
81
+ $configs = array();
82
+
83
+ foreach($results as $result) {
84
+ $configs[$result->getTitle()] = $result->getResponse();
85
+ }
86
+
87
+ return $this->addItem('Integration Results', $configs);
88
+ }
89
+
90
+ /**
91
+ * Adds a collection of items to the $_items array
92
+ *
93
+ * @param string $section
94
+ * @param array $values
95
+ */
96
+ public function addItem($section, array $values)
97
+ {
98
+ $this->_items[$section] = $values;
99
+ return $this;
100
+ }
101
+
102
+ public function getLogEntries($entryLimit = 100)
103
+ {
104
+ $logFile = Mage::getBaseDir('var') . '/log/wordpress.log';
105
+
106
+ if (file_exists($logFile)) {
107
+ try {
108
+ $logs = explode("\n", file_get_contents($logFile));
109
+ $entries = count($logs);
110
+
111
+ if ($entries > $entryLimit) {
112
+ $logs = array_splice($logs, (-($entryLimit)));
113
+ }
114
+
115
+ return implode("\n", array_reverse($logs));
116
+ }
117
+ catch (Exception $e) {
118
+ $this->log($e->getMessage());
119
+ }
120
+ }
121
+
122
+ return false;
123
+ }
124
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /**
6
+ * Cache for the test results collection
7
+ *
8
+ * @var null|Varien_Data_Collection
9
+ */
10
+ protected $_resultCollection = null;
11
+
12
+ /**
13
+ * Gets the test results and stores them in the cache
14
+ *
15
+ * @return Varien_Data_Collection
16
+ */
17
+ public function performIntegrationTests()
18
+ {
19
+ if (!$this->hasResults()) {
20
+ $results = $this->_helper('debug_test_resultCollection');
21
+
22
+ foreach($this->getAvailableTestClasses() as $test) {
23
+ $results->addItem($this->_helper('debug_test_'.$test)->performTest());
24
+ }
25
+
26
+ $this->_resultCollection = $results;
27
+ }
28
+
29
+ return $this->getResultCollection();
30
+ }
31
+
32
+ /**
33
+ * Returns true if the results collection contains any results
34
+ *
35
+ * @return bool
36
+ */
37
+ public function hasResults()
38
+ {
39
+ return ($this->_resultCollection != null);
40
+ }
41
+
42
+ /**
43
+ * Returns the results collection
44
+ *
45
+ * @return null|Varien_Data_Collection
46
+ */
47
+ public function getResultCollection()
48
+ {
49
+ return $this->_resultCollection;
50
+ }
51
+
52
+ /**
53
+ * Returns the class names used to perform the tests
54
+ *
55
+ * @return array
56
+ */
57
+ public function getAvailableTestClasses()
58
+ {
59
+ if ($this->isFullyIntegrated()) {
60
+ return array('connection', 'query', 'wpUrls', 'blogRoute');
61
+ }
62
+
63
+ return array('connection', 'query');
64
+ }
65
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Abstract.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Helper_Debug_Test_Abstract extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+ /**
6
+ * Test title
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_title = null;
11
+
12
+ /**
13
+ * Class used when error occurs
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_errorClass = 'error-msg';
18
+
19
+ /**
20
+ * Class used when no error occurs
21
+ *
22
+ * @var string
23
+ */
24
+ protected $_successClass = 'success-msg';
25
+
26
+ /**
27
+ * Server response when unknown error occurs
28
+ *
29
+ * @var string
30
+ */
31
+ const _error_unknown = 'An error was reported during this test. Please enable logging and check /var/log/wordpress.log';
32
+
33
+ /**
34
+ * Server response when a previous test was unsuccessfull
35
+ *
36
+ * @var string
37
+ */
38
+ const _error_cannot_test = '';//'This test cannot be performed until all previous tests are successfull';
39
+
40
+ /**
41
+ * Function contains test logic
42
+ *
43
+ * Must be present in all descendent classes
44
+ *
45
+ * @return bool
46
+ */
47
+ abstract protected function _performTest();
48
+
49
+ /**
50
+ * Wrapper for self::_performTest()
51
+ * Processes result of test and converts to object
52
+ *
53
+ * @return Varien_Object
54
+ */
55
+ final public function performTest()
56
+ {
57
+ try {
58
+ if ($this->_performTest()) {
59
+ return $this->_createResultObject($this->_title, ': )', $this->_successClass);
60
+ }
61
+
62
+ throw new Exception(self::_error_unknown);
63
+ }
64
+ catch (Exception $e) {
65
+ $this->log($e->getMessage());
66
+ return $this->_createResultObject($this->_title, $e->getMessage(), $this->_errorClass);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Converts the result data into an object
72
+ *
73
+ * @param string $title
74
+ * @param string $response
75
+ * @param string $resultClass
76
+ * @return Varien_Object
77
+ */
78
+ protected function _createResultObject($title, $response , $resultClass)
79
+ {
80
+ return new Varien_Object(array('title' => $title, 'response' => $response, 'result' => $resultClass));
81
+ }
82
+
83
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/BlogRoute.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test_BlogRoute extends Fishpig_Wordpress_Helper_Debug_Test_Abstract
4
+ {
5
+ /**
6
+ * Test title
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_title = 'Blog Route';
11
+
12
+ const _error_mismatched_urls = 'Go to the General Settings page of your WordPress Admin and set the \'Site address (URL)\' field to \'%s\'';
13
+
14
+ const _error_empty_route = 'Your blog route is either empty or contains invalid characters.';
15
+
16
+ /**
17
+ * Perform the test logic
18
+ * Checks whether the WordPress install and blog URL match
19
+ *
20
+ * @return bool
21
+ */
22
+ protected function _performTest()
23
+ {
24
+ if ($this->_helper('db')->isConnected() && $this->_helper('db')->isQueryable()) {
25
+ if (!$this->isFullyIntegrated()) {
26
+ return false;
27
+ }
28
+
29
+ if ($this->getBlogRoute()) {
30
+ return $this->isBlogRouteCorrect(false);
31
+ }
32
+
33
+ throw new Exception(self::_error_empty_route);
34
+ }
35
+
36
+ throw new Exception(self::_error_cannot_test);
37
+ }
38
+
39
+ /**
40
+ * Returns true if the install that WordPress is installed on (WP-Option: home) is the
41
+ * same as the site URL (WP-Option: siteurl)
42
+ *
43
+ * @param bool $graceful
44
+ * @return bool
45
+ */
46
+ public function isBlogRouteCorrect($graceful = true)
47
+ {
48
+ $wpBlogUrl = rtrim($this->getCachedWpOption('home'), '/');
49
+ $mageBlogUrl = rtrim($this->getUrl(), '/');
50
+
51
+ if ($wpBlogUrl != $mageBlogUrl) {
52
+ if (!$graceful) {
53
+ throw new Exception(sprintf(self::_error_mismatched_urls, $mageBlogUrl));
54
+ }
55
+
56
+ return false;
57
+ }
58
+
59
+ return true;
60
+ }
61
+
62
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Connection.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test_Connection extends Fishpig_Wordpress_Helper_Debug_Test_Abstract
4
+ {
5
+ /**
6
+ * Test title
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_title = 'Database Connection';
11
+
12
+ /**
13
+ * Perform the test logic
14
+ * Checks whether database is connected
15
+ *
16
+ * @return bool
17
+ */
18
+ protected function _performTest()
19
+ {
20
+ return $this->_helper('db')->isConnected(false);
21
+ }
22
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/Query.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test_Query extends Fishpig_Wordpress_Helper_Debug_Test_Abstract
4
+ {
5
+ /**
6
+ * Test title
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_title = 'Database Query';
11
+
12
+ /**
13
+ * Perform the test logic
14
+ * Checks whether database is connected
15
+ *
16
+ * @return bool
17
+ */
18
+ protected function _performTest()
19
+ {
20
+ if ($this->_helper('db')->isConnected()) {
21
+ return $this->_helper('db')->isQueryable(false);
22
+ }
23
+
24
+ throw new Exception(self::_error_cannot_test);
25
+ }
26
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/ResultCollection.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test_ResultCollection extends Varien_Data_Collection
4
+ {
5
+ /**
6
+ * Ensures that the collection size is correctly calculated
7
+ *
8
+ * @return int
9
+ */
10
+ public function getSize()
11
+ {
12
+ return count($this->_items);
13
+ }
14
+ }
app/code/community/Fishpig/Wordpress/Helper/Debug/Test/WpUrls.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Debug_Test_WpUrls extends Fishpig_Wordpress_Helper_Debug_Test_Abstract
4
+ {
5
+ /**
6
+ * Test title
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_title = 'WordPress URL\'s';
11
+
12
+ const _error_matching_urls = 'Your blog URL (site address) matches your install URL (WordPress address). Please change your blog route or move WordPress to a different sub-directory';
13
+
14
+ /**
15
+ * Perform the test logic
16
+ * Checks whether the WordPress install and blog URL match
17
+ *
18
+ * @return bool
19
+ */
20
+ protected function _performTest()
21
+ {
22
+ if ($this->_helper('db')->isConnected() && $this->_helper('db')->isQueryable()) {
23
+ if (!$this->isFullyIntegrated()) {
24
+ return false;
25
+ }
26
+
27
+ return $this->wpUrlsMatch(false);
28
+ }
29
+
30
+ throw new Exception(self::_error_cannot_test);
31
+ }
32
+
33
+ /**
34
+ * Returns true if the install that WordPress is installed on (WP-Option: home) is the
35
+ * same as the site URL (WP-Option: siteurl)
36
+ *
37
+ * @param bool $graceful
38
+ * @return bool
39
+ */
40
+ public function wpUrlsMatch($graceful = true)
41
+ {
42
+ $blogUrl = rtrim($this->_helper()->getUrl(), '/');
43
+ $installUrl = rtrim($this->getCachedWpOption('siteurl'), '/');
44
+
45
+ if ($blogUrl == $installUrl) {
46
+ if (!$graceful) {
47
+ throw new Exception(self::_error_matching_urls);
48
+ }
49
+
50
+ return false;
51
+ }
52
+
53
+ return true;
54
+ }
55
+
56
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter extends Fishpig_Wordpress_Helper_Object
4
+ {
5
+ /**
6
+ * Applies a set of filters to the given string
7
+ *
8
+ * @param string $content
9
+ * @param array $params
10
+ * @return string
11
+ */
12
+ public function applyFilters($content, array $params = array())
13
+ {
14
+ if (!isset($params['filters'])) {
15
+ $filters = $this->getFilters('content');
16
+ }
17
+ else {
18
+ $filters = $this->getFilters($params['filters']);
19
+ unset($params['filters']);
20
+ }
21
+
22
+ foreach($filters as $filter) {
23
+ $content = $this->applyFilter($content, $filter, $params);
24
+ }
25
+
26
+ return $content;
27
+ }
28
+
29
+ /**
30
+ * Applies a specific filter to the given content string
31
+ *
32
+ * @param string $content
33
+ * @param string $filter
34
+ * @param array $params
35
+ * @return string $content
36
+ */
37
+ public function applyFilter($content, $filter, array $params = array())
38
+ {
39
+ if ($helper = $this->_getFilterHelperClass($filter)) {
40
+ $content = $helper->setContent($content)->setType($filter)->setParams($params)->applyFilter();
41
+ }
42
+ else {
43
+ $this->log('Invalid filter: '.$this->camelize($filter));
44
+ }
45
+
46
+ return $content;
47
+ }
48
+
49
+ /**
50
+ * Returns an instance of a helper based on the helper key
51
+ *
52
+ * @param string $filter
53
+ * @return Fishpig_Wordpress_Helper_Filter_Abstract
54
+ */
55
+ protected function _getFilterHelperClass($filter)
56
+ {
57
+ return $this->_getHelperClass('wordpress/filter'.$this->camelize($filter));
58
+ }
59
+
60
+ /**
61
+ * Returns the default filter set
62
+ *
63
+ * @return array
64
+ */
65
+ public function getFilters($type)
66
+ {
67
+ if ($filters = trim(Mage::getStoreConfig('wordpress_blog/filters/'.$type.'_filters'), ' ,')) {
68
+ return explode(',', $filters);
69
+ }
70
+
71
+ return array();
72
+ }
73
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Abstract.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Helper_Filter_Abstract extends Fishpig_Wordpress_Helper_Object
4
+ {
5
+ /**
6
+ * Stores the content that the filter should be applied to
7
+ *
8
+ * @var string
9
+ */
10
+ protected $_content = null;
11
+
12
+ /**
13
+ * The filter type
14
+ *
15
+ * @var string
16
+ */
17
+ protected $_type = null;
18
+
19
+ /**
20
+ * Additional parameters that will be useful for the filter
21
+ *
22
+ * @var Varien_Object
23
+ */
24
+ protected $_params = null;
25
+
26
+ /**
27
+ * Contains the filter logic
28
+ * All filter's must have this function and
29
+ * this function should ALWAYS return the content
30
+ *
31
+ * @return string
32
+ */
33
+ abstract function applyFilter();
34
+
35
+
36
+ public function __construct()
37
+ {
38
+ $this->_params = new Varien_Object();
39
+ parent::__construct();
40
+ }
41
+ /**
42
+ * Sets the content variable
43
+ *
44
+ * @param string $content
45
+ */
46
+ public function setContent($content)
47
+ {
48
+ $this->_content = $content;
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Sets the type variable
54
+ *
55
+ * @param string $type
56
+ */
57
+ public function setType($type)
58
+ {
59
+ $this->type = $type;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Sets the parameter array
65
+ *
66
+ * @param array $params
67
+ */
68
+ public function setParams($params)
69
+ {
70
+ if ($params instanceof Varien_Object) {
71
+ $this->_params = $params;
72
+ }
73
+ else {
74
+ $this->_params->setData($params);
75
+ }
76
+
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Get the parameters
82
+ *
83
+ * @return Varien_Object
84
+ */
85
+ public function getParams()
86
+ {
87
+ return $this->_params;
88
+ }
89
+
90
+ /**
91
+ * Explodes a string into parts based on the given short tag
92
+ *
93
+ * @param string $shortcode
94
+ * @param string $content
95
+ * @param bool $splitTags = false
96
+ * @return array
97
+ */
98
+ protected function _explode($shortcode, $content, $splitTags = false)
99
+ {
100
+ if ($splitTags) {
101
+ $pattern = "/(\[" . $shortcode . "[^\]]*\])|(\[\/".$shortcode . "\])/";
102
+ }
103
+ else {
104
+ $pattern = "/(\[" . $shortcode . "[^\]]*\].*?\[\/".$shortcode . "\])/";
105
+ }
106
+
107
+ $parts = preg_split($pattern, $content, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
108
+
109
+ return $this->_sortExplodedString($parts, $shortcode);
110
+ }
111
+
112
+ /**
113
+ * Sorts and classifies a string exploded by self::_explode
114
+ *
115
+ * @param array $parts
116
+ * @param string $shortcode
117
+ * @return array
118
+ */
119
+ protected function _sortExplodedString(array $parts, $shortcode)
120
+ {
121
+ foreach($parts as $key => $part) {
122
+ if (strpos($part, "[$shortcode") !== false) {
123
+ $parts[$key] = array('is_opening_tag' => true, 'is_closing_tag' => false, 'content' => $part);
124
+ }
125
+ else if (strpos($part, "[/$shortcode]") !== false) {
126
+ $parts[$key] = array('is_opening_tag' => false, 'is_closing_tag' => true, 'content' => $part);
127
+ }
128
+ else {
129
+ $parts[$key] = array('is_opening_tag' => false, 'is_closing_tag' => false, 'content' => $part);
130
+ }
131
+ }
132
+
133
+ return $parts;
134
+ }
135
+
136
+ /**
137
+ * Returns a matched string from $buffer
138
+ *
139
+ * @param string $buffer
140
+ * @param string $field
141
+ * @return string
142
+ */
143
+ protected function _getMatchedString($buffer, $field, $defaultValue = null)
144
+ {
145
+ return ($matchedValue = $this->_match("/".$field."=['\"]([^'\"]+)['\"]/", $buffer, 1)) ? $matchedValue : $defaultValue;
146
+ }
147
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/AutoParagraph.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_AutoParagraph extends Fishpig_Wordpress_Helper_Filter_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ * This code has been taken from Wordpress to ensure that
8
+ * the results in Magento and Wordpress match exactly!
9
+ *
10
+ * @return string
11
+ */
12
+ public function applyFilter()
13
+ {
14
+ $content = $this->_content;
15
+ $br = true;
16
+
17
+ if ( trim($content) === '' ) {
18
+ return $content;
19
+ }
20
+
21
+ $content = $content . "\n";
22
+ $content = preg_replace('|<br />\s*<br />|', "\n\n", $content);
23
+
24
+ $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
25
+ $content = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $content);
26
+ $content = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $content);
27
+ $content = str_replace(array("\r\n", "\r"), "\n", $content);
28
+
29
+ if ( strpos($content, '<object') !== false ) {
30
+ $content = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $content); // no pee inside object/embed
31
+ $content = preg_replace('|\s*</embed>\s*|', '</embed>', $content);
32
+ }
33
+
34
+ $content = preg_replace("/\n\n+/", "\n\n", $content); // take care of duplicates
35
+ $contents = preg_split('/\n\s*\n/', $content, -1, PREG_SPLIT_NO_EMPTY);
36
+ $content = '';
37
+
38
+ foreach ( $contents as $tinkle ) {
39
+ $content .= '<p>' . trim($tinkle, "\n") . "</p>\n";
40
+ }
41
+
42
+ $content = preg_replace('|<p>\s*</p>|', '', $content); // under certain strange conditions it could create a P of entirely whitespace
43
+ $content = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $content);
44
+ $content = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $content); // don't pee all over a tag
45
+ $content = preg_replace("|<p>(<li.+?)</p>|", "$1", $content); // problem with nested lists
46
+ $content = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $content);
47
+ $content = str_replace('</blockquote></p>', '</p></blockquote>', $content);
48
+ $content = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $content);
49
+ $content = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $content);
50
+
51
+ if ($br) {
52
+ $content = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $content);
53
+ $content = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $content); // optionally make line breaks
54
+ $content = str_replace('<WPPreserveNewline />', "\n", $content);
55
+ }
56
+
57
+ $content = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $content);
58
+ $content = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $content);
59
+ $content = preg_replace( "|\n</p>$|", '</p>', $content );
60
+
61
+ return $content;
62
+ }
63
+
64
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/RemoveHtml.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_RemoveHtml extends Fishpig_Wordpress_Helper_Filter_Abstract
4
+ {
5
+ /**
6
+ * Removes all HTML from string
7
+ *
8
+ * @return string
9
+ */
10
+ public function applyFilter()
11
+ {
12
+ return strip_tags($this->_content);
13
+ }
14
+
15
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Abstract.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract extends Fishpig_Wordpress_Helper_Filter_Abstract
4
+ {
5
+
6
+ public function _createBlock($type, $name = null)
7
+ {
8
+ return Mage::getSingleton('core/layout')->createBlock($type, $name.microtime());
9
+ }
10
+
11
+
12
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/AssociatedProducts.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcode_AssociatedProducts extends Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ *
8
+ * @return string
9
+ */
10
+ public function applyFilter()
11
+ {
12
+ $parts = $this->_explode('associated-products', $this->_content, true);
13
+ $content = '';
14
+
15
+ foreach($parts as $part) {
16
+ $buffer = $part['content'];
17
+
18
+ if ($part['is_opening_tag']) {
19
+ $postId = $this->getParams()->getId();
20
+ $template = $this->_getMatchedString($buffer, 'template', 'wordpress/shortcode/associated-products.phtml');
21
+ $title = $this->_getMatchedString($buffer, 'title');
22
+
23
+ if ($postId) {
24
+ $post = Mage::getModel('wordpress/post')->load($postId);
25
+
26
+ if ($post->getId() > 0) {
27
+ try {
28
+ $part['content'] = $this->_createBlock('wordpress/post_associated_products')
29
+ ->setPostId($postId)
30
+ ->setTitle($title)
31
+ ->setTemplate($template)
32
+ ->toHtml();
33
+ }
34
+ catch (Exception $e) {
35
+ $this->_helper()->log('Shortcode_AssociatedProducts: '.$e->getMessage());
36
+ $part['content'] = '';
37
+ }
38
+ }
39
+ }
40
+ else {
41
+ $this->_helper()->log('Invalid product shortcode: '.htmlspecialchars($part['content']));
42
+ }
43
+ }
44
+
45
+ $content .= $part['content'];
46
+ }
47
+
48
+ return $content;
49
+ }
50
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Caption.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcode_Caption extends Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ * Converts all caption shortcodes into div tags
8
+ *
9
+ * @return string
10
+ */
11
+ public function applyFilter()
12
+ {
13
+ $parts = $this->_explode('caption', $this->_content);
14
+ $content = '';
15
+
16
+ foreach($parts as $part) {
17
+ $buffer = $part['content'];
18
+
19
+ if ($part['is_opening_tag']) {
20
+
21
+ $id = $this->_match("/id=['\"]([^'\"]+)['\"]/", $buffer, 1);
22
+ $align = str_replace("align", "", $this->_match("/align=['\"](align[^'\"]+)['\"]/", $buffer, 1));
23
+ $width = $this->_match("/width=['\"]([0-9]+)['\"]/", $buffer, 1);
24
+ $caption = $this->_match("/caption=['\"]([^'\"]+)['\"]/", $buffer, 1);
25
+ $innerHtml = $this->_match("/\[caption[^\]]*\](.*?)\[\/caption\]/", $buffer, 1);
26
+ $part['content'] = "<div id=\"$id\" class=\"$align\" style=\"width:".($width+10)."px;\">$innerHtml<p class=\"wp-caption\">$caption</div>";
27
+ }
28
+
29
+ $content .= $part['content'];
30
+ }
31
+
32
+ return $content;
33
+ }
34
+
35
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Product.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcode_Product extends Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ * Converts all product shortcodes
8
+ *
9
+ * @return string
10
+ */
11
+ public function applyFilter()
12
+ {
13
+ $parts = $this->_explode('product', $this->_content, true);
14
+ $content = '';
15
+
16
+ foreach($parts as $part) {
17
+ $buffer = $part['content'];
18
+
19
+ if ($part['is_opening_tag']) {
20
+ $id = $this->_match("/id=['\"]([^'\"]+)['\"]/", $buffer, 1);
21
+ $template = $this->_getMatchedString($buffer, 'template', 'wordpress/shortcode/product.phtml');
22
+
23
+ if ($id) {
24
+ $product = Mage::getModel('catalog/product')->load($id);
25
+
26
+ if ($product->getId() > 0) {
27
+ $part['content'] = $this->_createBlock('core/template')
28
+ ->setProduct($product)
29
+ ->setProductId($id)
30
+ ->setTemplate($template)
31
+ ->toHtml();
32
+ }
33
+ }
34
+ else {
35
+ $this->_helper()->log('Invalid product shortcode: '.htmlspecialchars($part['content']));
36
+ }
37
+ }
38
+
39
+ $content .= $part['content'];
40
+ }
41
+
42
+ return $content;
43
+ }
44
+
45
+ /**
46
+ * Creates a block
47
+ *
48
+ * @param string $type
49
+ * @param string $name
50
+ * @return Mage_Core_Block_Template
51
+ */
52
+ public function _createBlock($type, $name = null)
53
+ {
54
+ return Mage::getSingleton('core/layout')->createBlock($type, $name.microtime());
55
+ }
56
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/SyntaxHighlighter.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcode_SyntaxHighlighter extends Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ *
8
+ * @return string
9
+ */
10
+ public function applyFilter()
11
+ {
12
+ $parts = $this->_explode('sourcecode', $this->_content, true);
13
+ $content = '';
14
+ $nextIsSource = false;
15
+ $language = '';
16
+
17
+ foreach($parts as $part) {
18
+ $buffer = $part['content'];
19
+
20
+ if ($part['is_opening_tag']) {
21
+ $nextIsSource = true;
22
+ $language = $this->_getMatchedString($buffer, 'language');
23
+ $part['content'] = '';
24
+ }
25
+ elseif ($nextIsSource) {
26
+ $nextIsSource = false;
27
+ $part['content'] = '<pre class="brush: ' . ($language ? $language : 'php') . '">'.$part['content'].'</pre>';
28
+ }
29
+ elseif ($part['is_closing_tag']) {
30
+ $part['content'] = '';
31
+ }
32
+
33
+ $content .= $part['content'];
34
+ }
35
+
36
+ return $content;
37
+ }
38
+
39
+ public function isEnabled()
40
+ {
41
+ return Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/enabled');
42
+ }
43
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcode/Youtube.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcode_Youtube extends Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
4
+ {
5
+ /**
6
+ * Performs the filter logic
7
+ * Converts all youtube shortcodes into youtube videos
8
+ * [youtube=http://www.youtube.com/watch?v=DhtcaRRngcw]
9
+ *
10
+ * @return string
11
+ */
12
+ public function applyFilter()
13
+ {
14
+ $parts = $this->_explode('youtube', $this->_content);
15
+ $content = '';
16
+
17
+ foreach($parts as $part) {
18
+ $buffer = $part['content'];
19
+ if ($part['is_opening_tag']) {
20
+ $videoUrl = trim($this->_match("/youtube=([^\]]+)\]/", $buffer, 1), "\"' /");
21
+ $videCode = $this->_match("/v=([a-zA-Z0-9-]+)/", $videoUrl, 1);
22
+
23
+ try {
24
+ $part['content'] = $this->_createBlock('core/template')
25
+ ->setYoutubeVideoCode($videCode)
26
+ ->setTemplate('wordpress/shortcode/youtube-video.phtml')
27
+ ->toHtml();
28
+ }
29
+ catch (Exception $e) {
30
+ $this->_helper()->log('Shortcode_YouTube: '.$e->getMessage());
31
+ $part['content'] = '';
32
+ }
33
+ }
34
+
35
+ $content .= $part['content'];
36
+ }
37
+
38
+ return $content;
39
+ }
40
+
41
+ }
app/code/community/Fishpig/Wordpress/Helper/Filter/Shortcodes.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Filter_Shortcodes extends Fishpig_Wordpress_Helper_Filter_Abstract
4
+ {
5
+ /**
6
+ * Returns an array containing all currently supported shortcodes
7
+ *
8
+ * @return array
9
+ */
10
+ public function getShortcodes()
11
+ {
12
+ $shortcodes = explode(",", trim(Mage::getStoreConfig('wordpress_blog/filters/shortcodes'), ', '));
13
+
14
+ if ($this->_getShortcodeHelperClass('syntaxHighlighter')->isEnabled()) {
15
+ $shortcodes[] = 'syntaxHighlighter';
16
+ }
17
+
18
+ return $shortcodes;
19
+ }
20
+
21
+ /**
22
+ * Performs the filter logic
23
+ *
24
+ * @return string
25
+ */
26
+ public function applyFilter()
27
+ {
28
+ $content = $this->_content;
29
+ $shortcodes = $this->getShortcodes();
30
+
31
+ foreach($shortcodes as $shortcode) {
32
+ if ($helper = $this->_getShortcodeHelperClass($shortcode)) {
33
+ $content = $helper->setContent($content)->setType($shortcode)->setParams($this->_params)->applyFilter();
34
+ }
35
+ }
36
+
37
+ return $content;
38
+ }
39
+
40
+ /**
41
+ * Returns a helper based on the shortcode given
42
+ *
43
+ * @param string $shortcode
44
+ * @return Fishpig_Wordpress_Helper_Filter_Shortcode_Abstract
45
+ */
46
+ protected function _getShortcodeHelperClass($shortcode)
47
+ {
48
+ return $this->_getHelperClass('wordpress/filter_shortcode'.$this->camelize($shortcode));
49
+ }
50
+
51
+ }
app/code/community/Fishpig/Wordpress/Helper/Object.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Object extends Varien_Object
4
+ {
5
+ /**
6
+ * Returns an instance of a helper based on the helper key
7
+ *
8
+ * @param string $filter
9
+ * @return Fishpig_Wordpress_Helper_Filter_Abstract
10
+ */
11
+ protected function _getHelperClass($helperKey)
12
+ {
13
+ $registryKey = '_helper/'.$helperKey;
14
+
15
+ if ($helper = Mage::registry($registryKey)) {
16
+ return $helper;
17
+ }
18
+
19
+ if ($helper = $this->_createHelperClass($helperKey)) {
20
+ return $helper;
21
+ }
22
+
23
+ return null;
24
+ }
25
+
26
+ /**
27
+ * Returns an instance of a helper based on the helper key
28
+ *
29
+ * @param string $filter
30
+ * @return Fishpig_Wordpress_Helper_Filter_Abstract
31
+ */
32
+ protected function _createHelperClass($key)
33
+ {
34
+ $helperFile = Mage::getBaseDir('code') . DS . 'community' . DS . 'Fishpig' . DS . str_replace(' ', '/', ucwords(str_replace('/', ' ', str_replace('_', ' ', str_replace('/', '/Helper/', $key))))).'.php';
35
+ $helperClass = 'Fishpig_'.str_replace(' ', '_', ucwords(str_replace(array('/', '_'), array(' Helper ', ' '), $key)));
36
+
37
+ if (file_exists($helperFile)) {
38
+ try {
39
+ include_once($helperFile);
40
+ $helperInstance = new $helperClass;
41
+ Mage::register('_helper/'.$key, $helperInstance, true);
42
+ return $helperInstance;
43
+ }
44
+ catch (Exception $e) {
45
+ Mage::helper('wordpress')->load('Helper.Object->_createHelperClass: '.$e->getMessage());
46
+ return false;
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Convert an underscored string to a Class name
53
+ *
54
+ * @param string $str
55
+ * @return string
56
+ */
57
+ public function camelize($str)
58
+ {
59
+ return trim('_'.strtolower(substr($str, 0, 1)).substr($this->_camelize($str), 1), '-');
60
+ }
61
+
62
+ /**
63
+ * Wrapper for preg_match that adds extra functionality
64
+ *
65
+ * @param string $pattern
66
+ * @param string $value
67
+ * @param int $keyToReturn
68
+ * @return mixed
69
+ */
70
+ public function _match($pattern, $value, $keyToReturn = -1)
71
+ {
72
+ $result = array();
73
+ preg_match($pattern, $value, $result);
74
+
75
+ if ($keyToReturn == -1) {
76
+ return $result;
77
+ }
78
+ else if (isset($result[$keyToReturn])) {
79
+ return $result[$keyToReturn];
80
+ }
81
+
82
+ return null;
83
+ }
84
+
85
+ /**
86
+ * Wrapper for the Wordpress logger
87
+ *
88
+ * @param string $msg
89
+ */
90
+ public function log($msg)
91
+ {
92
+ return Mage::helper('wordpress')->log($msg);
93
+ }
94
+
95
+ /**
96
+ * Returns the relevant Wordpress helper.
97
+ *
98
+ * If no parameter passed, returns the default (Data.php) helper
99
+ *
100
+ */
101
+ public function _helper($helper = null)
102
+ {
103
+ return Mage::helper('wordpress')->_helper($helper);
104
+ }
105
+ }
app/code/community/Fishpig/Wordpress/Helper/Plugin/Abstract.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Helper_Plugin_Abstract extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Fishpig/Wordpress/Helper/Plugin/AllInOneSeo.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Plugin_AllInOneSeo extends Fishpig_Wordpress_Helper_Plugin_Abstract
4
+ {
5
+ public function isEnabled()
6
+ {
7
+ return Mage::getStoreConfigFlag('wordpress_blog/seo/aiosp_enabled');
8
+ }
9
+
10
+ public function getMetaFields()
11
+ {
12
+ return array('title', 'description', 'keywords');
13
+ }
14
+
15
+ public function getPluginOptions()
16
+ {
17
+ return unserialize($this->getCachedWpOption('aioseop_options'));
18
+ }
19
+
20
+ public function getPluginOption($key)
21
+ {
22
+ if ($options = $this->getPluginOptions()) {
23
+ $key = 'aiosp_'.$key;
24
+ if (isset($options[$key])) {
25
+ return $options[$key];
26
+ }
27
+ }
28
+ }
29
+
30
+ }
app/code/community/Fishpig/Wordpress/Helper/Post.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Post extends Fishpig_Wordpress_Helper_Abstract
4
+ {
5
+
6
+ /**
7
+ * Returns the permalink structure stored in the WP database
8
+ *
9
+ * @return string
10
+ */
11
+ public function getPermalinkStructure()
12
+ {
13
+ if (!$this->useGuidLinks()) {
14
+ return ltrim($this->getCachedWpOption('permalink_structure'), ' /');
15
+ }
16
+
17
+ return false;
18
+ }
19
+
20
+ /**
21
+ * Gets the WP permalink structure from the WP database
22
+ * Result is split by / and returned as an array
23
+ * If an empty array is returned, using default ?p={{post_id}} links
24
+ *
25
+ * @return array
26
+ */
27
+ public function getExplodedPermalinkStructure()
28
+ {
29
+ if ($structure = $this->getPermalinkStructure()) {
30
+ return array_filter(explode('/', $structure));
31
+ }
32
+
33
+ return false;
34
+ }
35
+
36
+ /**
37
+ * Returns TRUE is ?p=id links are being used
38
+ *
39
+ * @return bool
40
+ */
41
+ public function useGuidLinks()
42
+ {
43
+ return !trim($this->getCachedWpOption('permalink_structure'), '/ -');
44
+ }
45
+
46
+ public function getFullPermalinkStructure()
47
+ {
48
+ if (!isset($this->_cache['options']['full_permalink_structure'])) {
49
+
50
+ if ($this->useGuidLinks()) {
51
+ $this->_cache['options']['full_permalink_structure'] = array();
52
+ }
53
+ else {
54
+ $structure = $this->getPermalinkStructure();
55
+ $parts = preg_split("/(\/)/", $structure, -1, PREG_SPLIT_DELIM_CAPTURE);
56
+ $structure = array();
57
+
58
+ foreach($parts as $part) {
59
+ if ($result = preg_split("/(%[a-zA-Z0-9]{1,}%)/", $part, -1, PREG_SPLIT_DELIM_CAPTURE)) {
60
+ $results = array_filter(array_unique($result));
61
+
62
+ foreach($results as $result) {
63
+ array_push($structure, $result);
64
+ }
65
+ }
66
+ else {
67
+ $structure[] = $part;
68
+ }
69
+
70
+ }
71
+
72
+ $this->_cache['options']['full_permalink_structure'] = $structure;
73
+ }
74
+ }
75
+
76
+ return $this->_cache['options']['full_permalink_structure'];
77
+ }
78
+
79
+ /**
80
+ * return the permalink based on permalink structure
81
+ * which is defined in WP Admin
82
+ *
83
+ * @param Fishpig_Wordpress_Model_Post
84
+ * @return string
85
+ */
86
+ public function getPermalink(Fishpig_Wordpress_Model_Post $post)
87
+ {
88
+ if (!isset($this->_cache['permalink']['post'][$post->getId()])) {
89
+ if ($this->useGuidLinks()) {
90
+ $this->_cache['permalink']['post'][$post->getId()] = $this->getUrl('?p='.$post->getId());
91
+ }
92
+ else {
93
+ $structure = $this->getFullPermalinkStructure();
94
+
95
+ if (count($structure) > 0) {
96
+ $url = array();
97
+
98
+ foreach($structure as $segment) {
99
+ switch($segment) {
100
+ case '%year%': $url[] = $post->getPostDate('Y'); break;
101
+ case '%monthnum%': $url[] = $post->getPostDate('m'); break;
102
+ case '%day%': $url[] = $post->getPostDate('d'); break;
103
+ case '%hour%': $url[] = $post->getPostDate('H'); break;
104
+ case '%minute%': $url[] = $post->getPostDate('i'); break;
105
+ case '%second%': $url[] = $post->getPostDate('s'); break;
106
+ case '%postname%': $url[] = $post->getPostName(); break;
107
+ case '%post_id%': $url[] = $post->getId(); break;
108
+ case '%category%': $url[] =$this->_getPermalinkCategoryPortion($post); break;
109
+ default:
110
+ if (strlen(trim($segment, '%')) == (strlen($segment)-2)) {
111
+ $this->log("Unknown URI token in permalink structure: '{$segment}'");
112
+ }
113
+ else {
114
+ $url[] = $segment;
115
+ }
116
+
117
+ break;
118
+ }
119
+ }
120
+
121
+ $this->_cache['permalink']['post'][$post->getId()] = $this->getUrl(implode('', $url));
122
+ }
123
+ }
124
+ }
125
+
126
+ return $this->_cache['permalink']['post'][$post->getId()];
127
+ }
128
+
129
+ /**
130
+ * Generates the category portion of the URL for a post
131
+ *
132
+ * @param Fishpig_Wordpress_Model_Post $post
133
+ * @return string
134
+ */
135
+ protected function _getPermalinkCategoryPortion(Fishpig_Wordpress_Model_Post $post)
136
+ {
137
+ if ($category = $post->getParentCategory()) {
138
+ return trim($category->getSlug(), '/');
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Loads a post model based on the URI (array)
144
+ *
145
+ * @param string|array $explodedUri
146
+ * @return FIshpig_Wordpress_Model_Post
147
+ */
148
+ public function loadByPermalink($explodedUri)
149
+ {
150
+ if ($this->useGuidLinks()) {
151
+ return Mage::getModel('wordpress/post')->load($this->getParam('p', 0));
152
+ }
153
+
154
+ if (!is_array($explodedUri)) {
155
+ $explodedUri = explode('/', trim($explodedUri, '/'));
156
+ }
157
+
158
+ $structure = $this->getExplodedPermalinkStructure();
159
+
160
+ if ((isset($explodedUri[0])) && $explodedUri[0] == $this->getBlogRoute()) {
161
+ array_shift($explodedUri);
162
+ }
163
+
164
+ if (count($structure) == 0 && $postId = $this->getParam('p')) {
165
+ $post = Mage::getModel('wordpress/post')->load($postId);
166
+
167
+ if ($post->getId() > 0) {
168
+ return $post;
169
+ }
170
+ }
171
+ else if (count($structure) == count($explodedUri)) {
172
+ $postDate = array();
173
+ $posts = Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter();
174
+ $regSegment = "\%[a-zA-Z0-9]{1,}\%";
175
+ $regToken = "([a-zA-Z0-9 -.]{1,})";
176
+
177
+ foreach($structure as $key => $segment) {
178
+ if (preg_match("/{$regToken}{$regSegment}|{$regSegment}{$regToken}/", $segment, $results)) {
179
+ array_shift($results);
180
+ $results = array_filter($results);
181
+
182
+ foreach($results as $result) {
183
+ $segment = str_replace($result, '', $segment);
184
+ $explodedUri[$key] = str_replace($result, '', $explodedUri[$key]);
185
+ }
186
+
187
+ }
188
+
189
+ switch($segment) {
190
+ case '%year%': $postDate['1, 4'] = $explodedUri[$key]; break;
191
+ case '%monthnum%': $postDate['6, 2'] = $explodedUri[$key]; break;
192
+ case '%day%': $postDate['9, 2'] = $explodedUri[$key]; break;
193
+ case '%hour%': $postDate['12, 2'] = $explodedUri[$key]; break;
194
+ case '%minute%': $postDate['15, 2'] = $explodedUri[$key]; break;
195
+ case '%second%': $postDate['18, 2'] = $explodedUri[$key]; break;
196
+ case '%postname%': $posts->addFieldToFilter('post_name', $explodedUri[$key]); break;
197
+ case '%post_id%': $posts->addFieldToFilter('ID', $explodedUri[$key]); break;
198
+ case '%category%': $posts->addCategorySlugFilter($explodedUri[$key]); break;
199
+ }
200
+ }
201
+
202
+ if (count($postDate) > 0) {
203
+ $sql = array();
204
+
205
+ foreach($postDate as $offsets => $value) {
206
+ $sql[] = $this->_helper('db')->getWordpressRead()->quoteInto("SUBSTRING(post_date, {$offsets}) = ?", $value);;
207
+ }
208
+
209
+ $posts->getSelect()->where(implode(' AND ' , $sql));
210
+ }
211
+
212
+ if ($posts->count() > 0) {
213
+ return $posts->getFirstItem();
214
+ }
215
+ }
216
+
217
+ return false;
218
+ }
219
+
220
+ public function getTagsUrl()
221
+ {
222
+ return $this->getUrl('tags');
223
+ }
224
+
225
+ }
app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Abstract.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Helper_Post_Content_Shortcode_Abstract extends Varien_Object
4
+ {
5
+ protected $_shortcode = null;
6
+
7
+ public function setShortcode($shortcode)
8
+ {
9
+ $this->_shortcode = $shortcode;
10
+ return $this;
11
+ }
12
+
13
+ public function setContent($content)
14
+ {
15
+ $this->_content = $content;
16
+ return $this;
17
+ }
18
+
19
+ abstract function applyFilter();
20
+
21
+ protected function _explode($shortcode, $content, $splitTags = false)
22
+ {
23
+ if ($splitTags) {
24
+ $pattern = "/(\[" . $shortcode . "[^\]]*\])|(\[\/".$shortcode . "\])/";
25
+ }
26
+ else {
27
+ $pattern = "/(\[" . $shortcode . "[^\]]*\].*?\[\/".$shortcode . "\])/";
28
+ }
29
+
30
+ $parts = preg_split($pattern, $content, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
31
+
32
+ foreach($parts as $key => $part) {
33
+ if (strpos($part, "[$shortcode") !== false) {
34
+ $parts[$key] = array('is_opening_tag' => true, 'is_closing_tag' => false, 'content' => $part);
35
+ }
36
+ else if (strpos($part, "[/$shortcode]") !== false) {
37
+ $parts[$key] = array('is_opening_tag' => false, 'is_closing_tag' => true, 'content' => $part);
38
+ }
39
+ else {
40
+ $parts[$key] = array('is_opening_tag' => false, 'is_closing_tag' => false, 'content' => $part);
41
+ }
42
+ }
43
+
44
+ return $parts;
45
+ }
46
+
47
+ protected function _match($pattern, $value, $keyToReturn = -1)
48
+ {
49
+ $result = array();
50
+ preg_match($pattern, $value, $result);
51
+
52
+ if ($keyToReturn == -1) {
53
+ return $result;
54
+ }
55
+ else if (isset($result[$keyToReturn])) {
56
+ return $result[$keyToReturn];
57
+ }
58
+
59
+ return null;
60
+ }
61
+ }
app/code/community/Fishpig/Wordpress/Helper/Post/Content/Shortcode/Caption.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Helper_Post_Content_Shortcode_Caption extends Fishpig_Wordpress_Helper_Post_Content_Shortcode_Abstract
4
+ {
5
+
6
+ public function applyFilter()
7
+ {
8
+ $parts = $this->_explode('caption', $this->_content);
9
+ $content = '';
10
+
11
+ foreach($parts as $part) {
12
+ $buffer = $part['content'];
13
+
14
+ if ($part['is_opening_tag']) {
15
+
16
+ $id = $this->_match("/id=['\"]([^'\"]+)['\"]/", $buffer, 1);
17
+ $align = str_replace("align", "", $this->_match("/align=['\"](align[^'\"]+)['\"]/", $buffer, 1));
18
+ $width = $this->_match("/width=['\"]([0-9]+)['\"]/", $buffer, 1);
19
+ $caption = $this->_match("/caption=['\"]([^'\"]+)['\"]/", $buffer, 1);
20
+ $innerHtml = $this->_match("/\[caption[^\]]*\](.*?)\[\/caption\]/", $buffer, 1);
21
+ $part['content'] = "<div id=\"$id\" class=\"$align\" style=\"width:".($width+10)."px;\">$innerHtml<p class=\"wp-caption\">$caption</div>";
22
+
23
+ }
24
+
25
+ $content .= $part['content'];
26
+ }
27
+
28
+ return $content;
29
+ }
30
+
31
+ }
app/code/community/Fishpig/Wordpress/Model/Abstract.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Abstract extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Initialise the model to the correct model type
7
+ * The below code calculates the model type based on the class name
8
+ * This is much quicker than writing it manually for each model
9
+ */
10
+ public function _construct()
11
+ {
12
+ $this->_init(str_replace('_model_', '/', strtolower(substr(get_class($this), strlen('Fishpig_')))));
13
+ }
14
+
15
+ /**
16
+ * Load a model based on an attribute and value
17
+ *
18
+ * @param string $attribute
19
+ * @param string $value
20
+ * @return Fishpig_Wordpress_Model_Abstract
21
+ */
22
+ public function loadByAttribute($attribute, $value)
23
+ {
24
+ return $this->load($value, $attribute);
25
+ }
26
+
27
+ /**
28
+ * Load a model based on several attributes
29
+ * The first model found will be returned, not a whole collection
30
+ *
31
+ * @param array $attributes
32
+ * @return Fishpig_Wordpress_Model_Abstract
33
+ */
34
+ public function loadByAttributes(array $attributes)
35
+ {
36
+ return $this->getResource()->loadByAttributes($attributes);
37
+ }
38
+
39
+ /**
40
+ * Load one of the module helpers
41
+ * If no parameter is passed, Data.php is loaded
42
+ *
43
+ * @return Fishpig_Wordpress_Helper_Abstract
44
+ */
45
+ public function _helper($helper = null)
46
+ {
47
+ if ($helper != null) {
48
+ $helper = '/' . $helper;
49
+ }
50
+
51
+ return Mage::helper('wordpress' . $helper);
52
+ }
53
+
54
+ /**
55
+ * Returns the Wordpress URL
56
+ *
57
+ * @return string
58
+ */
59
+ public function getWpUrl($extra = '')
60
+ {
61
+ return $this->_helper()->getUrl($extra);
62
+ }
63
+
64
+ /**
65
+ * Prefix the given variable with the Wordpress table prefix
66
+ *
67
+ * @return string
68
+ */
69
+ public function getTableName($table)
70
+ {
71
+ return $this->_helper('db')->getTableName($table);
72
+ }
73
+
74
+ public function formatUrlKey($string, $splitter = '-')
75
+ {
76
+ $string = preg_replace('#[^0-9a-z]+#i', $splitter, $string);
77
+ $string = strtolower($string);
78
+ $string = trim($string, '-');
79
+
80
+ return $string;
81
+ }
82
+ }
app/code/community/Fishpig/Wordpress/Model/Admin/User.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Admin_User extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/admin_user');
8
+ }
9
+
10
+ /**
11
+ * Decrypts encrypted details once they are loaded from DB
12
+ */
13
+ protected function _afterLoad()
14
+ {
15
+ parent::_afterLoad();
16
+
17
+ foreach( array('username', 'password') as $field) {
18
+ $this->setData($field, Mage::helper('core')->decrypt($this->getData($field)));
19
+ }
20
+
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * Encrypts information before saving to DB
26
+ */
27
+ protected function _beforeSave()
28
+ {
29
+ foreach( array('username', 'password') as $field) {
30
+ $this->setData($field, Mage::helper('core')->encrypt($this->getData($field)));
31
+ }
32
+
33
+ return parent::_beforeSave();
34
+ }
35
+ }
app/code/community/Fishpig/Wordpress/Model/Archive.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Archive extends Varien_Object
4
+ {
5
+ /**
6
+ * Load an archive model by it's YYYY/MM
7
+ * EG: 2010/06
8
+ *
9
+ * @param string $value
10
+ */
11
+ public function load($value)
12
+ {
13
+ $this->setId($value);
14
+ $this->setName(date('F Y', strtotime($value.'/01 01:01:01')));
15
+ return $this;
16
+ }
17
+
18
+ /**
19
+ * Get the archive page URL
20
+ *
21
+ * @return string
22
+ */
23
+ public function getUrl()
24
+ {
25
+ return Mage::helper('wordpress')->getUrl($this->getId());
26
+ }
27
+
28
+ public function hasPosts()
29
+ {
30
+ if ($this->hasData('post_count')) {
31
+ return $this->getPostCount() > 0;
32
+ }
33
+
34
+ return $this->getPostCollection()->count() > 0;
35
+ }
36
+
37
+ public function getPostCollection()
38
+ {
39
+ if (!$this->hasData('post_collection')) {
40
+ $collection = Mage::getResourceModel('wordpress/post_collection')
41
+ ->addIsPublishedFilter()
42
+ ->addArchiveDateFilter($this->getId())
43
+ ->setOrderByPostDate();
44
+
45
+ $this->setData('post_collection', $collection);
46
+ }
47
+
48
+ return $this->getData('post_collection');
49
+ }
50
+ }
app/code/community/Fishpig/Wordpress/Model/Category/Abstract.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Category_Abstract extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ abstract public function getPostCollection();
6
+
7
+ /**
8
+ * Defines what type of category this is
9
+ *
10
+ * @var string (category / link_category)
11
+ */
12
+ protected $_categoryType = '';
13
+
14
+ public function getId()
15
+ {
16
+ return $this->getData('term_id');
17
+ }
18
+
19
+ /**
20
+ * Get this category's parent category
21
+ *
22
+ * @return Fishpig_Wordpress_Model_Category_Abstract
23
+ */
24
+ public function getParentCategory()
25
+ {
26
+ return Mage::getModel($this->getResourceName())->load($this->getParent());
27
+ }
28
+
29
+ /**
30
+ * Load a category model based on an attribute and value
31
+ *
32
+ * @return Fishpig_Wordpress_Model_Category_Abstract
33
+ */
34
+ public function loadByAttribute($attribute, $value)
35
+ {
36
+ return $this->getResource()->loadByAttribute($attribute, $value, $this->_categoryType);
37
+ }
38
+
39
+
40
+
41
+ /**
42
+ * To load a category model, several tables must be joined with identical field names
43
+ * To combat the ambiguity, the table alias is prefixed to the field name we are looking for
44
+ *
45
+ * @param int $id
46
+ * @param string $field
47
+ * @return Fishpig_Wordpress_Model_Category_Abstract
48
+ */
49
+ public function load($id, $field=null)
50
+ {
51
+ if ($field == null) {
52
+ $field = "main_table.".$this->getResource()->getIdFieldName();
53
+ }
54
+
55
+ return $this->loadByAttribute($field, $id);
56
+ }
57
+
58
+ /**
59
+ * Get the Category URL
60
+ *
61
+ * @return string
62
+ */
63
+ public function getUrl()
64
+ {
65
+ return rtrim($this->getWpUrl('category/' . $this->getSlug()), '/') . '/';
66
+ }
67
+
68
+ /**
69
+ * Returns the amount of posts related to this object
70
+ *
71
+ * @return int
72
+ */
73
+ public function getPostCount()
74
+ {
75
+ return count($this->getPostCollection());
76
+ }
77
+
78
+ }
app/code/community/Fishpig/Wordpress/Model/Image.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Image extends Fishpig_Wordpress_Model_Post_Attachment_Abstract
4
+ {
5
+ public function getThumbnailImage()
6
+ {
7
+ return $this->_getImagePath('thumbnail');
8
+ }
9
+
10
+ public function getMediumImage()
11
+ {
12
+ return $this->_getImagePath('medium');
13
+ }
14
+
15
+ public function getLargeImage()
16
+ {
17
+ return $this->_getImagePath('large');
18
+ }
19
+
20
+ public function getPostThumbnailImage()
21
+ {
22
+ return $this->_getImagePath('post-thumbnail');
23
+ }
24
+
25
+ public function getAvailableImage()
26
+ {
27
+ if ($sizes = $this->getSizes()) {
28
+ foreach($sizes as $type => $data) {
29
+ return $this->_getImagePath($type);
30
+ }
31
+ }
32
+ else {
33
+ return $this->_getImagePath();
34
+ }
35
+ }
36
+
37
+ protected function _getImagePath($type = null)
38
+ {
39
+ $filename = null;
40
+
41
+ if ($type == null) {
42
+ $filename = basename($this->getFile());
43
+ }
44
+ else {
45
+ $sizes = $this->getSizes();
46
+
47
+ if (isset($sizes[$type]['file'])) {
48
+ $filename = $sizes[$type]['file'];
49
+ }
50
+ }
51
+
52
+ if (!$filename) {
53
+ return null;
54
+ }
55
+
56
+ return $this->_getThisImageUrl().$filename;
57
+ }
58
+
59
+ protected function _getThisImageUrl()
60
+ {
61
+ return $this->_helper()->getBaseUrl('wp-content/uploads/')
62
+ . $this->_helper()->formatDate($this->getPostDate(), 'Y/m/');
63
+ }
64
+
65
+ }
66
+
app/code/community/Fishpig/Wordpress/Model/Link.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Link extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+
6
+
7
+ }
app/code/community/Fishpig/Wordpress/Model/Link/Category.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Link_Category extends Fishpig_Wordpress_Model_Category_Abstract
4
+ {
5
+ protected $_categoryType = 'link_category';
6
+
7
+ public function getLinks()
8
+ {
9
+ return Mage::getModel('wordpress/link')
10
+ ->getCollection()
11
+ ->addCategoryIdFilter($this->getId());
12
+ }
13
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Abstract.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Abstract extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ /**
6
+ * Load model based on attributes
7
+ *
8
+ */
9
+ public function loadByAttributes(array $attributes)
10
+ {
11
+ $collection = $this->getCollection();
12
+
13
+ foreach ($attributes as $attribute => $value) {
14
+ if (is_array($value)) {
15
+ foreach($value as $op => $val) {
16
+ $collection->addFieldToFilter($attribute, array($op => $val));
17
+ }
18
+ }
19
+ else {
20
+ $collection->addFieldToFilter($attribute, array('eq' => $value));
21
+ }
22
+ }
23
+
24
+ return $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
25
+ }
26
+
27
+ /**
28
+ * Returns a collection of current model type
29
+ *
30
+ */
31
+ public function getCollection()
32
+ {
33
+ return Mage::getModel($this->_getModelType())->getCollection();
34
+ }
35
+
36
+ /**
37
+ * Returns the current model type
38
+ *
39
+ */
40
+ protected function _getModelType()
41
+ {
42
+ return $this->_resourceModel.'/' . $this->_mainTable;
43
+ }
44
+
45
+ /**
46
+ * Writing to the WP database is current disabled
47
+ *
48
+ * This can be added in future releases easily if enough people want it
49
+ *
50
+ */
51
+ protected function _getWriteAdapter()
52
+ {
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * Returns the appropriate read adapater
58
+ *
59
+ * If WP/Mage share a database, the Magento adapter is returned
60
+ * If separate databases, a WP specific adapter is returned
61
+ *
62
+ */
63
+ public function _getReadAdapter()
64
+ {
65
+ if ($this->_helper()->isSameDatabase()) {
66
+ return Mage::getSingleton('core/resource')->getConnection('core_read');
67
+ }
68
+
69
+ return parent::_getReadAdapter();
70
+ }
71
+
72
+ /**
73
+ * Generic abstract functions
74
+ *
75
+ */
76
+ public function _helper($helper = null)
77
+ {
78
+ if ($helper != null) {
79
+ $helper = '/' . $helper;
80
+ }
81
+
82
+ return Mage::helper('wordpress' . $helper);
83
+ }
84
+
85
+ public function getWpUrl($extra = '')
86
+ {
87
+ return $this->_helper()->getUrl($extra);
88
+ }
89
+
90
+ public function getTableName($table)
91
+ {
92
+ return $this->_helper('db')->getTableName($table);
93
+ }
94
+
95
+ /**
96
+ * Crafts an SQL statement by escaping $value into $text
97
+ *
98
+ * @param string $text
99
+ * @param string $value
100
+ * @param string type
101
+ * @return string
102
+ */
103
+ public function quoteInto($text, $value, $type = null)
104
+ {
105
+ return $this->_helper('db')->getWordpressRead()->quoteInto($text, $value, $type = null);
106
+ }
107
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Admin_User extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/admin_user', 'autologin_id');
8
+ }
9
+
10
+ /**
11
+ * Custom load SQL
12
+ *
13
+ * @param string $field - field to match $value to
14
+ * @param string|int $value - $value to load record based on
15
+ * @param Mage_Core_Model_Abstract $object - object we're trying to load to
16
+ */
17
+ protected function _getLoadSelect($field, $value, $object)
18
+ {
19
+ $select = $this->_getReadAdapter()->select()
20
+ ->from(array('e' => $this->getMainTable()))
21
+ ->where("e.{$field}=?", $value)
22
+ ->where('user_id=?', Mage::getSingleton('admin/session')->getUser()->getId())
23
+ ->limit(1);
24
+
25
+ return $select;
26
+ }
27
+
28
+ protected function _getWriteAdapter()
29
+ {
30
+ return Mage::getSingleton('core/resource')->getConnection('core_write');
31
+ }
32
+
33
+ public function _getReadAdapter()
34
+ {
35
+ return Mage::getSingleton('core/resource')->getConnection('core_read');
36
+ }
37
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Admin/User/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Admin_User_Collection extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/admin_user');
8
+ }
9
+ }
10
+
app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Abstract.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Category_Abstract extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function loadByAttribute($attribute, $value, $type = null)
6
+ {
7
+ $tbl_tax = $this->getTableName('term_taxonomy');
8
+ $tbl_rel = $this->getTableName('term_relationships');
9
+ $collection = $this->getCollection();
10
+
11
+ $collection->getSelect()->setPart('columns', array());
12
+ $collection->getSelect()->join($tbl_tax, "`main_table`.`term_id` = `$tbl_tax`.`term_id`", array('main_table.term_id', 'category_type' => 'taxonomy', 'main_table.name', 'main_table.slug', 'description', 'parent'));
13
+ $collection->getSelect()->join($tbl_rel, "`$tbl_rel`.`term_taxonomy_id` = `$tbl_tax`.`term_taxonomy_id` ", '');
14
+ $collection->getSelect()->where("$attribute = '$value'");
15
+
16
+ if ($type != null) {
17
+ $collection->getSelect()->where("`$tbl_tax`.`taxonomy` = '$type'");
18
+ }
19
+
20
+ return $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
21
+ }
22
+
23
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Category/Collection/Abstract.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Category_Collection_Abstract extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ /**
6
+ * Defines the type of category
7
+ * Can be either category or link_category
8
+ *
9
+ * @var string
10
+ */
11
+ protected $_categoryType = 'category';
12
+
13
+ /**
14
+ * Perform the joins necessary to create a full category record
15
+ */
16
+ protected function _initSelect()
17
+ {
18
+ return $this->getSelect()
19
+ ->distinct()
20
+ ->from(array('main_table' => $this->getResource()->getMainTable()))
21
+ ->join(
22
+ array('tax' => $this->getTableName('term_taxonomy')),
23
+ $this->quoteInto("`tax`.`taxonomy` = ?", $this->_categoryType)
24
+ . " AND `main_table`.`term_id` = `tax`.`term_id`",
25
+ array('parent_id' => 'parent', 'description')
26
+ )
27
+ ->joinLeft(
28
+ array('rel' => $this->getTableName('term_relationships')),
29
+ "`tax`.`term_taxonomy_id` = `rel`.`term_taxonomy_id`",
30
+ ''
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Filters the collection by parent
36
+ * If 0 is passed, root categories will be returned
37
+ *
38
+ * @var int $parentId
39
+ */
40
+ public function addParentIdFilter($parentId)
41
+ {
42
+ return $this->addFieldToFilter('parent', $parentId);
43
+ }
44
+
45
+ /**
46
+ * Filter the collection by a post ID
47
+ *
48
+ * @param int $postId
49
+ */
50
+ public function addPostIdFilter($postId)
51
+ {
52
+ return $this->addFIeldToFilter('object_id', $postId);
53
+ }
54
+
55
+ /**
56
+ * Filter the collection by a post model
57
+ * This is just a wrapper for self::addPostIdFilter
58
+ *
59
+ * @param Fishpig_Wordpress_Model_Post $post
60
+ */
61
+ public function addPostFilter(Fishpig_Wordpress_Model_Post $post)
62
+ {
63
+ return $this->addPostIdFilter($post->getId());
64
+ }
65
+
66
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Collection/Abstract.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Collection_Abstract extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ /**
6
+ * Forces the collection to contain no records
7
+ */
8
+ public function forceNoResults()
9
+ {
10
+ $this->getSelect()->where('1=2');
11
+ return $this;
12
+ }
13
+
14
+ /**
15
+ * Returns a helper from this module
16
+ * By default the Data helper is returned
17
+ *
18
+ * @param string $helper
19
+ * @return Fishpig_Wordpress_Helper_Abstract
20
+ */
21
+ public function _helper($helper = null)
22
+ {
23
+ if ($helper != null) {
24
+ $helper = '/' . $helper;
25
+ }
26
+
27
+ return Mage::helper('wordpress' . $helper);
28
+ }
29
+
30
+ /**
31
+ * Returns the Wordpress URL
32
+ *
33
+ * @param string $extra
34
+ * @return string
35
+ */
36
+ public function getWpUrl($extra = '')
37
+ {
38
+ return $this->_helper()->getUrl($extra);
39
+ }
40
+
41
+ /**
42
+ * Returns a Wordpress table name
43
+ *
44
+ * @param string $table
45
+ * @return string
46
+ */
47
+ public function getTableName($table)
48
+ {
49
+ return $this->_helper('db')->getTableName($table);
50
+ }
51
+
52
+ /**
53
+ * Crafts an SQL statement by escaping $value into $text
54
+ *
55
+ * @param string $text
56
+ * @param string $value
57
+ * @param string type
58
+ * @return string
59
+ */
60
+ public function quoteInto ($text, $value, $type = null)
61
+ {
62
+ return $this->_conn->quoteInto($text, $value, $type = null);
63
+ }
64
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Image.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Image extends Fishpig_Wordpress_Model_Mysql4_Post_Attachment_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/image', 'ID');
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Image/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Image_Collection extends Fishpig_Wordpress_Model_Mysql4_Post_Attachment_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/image');
8
+ }
9
+
10
+ public function load($printQuery = false, $logQuery = false)
11
+ {
12
+ $this->getSelect()->where("post_mime_type LIKE 'image%'");
13
+ return parent::load($printQuery, $logQuery);
14
+ }
15
+
16
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Link.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Link extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/link', 'link_id');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Link_Category extends Fishpig_Wordpress_Model_Mysql4_Category
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/link_category', 'term_id');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Category/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Link_Category_Collection extends Fishpig_Wordpress_Model_Mysql4_Category_Collection
4
+ {
5
+ protected $_categoryType = 'link_category';
6
+
7
+ public function _construct()
8
+ {
9
+ $this->_init('wordpress/link_category');
10
+ }
11
+
12
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Link/Collection.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Link_Collection extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/link');
8
+ }
9
+
10
+ public function addCategoryIdFilter($categoryId)
11
+ {
12
+ $tbl_tax = $this->getTableName('term_taxonomy');
13
+ $tbl_rel = $this->getTableName('term_relationships');
14
+
15
+ $this->getSelect()->join($tbl_rel, "`$tbl_rel`.`object_id` = `main_table`.`link_id`", '');
16
+ $this->getSelect()->join($tbl_tax, "`$tbl_tax`.`term_taxonomy_id` = `$tbl_rel`.`term_taxonomy_id` AND `$tbl_tax`.`term_id` = $categoryId AND `$tbl_tax`.`taxonomy` = 'link_category'", '');
17
+ return $this;
18
+ }
19
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Option.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Option extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/option', 'option_id');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Option/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Option_Collection extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/option');
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Page.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Page extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/page', 'ID');
8
+ }
9
+
10
+ public function loadBySlug(array $explodedUri)
11
+ {
12
+ try {
13
+ if ($explodedUri = $this->_helper()->explodeUri($explodedUri)) {
14
+ $parentId = 0;
15
+
16
+ foreach($explodedUri as $pageName) {
17
+ $sql = $this->quoteInto("SELECT ID FROM wp_posts WHERE post_name = ? AND post_type = 'page' AND post_status = 'publish' AND post_parent = {$parentId}", $pageName);
18
+
19
+ if (!($parentId = $this->_helper('db')->getWordpressRead()->fetchOne($sql))) {
20
+ throw new Exception('Invalid chain link');
21
+ }
22
+ }
23
+
24
+ return Mage::getModel('wordpress/page')->load($parentId);
25
+ }
26
+ }
27
+ catch (Exception $e) { }
28
+
29
+ return false;
30
+ }
31
+
32
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Page/Collection.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Page_Collection extends Fishpig_Wordpress_Model_Mysql4_Post_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/page');
8
+ }
9
+
10
+ /**
11
+ * Adds a published filter to collection
12
+ */
13
+ public function addIsPublishedFilter()
14
+ {
15
+ return $this->addStatusFilter('publish');
16
+ }
17
+
18
+ /**
19
+ * Adds a filter to the status column
20
+ *
21
+ * @param string $status
22
+ */
23
+ public function addStatusFilter($status)
24
+ {
25
+ $this->getSelect() ->where($this->quoteInto('`main_table`.`post_status` =?', $status));
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Filter the collection by an author ID
31
+ *
32
+ * @param int $authorId
33
+ */
34
+ public function addAuthorIdFilter($authorId)
35
+ {
36
+ return $this->addFieldToFilter('post_author', $authorId);
37
+ }
38
+
39
+ /**
40
+ * Orders the collection by post date
41
+ *
42
+ * @param string $dir
43
+ */
44
+ public function setOrderByPostDate($dir = 'desc')
45
+ {
46
+ return $this->setOrder('post_date', $dir);
47
+ }
48
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post', 'ID');
8
+ }
9
+
10
+ /**
11
+ * Custom load SQL
12
+ *
13
+ * @param string $field - field to match $value to
14
+ * @param string|int $value - $value to load record based on
15
+ * @param Mage_Core_Model_Abstract $object - object we're trying to load to
16
+ */
17
+ protected function _getLoadSelect($field, $value, $object)
18
+ {
19
+ $select = $this->_getReadAdapter()->select()
20
+ ->from(array('e' => $this->getMainTable()))
21
+ ->where("e.{$field}=?", $value);
22
+
23
+ if ($this->_helper('plugin_allInOneSeo')->isEnabled()) {
24
+ foreach($this->_helper('plugin_allInOneSeo')->getMetaFields() as $field) {
25
+ $table = 'aioseop_'.$field;
26
+ $select->joinLeft(
27
+ array($table => $this->getTableName('postmeta')),
28
+ "{$table}.post_id = e.ID AND ".$this->quoteInto("{$table}.meta_key=?", "_aioseop_{$field}"),
29
+ array('meta_'.$field => 'meta_value')
30
+ );
31
+ }
32
+ }
33
+
34
+
35
+ $select->limit(1);
36
+
37
+ return $select;
38
+ }
39
+
40
+ public function getPostTags(Fishpig_Wordpress_Model_Post $post)
41
+ {
42
+ return Mage::getResourceModel('wordpress/post_tag_collection')
43
+ ->addPostIdFilter($post->getId());
44
+ }
45
+
46
+ public function getParentCategories(Fishpig_Wordpress_Model_Post $post)
47
+ {
48
+ return Mage::getResourceModel('wordpress/post_category_collection')
49
+ ->addPostIdFilter($post->getId());
50
+ }
51
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Abstract.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Post_Attachment_Abstract extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+
6
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Attachment/Collection/Abstract.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Attachment_Collection_Abstract extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function load($printQuery = false, $logQuery = false)
6
+ {
7
+ $this->getSelect()->where("post_type = 'attachment'")->where("post_mime_type LIKE 'image%'");
8
+ return parent::load($printQuery, $logQuery);
9
+ }
10
+
11
+ public function setParent($parentId = 0)
12
+ {
13
+ $this->getSelect()->where("post_parent = $parentId");
14
+ return $this;
15
+ }
16
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Category extends Fishpig_Wordpress_Model_Mysql4_Category_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post_category', 'term_id');
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Category/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Category_Collection extends Fishpig_Wordpress_Model_Mysql4_Category_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post_category');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Collection extends Fishpig_Wordpress_Model_Mysql4_Post_Collection_Abstract
4
+ {
5
+ /**
6
+ * True if term tables have been joined
7
+ * This stops the term tables being joined repeatedly
8
+ *
9
+ * @var array()
10
+ */
11
+ protected $_termTablesJoined = array();
12
+
13
+ public function _construct()
14
+ {
15
+ $this->_init('wordpress/post');
16
+ }
17
+
18
+ /**
19
+ * Filters the collection by an array of post ID's and category ID's
20
+ * When filtering by a category ID, all posts from that category will be returned
21
+ * If you change the param $operator to AND, only posts that are in a category specified in
22
+ * $categoryIds and $postIds will be returned
23
+ *
24
+ * @param mixed $postIds
25
+ * @param mixed $categoryIds
26
+ * @param string $operator
27
+ */
28
+ public function addCategoryAndPostIdFilter($postIds, $categoryIds, $operator = 'OR')
29
+ {
30
+ if (!is_array($postIds)) {
31
+ $postIds = array($postIds);
32
+ }
33
+
34
+ if (!is_array($categoryIds)) {
35
+ $categoryIds = array($categoryIds);
36
+ }
37
+
38
+ $postSql = $this->quoteInto("`main_table`.`ID` IN (?)", $postIds);
39
+ $categorySql = $this->quoteInto("`tax`.`term_id` IN (?)", $categoryIds);
40
+
41
+ $this->joinTermTables('category');
42
+
43
+ if (count($postIds) > 0 && count($categoryIds) > 0) {
44
+ $this->getSelect()->where("{$postSql} {$operator} {$categorySql}");
45
+ }
46
+ else if (count($postIds) > 0) {
47
+ $this->getSelect()->where("{$postSql}");
48
+ }
49
+ else if (count($categoryIds) > 0) {
50
+ $this->getSelect()->where("{$categorySql}");
51
+ }
52
+
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Filters the collection by a term ID and type
58
+ *
59
+ * @param int|array $termId
60
+ * @param string $type
61
+ */
62
+ public function addTermIdFilter($termId, $type)
63
+ {
64
+ if (is_array($termId)) {
65
+ $whereSql = $this->quoteInto("`tax`.`term_id` IN (?)", $termId);
66
+ }
67
+ else {
68
+ $whereSql = $this->quoteInto("`tax`.`term_id` = ?", $termId);
69
+ }
70
+
71
+ $this->joinTermTables($type)
72
+ ->getSelect()
73
+ ->where($whereSql);
74
+
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Joins the category tables to the collection
80
+ * This allows filtering by category
81
+ */
82
+ public function joinTermTables($type)
83
+ {
84
+ if (!isset($this->_termTablesJoined[$type])) {
85
+ $tableTax = $this->getTableName('term_taxonomy');
86
+ $tableTermRel = $this->getTableName('term_relationships');
87
+ $tableTerms = $this->getTableName('terms');
88
+
89
+ $this->getSelect()->join(array('rel' => $tableTermRel), "`rel`.`object_id`=`main_table`.`ID`", '');
90
+ $this->getSelect()->join(array('tax' => $tableTax), "`tax`.`term_taxonomy_id`=`rel`.`term_taxonomy_id` AND `tax`.`taxonomy`='{$type}'", '');
91
+ $this->getSelect()->join(array('terms' => $tableTerms), "`terms`.`term_id` = `tax`.`term_id`", '');
92
+ $this->getSelect()->distinct();
93
+
94
+ $this->_termTablesJoined[$type] = true;
95
+ }
96
+
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * Filters the collection by a category slug
102
+ *
103
+ * @param string $categorySlug
104
+ */
105
+ public function addCategorySlugFilter($categorySlug)
106
+ {
107
+ return $this->joinTermTables('category')
108
+ ->addFieldToFilter('slug', $categorySlug);
109
+ }
110
+
111
+ /**
112
+ * Filter the collection by a category ID
113
+ *
114
+ * @param int $categoryId
115
+ * @return $this
116
+ */
117
+ public function addCategoryIdFilter($categoryId)
118
+ {
119
+ return $this->addTermIdFilter($categoryId, 'category');
120
+ }
121
+
122
+ /**
123
+ * Filter the collection by a tag ID
124
+ *
125
+ * @param int $categoryId
126
+ * @return $this
127
+ */
128
+ public function addTagIdFilter($tagId)
129
+ {
130
+ return $this->addTermIdFilter($tagId, 'post_tag');
131
+ }
132
+
133
+ /**
134
+ * Filter the collection by an author ID
135
+ *
136
+ * @param int $authorId
137
+ */
138
+ public function addAuthorIdFilter($authorId)
139
+ {
140
+ return $this->addFieldToFilter('post_author', $authorId);
141
+ }
142
+
143
+ /**
144
+ * Orders the collection by post date
145
+ *
146
+ * @param string $dir
147
+ */
148
+ public function setOrderByPostDate($dir = 'desc')
149
+ {
150
+ return $this->setOrder('post_date', $dir);
151
+ }
152
+
153
+ /**
154
+ * Filters the collection with an archive date
155
+ * EG: 2010/10
156
+ *
157
+ * @param string $archiveDate
158
+ */
159
+ public function addArchiveDateFilter($archiveDate)
160
+ {
161
+ $this->getSelect()->where($this->quoteInto("`main_table`.`post_date` LIKE ?", str_replace("/", "-", $archiveDate)."-%"));
162
+ return $this;
163
+ }
164
+ }
165
+
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Collection/Abstract.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Mysql4_Post_Collection_Abstract extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ /**
6
+ * Return the current post type (post || page)
7
+ *
8
+ * @return string
9
+ */
10
+ protected function _getPostType()
11
+ {
12
+ return trim(substr($this->getResourceModelName(), strpos($this->getResourceModelName(), '/')), '/');
13
+ }
14
+
15
+ /**
16
+ * Ensures that only posts and not pages are returned
17
+ * WP stores posts and pages in the same DB table
18
+ */
19
+ protected function _initSelect()
20
+ {
21
+ parent::_initSelect();
22
+ $this->getSelect()
23
+ ->where($this->quoteInto("`main_table`.`post_type`=?", $this->_getPostType()));
24
+
25
+ if ($this->_helper('plugin_allInOneSeo')->isEnabled()) {
26
+ foreach($this->_helper('plugin_allInOneSeo')->getMetaFields() as $field) {
27
+ $table = 'aioseop_'.$field;
28
+ $this->getSelect()->joinLeft(
29
+ array($table => $this->getTableName('postmeta')),
30
+ "{$table}.post_id = main_table.ID AND ".$this->quoteInto("{$table}.meta_key=?", "_aioseop_{$field}"),
31
+ array('meta_'.$field => 'meta_value')
32
+ );
33
+ }
34
+ }
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Adds a published filter to collection
41
+ */
42
+ public function addIsPublishedFilter()
43
+ {
44
+ return $this->addStatusFilter('publish');
45
+ }
46
+
47
+ /**
48
+ * Adds a filter to the status column
49
+ *
50
+ * @param string $status
51
+ */
52
+ public function addStatusFilter($status)
53
+ {
54
+ $this->getSelect() ->where($this->quoteInto('`main_table`.`post_status` =?', $status));
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Sets the current page based on the URL value
60
+ */
61
+ public function setPageFromUrl()
62
+ {
63
+ $pageId = Mage::app()->getRequest()->getParam('page', 1);
64
+ return $this->setCurPage($pageId);
65
+ }
66
+
67
+ /**
68
+ * Sets the number of posts per page
69
+ * If no value is passed, the number of posts is taken from the WP Admin Config
70
+ *
71
+ * @param int $postsPerPage
72
+ */
73
+ public function setPostsPerPage($postsPerPage = null)
74
+ {
75
+ if (is_null($postsPerPage)) {
76
+ $postsPerPage = Mage::app()->getRequest()->getParam('limit', $this->_helper()->getCachedWpOption('posts_per_page', 10));
77
+ }
78
+
79
+ return $this->setPageSize($postsPerPage);
80
+ }
81
+
82
+ /**
83
+ * Filter the collection by an author ID
84
+ *
85
+ * @param int $authorId
86
+ */
87
+ public function addAuthorIdFilter($authorId)
88
+ {
89
+ return $this->addFieldToFilter('post_author', $authorId);
90
+ }
91
+
92
+ /**
93
+ * Orders the collection by post date
94
+ *
95
+ * @param string $dir
96
+ */
97
+ public function setOrderByPostDate($dir = 'desc')
98
+ {
99
+ return $this->setOrder('post_date', $dir);
100
+ }
101
+
102
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Comment extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post_comment', 'comment_ID');
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Comment/Collection.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Comment_Collection extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post_comment');
8
+ }
9
+
10
+ /**
11
+ * Filters the collection of comments
12
+ * so only comments for a certain post are returned
13
+ *
14
+ */
15
+ public function addPostIdFilter($postId)
16
+ {
17
+ return $this->addFieldToFilter('comment_post_ID', $postId);
18
+ }
19
+
20
+
21
+ /**
22
+ * Filters the collection so only approved comments are returned
23
+ *
24
+ */
25
+ public function addCommentApprovedFilter($status = 1)
26
+ {
27
+ return $this->addFieldToFilter('comment_approved', $status);
28
+ }
29
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Tag extends Fishpig_Wordpress_Model_Mysql4_Category_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/post_tag', 'term_id');
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/Post/Tag/Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_Post_Tag_Collection extends Fishpig_Wordpress_Model_Mysql4_Category_Collection_Abstract
4
+ {
5
+ /**
6
+ * Defines the type of category
7
+ * Can be either category or link_category
8
+ *
9
+ * @var string
10
+ */
11
+ protected $_categoryType = 'post_tag';
12
+
13
+ public function _construct()
14
+ {
15
+ $this->_init('wordpress/post_tag');
16
+ }
17
+
18
+
19
+
20
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/User.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_User extends Fishpig_Wordpress_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/user', 'ID');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Mysql4/User/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Mysql4_User_Collection extends Fishpig_Wordpress_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('wordpress/user');
8
+ }
9
+ }
app/code/community/Fishpig/Wordpress/Model/Observer/Abstract.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Observer_Abstract extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Get an admin URL
7
+ *
8
+ * @param string $routePath
9
+ * @param mixed $routeParams
10
+ * @return string
11
+ */
12
+ public function getAdminUrl($routePath=null, $routeParams=null)
13
+ {
14
+ return Mage::getSingleton('adminhtml/url')->getUrl($routePath, $routeParams);
15
+ }
16
+
17
+ /**
18
+ * Return the current HTTP request object
19
+ *
20
+ * @return
21
+ */
22
+ protected function _getRequest()
23
+ {
24
+ return Mage::app()->getRequest();
25
+ }
26
+
27
+ /**
28
+ * Returns the relevant Wordpress helper.
29
+ *
30
+ * If no parameter passed, returns the default (Data.php) helper
31
+ *
32
+ */
33
+ public function _helper($helper = null)
34
+ {
35
+ if ($helper != null) {
36
+ $helper = '/' . $helper;
37
+ }
38
+
39
+ return Mage::helper('wordpress' . $helper);
40
+ }
41
+
42
+ /**
43
+ * Prints out an array
44
+ *
45
+ * @param array $arr
46
+ * @param bool $exit
47
+ */
48
+ protected function _debug(array $arr, $exit = true)
49
+ {
50
+ echo '<pre>';
51
+ print_r($arr);
52
+ echo '</pre>';
53
+
54
+ if ($exit) {
55
+ exit;
56
+ }
57
+ }
58
+ }
app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/Catalog/Product/SaveAssociations.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Observer_Adminhtml_Catalog_Product_SaveAssociations extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Save the product/post & product/category associations
7
+ * This information is saved in the Magento database
8
+ */
9
+ public function saveAssociations()
10
+ {
11
+ try {
12
+ if ($this->_getProduct()) {
13
+ $this->_deleteCurrentAssociations('post');
14
+ $this->_addNewAssociations('post');
15
+ $this->_deleteCurrentAssociations('category');
16
+ $this->_addNewAssociations('category');
17
+ }
18
+ }
19
+ catch (Exception $e) {
20
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Deletes the associations for the current product and the given type
26
+ *
27
+ * @param string $type should be either post or category
28
+ * @return bool
29
+ */
30
+ protected function _deleteCurrentAssociations($type)
31
+ {
32
+ $productId = $this->_getProduct()->getId();
33
+ $table = $this->_getTableName('wordpress_product_'.$type);
34
+
35
+ return $this->_query("DELETE FROM {$table} WHERE product_id = {$productId}");
36
+ }
37
+
38
+ /**
39
+ * Adds the newassociations for the current product and the given type
40
+ *
41
+ * @param string $type should be either post or category
42
+ * @return bool
43
+ */
44
+ protected function _addNewAssociations($type)
45
+ {
46
+ $assocIds = $this->_getIds($type);
47
+ $productId = $this->_getProduct()->getId();
48
+ $table = $this->_getTableName('wordpress_product_'.$type);
49
+
50
+ foreach($assocIds as $assocId) {
51
+ $this->_query("INSERT INTO {$table} (product_id, {$type}_id) VALUES ({$productId}, {$assocId})");
52
+ }
53
+
54
+ return true;
55
+ }
56
+
57
+ /**
58
+ * Loads the current Product model
59
+ *
60
+ * @return Mage_Catalog_Model_Product
61
+ */
62
+ protected function _getProduct()
63
+ {
64
+ if ($product = Mage::registry('product')) {
65
+ return $product;
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Loads either WP category or post ID's
73
+ *
74
+ * @param string $type should be either category or post
75
+ * @return array
76
+ */
77
+ protected function _getIds($type)
78
+ {
79
+ if ($post = Mage::app()->getRequest()->getPost()) {
80
+ $assocIds = array();
81
+
82
+ if (isset($post['wp_'.$type.'_id'])) {
83
+ $assocIds = $post['wp_'.$type.'_id'];
84
+ }
85
+
86
+ return $assocIds;
87
+ }
88
+
89
+ throw new Exception('Invalid post request');
90
+ }
91
+
92
+ /**
93
+ * Performs a read query on the Magento database
94
+ *
95
+ * @param string $sql contains the SQL query
96
+ * @return bool
97
+ */
98
+ protected function _query($sql)
99
+ {
100
+ return Mage::getSingleton('core/resource')->getConnection('core_write')->query($sql);
101
+ }
102
+
103
+ /**
104
+ * Returns the given table named prefixed with the table prefix
105
+ *
106
+ * @param string $table
107
+ * @return string
108
+ */
109
+ protected function _getTableName($table)
110
+ {
111
+ return Mage::getSingleton('core/resource')->getTableName($table);
112
+ }
113
+
114
+ }
app/code/community/Fishpig/Wordpress/Model/Observer/Adminhtml/System/Config/SaveAfter.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Observer_Adminhtml_System_Config_SaveAfter extends Fishpig_Wordpress_Model_Observer_Abstract
4
+ {
5
+ /**
6
+ * Perform the database & integration checks
7
+ * This has to be done before blocks start being rendered so an error message can be added
8
+ *
9
+ * @param Varien_Event_Observer $observer
10
+ */
11
+ public function postLogic(Varien_Event_Observer $observer)
12
+ {
13
+ try {
14
+ if (Mage::getStoreConfigFlag('wordpress/debug/log_enabled') && !Mage::getStoreConfigFlag('dev/log/active') ) {
15
+
16
+ Mage::app()->getStore()->setConfig('dev/log/active', 1);
17
+ Mage::log('Test', null, 't.log');
18
+ Mage::getConfig()->saveConfig('dev/log/active', 1);
19
+ }
20
+ }
21
+ catch (Exception $e) {exit($e);
22
+ $this->_helper()->log($e->getMessage());
23
+ }
24
+ }
25
+
26
+ }
app/code/community/Fishpig/Wordpress/Model/Observer/DatabaseSetup.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Observer_DatabaseSetup extends Fishpig_Wordpress_Model_Observer_Abstract
4
+ {
5
+ public function initConnection(Varien_Event_Observer $observer)
6
+ {
7
+ try {
8
+ $this->_helper('db')->mapTables();
9
+ $this->_initConnection();
10
+ }
11
+ catch (Exception $e) {
12
+ $this->_helper()->log($e->getMessage());
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Initialise the database connection
18
+ *
19
+ * @return bool
20
+ */
21
+ protected function _initConnection()
22
+ {
23
+ if ($this->_helper()->isSeparateDatabase()) {
24
+ try {
25
+ if (!$connection = $this->_createConnection()) {
26
+ throw new Exception('There was an error connecting to the WordPress database');
27
+ }
28
+ }
29
+ catch (Exception $e) {
30
+ $this->_helper()->log('initDatabaseConnection: ' . $e->getMessage());
31
+ return false;
32
+ }
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ /**
39
+ * Creates the WordPress database connections
40
+ * This function only need be called if Mage/WP are installed in different DB's
41
+ *
42
+ */
43
+ protected function _createConnection()
44
+ {
45
+ $configs = array('model' => 'mysql4', 'active' => '1');
46
+ $keys = array('host' => '', 'username' => '', 'password' => '', 'dbname' => '', 'charset' => 'utf8');
47
+
48
+ foreach($keys as $key => $defaultValue) {
49
+ if ($value = Mage::getStoreConfig('wordpress/database/' . $key)) {
50
+ $configs[$key] = $value;
51
+ }
52
+ else {
53
+ $configs[$key] = $defaultValue;
54
+ }
55
+ }
56
+
57
+ foreach(array('username', 'password', 'dbname') as $field) {
58
+ if (isset($configs[$field])) {
59
+ $configs[$field] = Mage::helper('core')->decrypt($configs[$field]);
60
+ }
61
+ }
62
+
63
+ if ($configs['host']) {
64
+ return Mage::getSingleton('core/resource')->createConnection('wordpress_read', 'pdo_mysql', $configs);
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ }
app/code/community/Fishpig/Wordpress/Model/Option.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Option extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ /**
6
+ * Loads an option based on it's name
7
+ *
8
+ * $param string $name
9
+ * @return $this
10
+ */
11
+ public function loadByName($name)
12
+ {
13
+ return $this->loadByAttribute('option_name', $name);
14
+ }
15
+ }
app/code/community/Fishpig/Wordpress/Model/Page.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Page extends Fishpig_Wordpress_Model_Post_Abstract
4
+ {
5
+ public function loadBySlug($explodedUri)
6
+ {
7
+ return $this->getResource()->loadBySlug($explodedUri);
8
+ }
9
+
10
+ }
app/code/community/Fishpig/Wordpress/Model/Post.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Post extends Fishpig_Wordpress_Model_Post_Abstract
4
+ {
5
+ /**
6
+ * Returns the permalink used to access this post
7
+ *
8
+ * @return string
9
+ */
10
+ public function getPermalink()
11
+ {
12
+ if (!$this->hasData('permalink')) {
13
+ $this->setData('permalink', $this->_helper('post')->getPermalink($this));
14
+ }
15
+
16
+ return $this->getData('permalink');
17
+ }
18
+
19
+ /**
20
+ * Wrapper for self::getPermalink()
21
+ *
22
+ * @return string
23
+ */
24
+ public function getUrl()
25
+ {
26
+ return $this->getPermalink();
27
+ }
28
+
29
+ /**
30
+ * Gets the post content
31
+ * If parameter1 is true, nl2br is added
32
+ *
33
+ * @return string
34
+ */
35
+ public function getPostContent()
36
+ {
37
+ return $this->_helper('filter')->applyFilters($this->getData('post_content'), array('id' => $this->getId(), 'type' => 'post'));
38
+ }
39
+
40
+ public function getPostExcerpt()
41
+ {
42
+ if (!$this->getData('post_excerpt')) {
43
+ if ($content = $this->getData('post_content')) {
44
+ if (strpos($content, '<!--more-->') !== false) {
45
+ $excerpt = substr($content, 0, strpos($content, '<!--more-->'));
46
+ $excerpt .= " <a href=\"".$this->getPermalink()."\">".$this->getReadMoreAnchor()."</a>";
47
+ }
48
+ else {
49
+ $excerpt = null;
50
+ }
51
+ }
52
+ else {
53
+ $excerpt = null;
54
+ }
55
+
56
+ $this->setPostExcerpt($this->_helper('filter')->applyFilters($excerpt, array('id' => $this->getId(), 'type' => 'post', 'filters' => 'excerpt')));
57
+ }
58
+
59
+ return $this->getData('post_excerpt');
60
+ }
61
+
62
+ /**
63
+ * Returns the parent category of the current post
64
+ *
65
+ * @return Fishpig_Wordpress_Model_Post_Category
66
+ */
67
+ public function getParentCategory()
68
+ {
69
+ if (!$this->hasData('parent_category')) {
70
+ $this->setData('parent_category', $this->getParentCategories()->getFirstItem());
71
+ }
72
+
73
+ return $this->getData('parent_category');
74
+ }
75
+
76
+ public function getParentCategories()
77
+ {
78
+ if (!$this->hasData('parent_categories')) {
79
+ $this->setData('parent_categories', $this->getResource()->getParentCategories($this));
80
+ }
81
+
82
+ return $this->getData('parent_categories');
83
+ }
84
+
85
+ /**
86
+ * Gets a collection of post tags
87
+ *
88
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Tag_Collection
89
+ */
90
+ public function getTags()
91
+ {
92
+ if (!$this->hasData('tags')) {
93
+ $this->setData('tags', $this->getResource()->getPostTags($this));
94
+ }
95
+
96
+ return $this->getData('tags');
97
+ }
98
+
99
+ public function getReadMoreAnchor()
100
+ {
101
+ $readMoreAnchor = $this->_helper()->htmlEscape(Mage::getStoreConfig('wordpress_blog/posts/more_anchor'));
102
+
103
+ if ($readMoreAnchor) {
104
+ return $readMoreAnchor;
105
+ }
106
+
107
+ return $this->_helper()->__('Read More');
108
+ }
109
+ }
app/code/community/Fishpig/Wordpress/Model/Post/Abstract.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Post_Abstract extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ /**
6
+ * Returns a collection of comments for this post
7
+ *
8
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Comment_Collection
9
+ */
10
+ public function getComments()
11
+ {
12
+ if (!$this->hasData('comments')) {
13
+ $this->setData('comments', Mage::getModel('wordpress/post_comment')->loadByPostId($this->getData('ID')));
14
+ }
15
+
16
+ return $this->getData('comments');
17
+ }
18
+
19
+ /**
20
+ * Returns a collection of images for this post
21
+ *
22
+ * @return Fishpig_Wordpress_Model_Mysql4_Image_Collection
23
+ *
24
+ * NB. This function has not been thoroughly tested
25
+ * Please report any bugs
26
+ */
27
+ public function getImages()
28
+ {
29
+ if (!$this->hasData('images')) {
30
+ $this->setData('images', Mage::getModel('wordpress/image')->getCollection()->setParent($this->getData('ID')));
31
+ }
32
+
33
+ return $this->getData('images');
34
+ }
35
+
36
+ /**
37
+ * Returns the featured image for the post
38
+ *
39
+ * This image must be uploaded and assigned in the WP Admin
40
+ *
41
+ * @return Fishpig_Wordpress_Model_Image
42
+ */
43
+ public function getFeaturedImage()
44
+ {
45
+ if (!$this->hasData('featured_image')) {
46
+ $images = $this->getImages();
47
+
48
+ if ($images) {
49
+ $featuredImageId = $this->_helper('db')
50
+ ->fetchOne("SELECT meta_value FROM ".$this->_helper('db')->getTableName('postmeta')." WHERE `post_id` = ".$this->getId()." AND `meta_key` = '_thumbnail_id' ");
51
+
52
+ if ($featuredImageId) {
53
+ $this->setData('featured_image', Mage::getModel('wordpress/image')->load($featuredImageId));
54
+ }
55
+ }
56
+ }
57
+
58
+ return $this->getData('featured_image');
59
+ }
60
+
61
+ /**
62
+ * Get the model for the author of this post
63
+ *
64
+ * @return Fishpig_Wordpress_Model_Author
65
+ */
66
+ public function getAuthor()
67
+ {
68
+ return Mage::getModel('wordpress/user')->load($this->getAuthorId());
69
+ }
70
+
71
+ /**
72
+ * Returns the author ID of the current post
73
+ *
74
+ * @return int
75
+ */
76
+ public function getAuthorId()
77
+ {
78
+ return $this->getData('post_author');
79
+ }
80
+
81
+ /**
82
+ * Returns the post date formatted
83
+ * If not format is supplied, the format specified in your Magento config will be used
84
+ *
85
+ * @return string
86
+ */
87
+ public function getPostDate($format = null)
88
+ {
89
+ return $this->_helper()->formatDate($this->getData('post_date'), $format);
90
+ }
91
+
92
+ /**
93
+ * Returns the post time formatted
94
+ * If not format is supplied, the format specified in your Magento config will be used
95
+ *
96
+ * @return string
97
+ */
98
+ public function getPostTime($format = null)
99
+ {
100
+ return $this->_helper()->formatTime($this->getData('post_time'), $format);
101
+ }
102
+ }
app/code/community/Fishpig/Wordpress/Model/Post/Attachment/Abstract.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Fishpig_Wordpress_Model_Post_Attachment_Abstract extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ /**
6
+ * Loads the associated attachment meta data
7
+ * This data is stored as a serialized array
8
+ *
9
+ * @param int $id
10
+ * @param string $field
11
+ * @return Fishpig_Wordpress_Model_Post_Attachment_Abstract
12
+ */
13
+ public function load($id, $field = null)
14
+ {
15
+ parent::load($id, $field);
16
+
17
+ if ($this->getId() > 0) {
18
+ $sql = "SELECT meta_value FROM ".$this->getTableName('postmeta')." WHERE meta_key = '_wp_attachment_metadata' AND post_id = ".$this->getId()." LIMIT 1";
19
+ $data = unserialize($this->_helper('db')->fetchOne($sql));
20
+
21
+ if (is_array($data)) {
22
+ foreach($data as $key => $value) {
23
+ $this->setData($key, $value);
24
+ }
25
+ }
26
+ }
27
+
28
+ return $this;
29
+ }
30
+
31
+ }
app/code/community/Fishpig/Wordpress/Model/Post/Category.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Post_Category extends Fishpig_Wordpress_Model_Category_Abstract
4
+ {
5
+ /**
6
+ * Sets the category type as this class extends from a base class
7
+ * that can also be used for link categories
8
+ *
9
+ * @var string
10
+ */
11
+ protected $_categoryType = 'category';
12
+
13
+ /**
14
+ * Cache for this category's post collection
15
+ *
16
+ * @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
17
+ */
18
+ protected $_postCollection = null;
19
+
20
+ /**
21
+ * Loads a category model based on a post ID
22
+ *
23
+ * @param int $postId
24
+ */
25
+ public function loadByPostId($postId)
26
+ {
27
+ return $this->loadByAttribute('object_id', $postId);
28
+ }
29
+
30
+ public function loadBySlug($slug)
31
+ {
32
+ $collection = Mage::getResourceModel('wordpress/post_category_collection')
33
+ ->addFieldToFilter('slug', $slug)
34
+ ->setPageSize(1)->setCurPage(1);
35
+
36
+ if (count($collection) > 0) {
37
+ return $collection->getFirstItem();
38
+ }
39
+
40
+ return false;
41
+ }
42
+
43
+ /**
44
+ * Loads the posts belonging to this category
45
+ *
46
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
47
+ */
48
+ public function getPostCollection()
49
+ {
50
+ if (is_null($this->_postCollection)) {
51
+ $this->_postCollection = Mage::getResourceModel('wordpress/post_collection')
52
+ ->addIsPublishedFilter()
53
+ ->addCategoryIdFilter($this->getId());
54
+ }
55
+
56
+ return $this->_postCollection;
57
+ }
58
+
59
+ /**
60
+ * Gets the category URL
61
+ *
62
+ * @return string
63
+ */
64
+ public function getUrl()
65
+ {
66
+ return rtrim($this->getWpUrl(trim($this->_helper()->getCachedWpOption('category_base', 'category'), '/') . '/' . $this->getSlug()), '/') . '/';
67
+ }
68
+ }
app/code/community/Fishpig/Wordpress/Model/Post/Comment.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Post_Comment extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ /**
6
+ * Returns a collection of comments for a certain post
7
+ *
8
+ * @param int $postId
9
+ * @param bool $isApproved
10
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Comment_Collection
11
+ */
12
+ public function loadByPostId($postId, $isApproved = true)
13
+ {
14
+ $comments = Mage::getModel('wordpress/post_comment')
15
+ ->getCollection()
16
+ ->addPostIdFilter($postId);
17
+
18
+ if ($isApproved) {
19
+ $comments->addCommentApprovedFilter();
20
+ }
21
+
22
+ return $comments;
23
+ }
24
+
25
+ /**
26
+ * Returns the comment date
27
+ * If no format is specified, the default format is used from the Magento config
28
+ *
29
+ * @return string
30
+ */
31
+ public function getCommentDate($format = null)
32
+ {
33
+ return $this->_helper()->formatDate($this->getData('comment_date'), $format);
34
+ }
35
+
36
+ /**
37
+ * Returns the comment time
38
+ * If no format is specified, the default format is used from the Magento config
39
+ *
40
+ * @return string
41
+ */
42
+ public function getCommentTime($format = null)
43
+ {
44
+ return $this->_helper()->formatTime($this->getData('comment_date'), $format);
45
+ }
46
+
47
+ /**
48
+ * Return the URL for the comment author
49
+ *
50
+ * @return string
51
+ */
52
+ public function getCommentAuthorUrl()
53
+ {
54
+ return ($url = $this->getData('comment_author_url')) ? $url : '#';
55
+ }
56
+ }
app/code/community/Fishpig/Wordpress/Model/Post/Tag.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_Post_Tag extends Fishpig_Wordpress_Model_Category_Abstract
4
+ {
5
+ /**
6
+ * Sets the category type as this class extends from a base class
7
+ * that can also be used for link categories
8
+ *
9
+ * @var string
10
+ */
11
+ protected $_categoryType = 'post_tag';
12
+
13
+ /**
14
+ * Cache for this category's post collection
15
+ *
16
+ * @var Fishpig_Wordpress_Model_Mysql4_Post_Collection
17
+ */
18
+ protected $_postCollection = null;
19
+
20
+ /**
21
+ * Loads a category model based on a post ID
22
+ *
23
+ * @param int $postId
24
+ */
25
+ public function loadByPostId($postId)
26
+ {
27
+ return $this->loadByAttribute('object_id', $postId);
28
+ }
29
+
30
+ /**
31
+ * Loads the posts belonging to this category
32
+ *
33
+ * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
34
+ */
35
+ public function getPostCollection()
36
+ {
37
+ if (is_null($this->_postCollection)) {
38
+ $this->_postCollection = Mage::getResourceModel('wordpress/post_collection')
39
+ ->addIsPublishedFilter()
40
+ ->addTagIdFilter($this->getId());
41
+ }
42
+
43
+ return $this->_postCollection;
44
+ }
45
+
46
+ /**
47
+ * Gets the category URL
48
+ *
49
+ * @return string
50
+ */
51
+ public function getUrl()
52
+ {
53
+ return rtrim($this->getWpUrl(trim($this->_helper()->getCachedWpOption('tag_base', 'tag'), '/') . '/' . $this->getSlug()), '/') . '/';
54
+ }
55
+
56
+ public function getAllTagsUrl()
57
+ {
58
+ return $this->getWpUrl('tags');
59
+ }
60
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Encrypted.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Backend_Encrypted extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
4
+ {
5
+
6
+ /**
7
+ * Decrypt value after loading
8
+ * If no value present, do not decrypt!
9
+ */
10
+ protected function _afterLoad()
11
+ {
12
+ $value = (string)$this->getValue();
13
+
14
+ if ($value) {
15
+ parent::_afterLoad();
16
+ }
17
+ }
18
+
19
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Database/Location.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_Database_Location
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return
8
+ array(
9
+ array('value' => 0, 'label' => 'Magento/WordPress share a database'),
10
+ array('value' => 1, 'label' => 'Magento/WordPress do not share a database'),
11
+ );
12
+ }
13
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Content.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_Filters_Content
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $filters = array('' => 'Disable All', 'shortcodes' => 'Render Shortcodes', 'auto_paragraph' => 'Auto Add P Tags');
8
+ $options = array();
9
+
10
+ foreach($filters as $value => $label) {
11
+ $options[] = array('value' => $value, 'label' => $label);
12
+ }
13
+
14
+ return $options;
15
+ }
16
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Filters/Excerpt.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_Filters_Excerpt
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $filters = array('' => 'Disable All', 'remove_html' => 'Remove HTML', 'shortcodes' => 'Render Shortcodes', 'remove_shortcodes' => 'Remove Shortcodes');
8
+ $options = array();
9
+
10
+ foreach($filters as $value => $label) {
11
+ $options[] = array('value' => $value, 'label' => $label);
12
+ }
13
+
14
+ return $options;
15
+ }
16
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Integration.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_Integration
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 0, 'label' => 'Semi Integrated'),
9
+ array('value' => 1, 'label' => 'Fully Integrated'),
10
+ );
11
+ }
12
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Shortcodes.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_Shortcodes
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+
8
+ $shortcodes = array('' => 'Disable All', 'caption' => 'Caption', 'youtube' => 'YouTube Videos', 'product' => 'Featured Product (Custom)', 'associatedProducts' => 'Associated Products (Custom)');
9
+ $options = array();
10
+
11
+ foreach($shortcodes as $value => $label) {
12
+ $options[] = array('value' => $value, 'label' => $label);
13
+ }
14
+
15
+ return $options;
16
+ }
17
+ }
app/code/community/Fishpig/Wordpress/Model/System/Config/Source/SyntaxHighlighter/Theme.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_System_Config_Source_SyntaxHighlighter_Theme
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $files = array('Default', 'Django', 'Eclipse', 'Emacs', 'FadeToGrey', 'MDUltra', 'Midnight', 'RDark');
8
+ $options = array();
9
+
10
+ foreach($files as $theme) {
11
+ $options[] = array(
12
+ 'value' => $theme,
13
+ 'label' => $theme
14
+ );
15
+ }
16
+
17
+ return $options;
18
+ }
19
+ }
app/code/community/Fishpig/Wordpress/Model/User.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Model_User extends Fishpig_Wordpress_Model_Abstract
4
+ {
5
+ /**
6
+ * Get the URL for this user
7
+ *
8
+ * @return string
9
+ */
10
+ public function getUrl()
11
+ {
12
+ return rtrim($this->getWpUrl('author/' . $this->getUserLogin()), '/') . '/';
13
+ }
14
+
15
+ /**
16
+ * Removes the password from the Wordpress user model
17
+ * This is done for security reasons
18
+ */
19
+ protected function _afterLoad()
20
+ {
21
+ if ($this->hasData('user_pass')) {
22
+ $this->unsetData('user_pass');
23
+ }
24
+ }
25
+ }
app/code/community/Fishpig/Wordpress/controllers/Adminhtml/DebugController.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Adminhtml_DebugController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ public function indexAction()
7
+ {
8
+ try {
9
+ if ($this->_helper('debug')->isIntegrated()) {
10
+ if ($this->_helper()->isFullyIntegrated()) {
11
+ Mage::getSingleton('adminhtml/session')->addSuccess(Fishpig_Wordpress_Helper_Debug::SUCCESS_FULLY_INTEGRATED);
12
+
13
+ Mage::getSingleton('adminhtml/session')->addSuccess(
14
+ sprintf(
15
+ Fishpig_Wordpress_Helper_Debug::SUCCESS_FULLY_INTEGRATED_LINKS, $this->_helper()->getUrl(), $this->_helper()->getAdminUrl()
16
+ )
17
+ );
18
+ }
19
+ else {
20
+ Mage::getSingleton('adminhtml/session')->addSuccess(Fishpig_Wordpress_Helper_Debug::SUCCESS_SEMI_INTEGRATED);
21
+ }
22
+ }
23
+ else {
24
+ Mage::getSingleton('adminhtml/session')->addWarning('It is difficult to determine whether Magento and Wordpress are integrated. Please submit an error report to the module developers.');
25
+ $this->_helper()->log('debug.indexAction: execution escaped the correct flow');
26
+ }
27
+ }
28
+ catch (Exception $e) {
29
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
30
+ }
31
+
32
+ $this->_redirect('adminhtml/system_config/edit/section/wordpress');
33
+ }
34
+
35
+
36
+ protected function _helper($helper = null)
37
+ {
38
+ if ($helper != null) {
39
+ $helper = '/' . $helper;
40
+ }
41
+
42
+ return Mage::helper('wordpress' . $helper);
43
+ }
44
+ }
45
+
app/code/community/Fishpig/Wordpress/controllers/Adminhtml/RedirectController.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Adminhtml_RedirectController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $ahelper = $this->_helper('adminhtml');
8
+
9
+ try {
10
+ return $this->_loginToWordpressAdmin();
11
+ }
12
+ catch (Exception $e) {
13
+ if (!$this->_helper('db')->isConnected()) {
14
+ return $ahelper->redirectToWordpressConfig();
15
+ }
16
+ else {
17
+ if ($ahelper->getAutoLogin()) {
18
+ $ahelper->addError('There was an error logging you into WordPress. Please check your WordPress Admin credentials below and try again')->addNotice('If you are sure that the details entered below are your correct WP-Admin login details you should check consult the WordPress log file for more information');
19
+ }
20
+ else {
21
+ $ahelper->addError('Please set your Wordpress Admin area login details below. Once you have done this you will be able to login to Wordpress with 1 click by selecting Wordpress Admin from the top menu.');
22
+ }
23
+
24
+ $this->_redirect('wordpress/adminhtml_wpAdmin/login', array('redirect_to' => base64_encode($this->_getDestinationPage())));
25
+ return;
26
+ }
27
+ }
28
+ }
29
+
30
+ protected function _loginToWordpressAdmin()
31
+ {
32
+ $postUrl = $this->_helper()->getBaseUrl('wp-login.php');
33
+ $postData = array(
34
+ 'log' => $this->_getUsername(),
35
+ 'pwd' => $this->_getPassword(),
36
+ 'rememberme' => 'forever',
37
+ 'wp-submit' => 'Log In',
38
+ 'redirect_to' => $this->_getDestinationPage(),
39
+ 'testcookie' => 1
40
+ );
41
+
42
+ try {
43
+ $curl = $this->_helper('curl')
44
+ ->post($postUrl, $postData, array('header' => 1, 'follow_location' => 0, 'return_transfer' => 1), true);
45
+
46
+ $result = $curl->getResult();
47
+
48
+ if (strpos($result, 'Location: ') === false) {
49
+ throw new Exception('Invalid response returned. Are the WP-Admin login details correct?');
50
+ }
51
+
52
+ foreach(explode("\n", $result) as $line) {
53
+ $line = trim($line);
54
+
55
+ if (substr($line, 0, 1) == '<') {
56
+ break;
57
+ }
58
+
59
+ if ($line) {
60
+ header($line, false);
61
+ }
62
+ }
63
+ }
64
+ catch (Exception $e) {
65
+ $this->_helper()->log('RedirectController._loginToWordpress: '.$e->getMessage());
66
+ throw $e;
67
+ }
68
+
69
+ $this->_redirectUrl($this->_getDestinationPage());
70
+ return;
71
+ }
72
+
73
+ protected function _getDestinationPage()
74
+ {
75
+ $page = array();
76
+ $page['default'] = 'index.php';
77
+ $page['default'] = '';
78
+ $page['posts'] = 'edit.php';
79
+ $page['media'] = 'upload.php';
80
+ $page['links'] = 'link-manager.php';
81
+ $page['pages'] = 'edit.php?post_type=page';
82
+ $page['comments'] = 'edit-comments.php';
83
+ $page['appearance'] = 'themes.php';
84
+ $page['plugins'] = 'plugins.php';
85
+ $page['users'] = 'users.php';
86
+ $page['tools'] = 'tools.php';
87
+ $page['settings'] = 'options-' . $this->getRequest()->getParam('wp_page_option', 'general') . '.php';
88
+
89
+ $key = $this->getRequest()->getParam('wp_page', 'default');
90
+
91
+ if (!isset($page[$key])) {
92
+ $key = 'default';
93
+ }
94
+
95
+ $url = $this->_helper()->getAdminUrl($page[$key]);
96
+
97
+ if (substr($url, 0, strlen('/wp-admin/')) != '/wp-admin/') {
98
+ return $url;
99
+ }
100
+
101
+ throw new Exception('There appears to be an error connecting to your WordPress database.');
102
+ }
103
+
104
+ protected function _getUsername()
105
+ {
106
+ return $this->_helper('adminhtml')->getAutoLogin()->getUsername();
107
+ }
108
+
109
+ protected function _getPassword()
110
+ {
111
+ return $this->_helper('adminhtml')->getAutoLogin()->getPassword();
112
+ }
113
+
114
+ public function _helper($helper = null)
115
+ {
116
+ if ($helper != null) {
117
+ $helper = '/' . $helper;
118
+ }
119
+
120
+ return Mage::helper('wordpress' . $helper);
121
+ }
122
+
123
+ }
app/code/community/Fishpig/Wordpress/controllers/Adminhtml/SupportController.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Adminhtml_SupportController extends Fishpig_Wordpress_Controller_Adminhtml_Abstract
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->loadLayout();
8
+ $this->renderLayout();
9
+ }
10
+
11
+ public function sendAction()
12
+ {
13
+ if ($data = $this->_prepareData()) {
14
+ try {
15
+ if ($this->_sendEmail($data) == false) {
16
+ throw new Exception($this->__('There was an unknown error while sending your '. $this->getEnquiryType().'.'));
17
+ }
18
+
19
+ $this->_unsetSessionData();
20
+ $this->getSession()->addSuccess($this->__('Your '.$this->getEnquiryType().' was sent successfully. Please allow 24 hours for a reply'));
21
+ $this->_redirect('adminhtml/dashboard');
22
+ }
23
+ catch (Exception $e) {
24
+ $this->_saveSessionData();
25
+ $this->_helper()->log($e->getMessage());
26
+ $this->getSession()->addError($e->getMessage());
27
+ $this->_redirect('wordpress/adminhtml_support/', array('type' => $this->getEnquiryTypeId()));
28
+ }
29
+ }
30
+ }
31
+
32
+ protected function _sendEmail($data)
33
+ {
34
+ $email = new Zend_Mail();
35
+ $email->addTo('wpmage@fishpig.co.uk', 'fishpig')
36
+ ->setFrom($data->getSenderEmail(), $data->getSenderName())
37
+ ->setSubject($data->getSubject())
38
+ ->setBodyText($data->getBodyText());
39
+
40
+ return $email->send();
41
+ }
42
+
43
+ protected function _prepareData()
44
+ {
45
+ if ($postData = $this->_getRawData()) {
46
+ $doubleBreak = "\n\n\n\n";
47
+
48
+ $body = $postData->getContent().$doubleBreak;
49
+ $body .= "This message was sent using the support form at ".Mage::getBaseUrl().$doubleBreak;
50
+ $body .= print_r($this->_helper('debug_environmentReport')->getReport(), true).$doubleBreak;
51
+ $body .= $this->_helper('debug_environmentReport')->getLogEntries(100).$doubleBreak;
52
+ $postData->setBodyText($body);
53
+
54
+ $postData->setSubject($postData->getEnquiryType().': '.$postData->getSubject());
55
+
56
+ return $postData;
57
+ }
58
+
59
+ return false;
60
+ }
61
+
62
+
63
+ protected function _getRawData()
64
+ {
65
+ if ($post = $this->getRequest()->getPost()) {
66
+ foreach($post as $index => $value) {
67
+ $post[$index] = htmlspecialchars($value);
68
+ }
69
+
70
+ return new Varien_Object(array_merge(
71
+ array(
72
+ 'sender_name' => 'Support Form',
73
+ 'sender_email' => 'wpmage@fishpig.co.uk',
74
+ 'enquiry_type' => 'Support Ticket',
75
+ 'subject' => 'No Subject',
76
+ 'content' => 'Body not set',
77
+ ), $post));
78
+ }
79
+
80
+ return false;
81
+ }
82
+
83
+ protected function _saveSessionData()
84
+ {
85
+ if ($post = $this->getRequest()->getPost()) {
86
+ $this->getSession()->setSupportData($post);
87
+ }
88
+ }
89
+
90
+ protected function _unsetSessionData()
91
+ {
92
+ $this->getSession()->setSupportData(null);
93
+ }
94
+
95
+ public function getEnquiryType()
96
+ {
97
+ return ($type = $this->getRequest()->getPost('enquiry_type')) ? $type : $this->__('Support Ticket');
98
+ }
99
+
100
+ public function getEnquiryTypeId()
101
+ {
102
+ return ('Support Ticket' == $this->getRequest()->getPost('enquiry_type')) ? 0 : 1;
103
+
104
+ }
105
+ }
106
+
app/code/community/Fishpig/Wordpress/controllers/Adminhtml/WpAdminController.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Adminhtml_WpAdminController extends Mage_Adminhtml_Controller_action
4
+ {
5
+ public function loginAction()
6
+ {
7
+ if ($adminUser = $this->_initAdminUserModel()) {
8
+ Mage::register('wordpress_admin_user', $adminUser);
9
+ }
10
+
11
+ $this->loadLayout();
12
+ $this->_setActiveMenu('wordpress');
13
+ $this->renderLayout();
14
+ }
15
+
16
+ protected function _initAdminUserModel()
17
+ {
18
+ $adminUser = Mage::getModel('wordpress/admin_user')->load(0, 'store_id');
19
+
20
+ if ($adminUser->getId()) {
21
+ return $adminUser;
22
+ }
23
+ }
24
+
25
+ public function saveAction()
26
+ {
27
+ if ($data = $this->getRequest()->getPost()) {
28
+ try {
29
+ $data['user_id'] = Mage::getSingleton('admin/session')->getUser()->getUserId();
30
+ $autologin = Mage::getModel('wordpress/admin_user');
31
+ $autologin->setData($data)->setId($this->getRequest()->getParam('id'));
32
+
33
+ $autologin->save();
34
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Your Wordpress Auto-login details were successfully saved.'));
35
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
36
+ }
37
+ catch (Exception $e) {
38
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
39
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
40
+ }
41
+ }
42
+ else {
43
+ Mage::getSingleton('adminhtml/session')->addError($this->__('There was an error while trying to save your Wordpress Auto-login details.'));
44
+ }
45
+
46
+ $this->_redirect('*/*/login');
47
+ }
48
+
49
+ }
app/code/community/Fishpig/Wordpress/controllers/Archive/ViewController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Archive_ViewController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Initialise the current category
7
+ */
8
+ protected function _init()
9
+ {
10
+ parent::_init();
11
+
12
+ if ($archive = $this->_initArchive()) {
13
+ $this->register('wordpress_archive', $archive)
14
+ ->_title($archive->getName())
15
+ ->_addCrumb('archive', array('link' => $archive->getUrl(), 'label' => $archive->getName()))
16
+ ->_addCanonicalLink($archive->getUrl());
17
+ }
18
+ else {
19
+ $this->throwInvalidObjectException('author');
20
+ }
21
+
22
+ $this->_prepareSyntaxHighlighter();
23
+ }
24
+
25
+ protected function _prepareSyntaxHighlighter()
26
+ {
27
+ if (Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/display_post_list')) {
28
+ return parent::_prepareSyntaxHighlighter();
29
+ }
30
+
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Loads an archive model based on the URI
36
+ *
37
+ * @return Fishpig_Wordpress_Model_Archive
38
+ */
39
+ protected function _initArchive()
40
+ {
41
+ if ($archiveSlug = $this->getRequest()->getParam('archive')) {
42
+ if ($archive = Mage::getModel('wordpress/archive')->load($archiveSlug)) {
43
+ if ($archive->hasPosts()) {
44
+ return $archive;
45
+ }
46
+ }
47
+ }
48
+
49
+ return false;
50
+ }
51
+ }
app/code/community/Fishpig/Wordpress/controllers/AuthorController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_AuthorController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Initialise the current category
7
+ */
8
+ protected function _init()
9
+ {
10
+ parent::_init();
11
+
12
+ if ($author = $this->_initAuthor()) {
13
+
14
+ $this->register('wordpress_author', $author)
15
+ ->_title($author->getDisplayName())
16
+ ->_addCrumb('author_nolink', array('label' => $this->__('Author')))
17
+ ->_addCrumb('author', array('link' => $author->getUrl(), 'label' => $author->getDisplayName()))
18
+ ->_addCanonicalLink($author->getUrl());
19
+ }
20
+ else {
21
+ $this->throwInvalidObjectException('author');
22
+ }
23
+
24
+ return $this;
25
+ }
26
+
27
+ /**
28
+ * Load user based on URI
29
+ *
30
+ * @return Fishpig_Wordpress_Model_User
31
+ */
32
+ protected function _initAuthor()
33
+ {
34
+ if ($slug = urldecode($this->getRequest()->getParam('author'))) {
35
+ if ($author = Mage::getModel('wordpress/user')->load($slug, 'user_nicename')) {
36
+ if ($author->getId() > 0) {
37
+ return $author;
38
+ }
39
+ }
40
+ }
41
+
42
+ return false;
43
+ }
44
+ }
app/code/community/Fishpig/Wordpress/controllers/CategoryController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_CategoryController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Initialise the current category
7
+ */
8
+ protected function _init()
9
+ {
10
+ if ($category = $this->_loadCategoryBasedOnUrl()) {
11
+ Mage::register('wordpress_category', $category);
12
+
13
+ if (!$this->_helper()->isLegacyMagento()) {
14
+ $this->_addCustomLayoutHandles(array('wordpress_category_index', 'WORDPRESS_CATEGORY_'.$category->getId()));
15
+ }
16
+
17
+ // Add base breacrumbs and title
18
+ parent::_init();
19
+
20
+ $this->_title($category->getName());
21
+ $this->_addCrumb('category', array('link' => $category->getUrl(), 'label' => $category->getName()));
22
+ $this->_addCanonicalLink($category->getUrl());
23
+ $this->_prepareSyntaxHighlighter();
24
+
25
+ return $this;
26
+ }
27
+ else {
28
+ $this->throwInvalidObjectException('category');
29
+ }
30
+ }
31
+
32
+ protected function _prepareSyntaxHighlighter()
33
+ {
34
+ if (Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/display_post_list')) {
35
+ return parent::_prepareSyntaxHighlighter();
36
+ }
37
+
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Load the category based on the slug stored in the param 'category'
43
+ *
44
+ * @return Fishpig_Wordpress_Model_Post_Categpry
45
+ */
46
+ protected function _loadCategoryBasedOnUrl()
47
+ {
48
+ $category = Mage::getModel('wordpress/post_category')->loadBySlug($this->getRequest()->getParam('category'));
49
+ return ($category && $category->getId() > 0) ? $category : false;
50
+ }
51
+ }
app/code/community/Fishpig/Wordpress/controllers/FeedController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_FeedController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Display the RSS Feed
7
+ *
8
+ */
9
+ public function indexAction()
10
+ {
11
+ if (Mage::getStoreConfigFlag('wordpress_blog/rss_feed/enabled')) {
12
+ $this->getResponse()
13
+ ->setHeader('Content-Type', 'text/xml; charset=' . $this->_helper()->getCachedWpOption('blog_charset'), true)
14
+ ->setBody($this->getLayout()->createBlock('wordpress/feed_rss2', 'wordpress_feed')->toHtml());
15
+ }
16
+ else {
17
+ $this->_forward('noRoute');
18
+ }
19
+ }
20
+
21
+ }
app/code/community/Fishpig/Wordpress/controllers/HomepageController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_HomepageController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ protected function _init()
6
+ {
7
+ parent::_init();
8
+ $this->_addCanonicalLink($this->_helper()->getUrl());
9
+
10
+ if ($this->getSeoPlugin()->isEnabled()) {
11
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
12
+
13
+ foreach($this->getSeoPlugin()->getMetaFields() as $field) {
14
+ if ($value = $this->getSeoPlugin()->getPluginOption('home_'.$field)) {
15
+
16
+ $headBlock->setData($field, $value);
17
+ }
18
+ }
19
+
20
+ if ($title = $this->getSeoPlugin()->getPluginOption('home_title')) {
21
+ $this->_title()->_title($title);
22
+ }
23
+ }
24
+ }
25
+
26
+ $this->_prepareSyntaxHighlighter();
27
+ }
28
+
29
+ protected function _prepareSyntaxHighlighter()
30
+ {
31
+ if (Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/display_post_list')) {
32
+ return parent::_prepareSyntaxHighlighter();
33
+ }
34
+
35
+ return $this;
36
+ }
37
+ }
app/code/community/Fishpig/Wordpress/controllers/PageController.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_PageController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+
6
+ protected function _init()
7
+ {
8
+ parent::_init();
9
+
10
+ if ($page = Mage::registry('wordpress_page')) {
11
+ $this->_title($page->getPostTitle());
12
+ $this->_addCrumb('page', array('link' => $page->getUrl(), 'label' => $page->getPostTitle()));
13
+ $this->_addCanonicalLink($page->getUrl());
14
+ }
15
+
16
+ return $this;
17
+ }
18
+
19
+
20
+ }
app/code/community/Fishpig/Wordpress/controllers/Post/View/CommentController.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Post_View_CommentController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Disable the indexAction
7
+ */
8
+ public function indexAction()
9
+ {
10
+ $this->_forward('noRoute');
11
+ return;
12
+ }
13
+
14
+ /**
15
+ * Post a comment action
16
+ */
17
+ public function postAction()
18
+ {
19
+ $this->_event('wordpress_post_comment_before', array('comment_data'=>$this->getRequest()->getPost()));
20
+
21
+ $redirectUrl = $this->_helper()->getUrl();
22
+ $post = $this->_getCommentPost();
23
+
24
+ try {
25
+ if (($post->getId() > 0) == false) {
26
+ throw new Exception($this->__(Mage::getStoreConfig('wordpress_blog/post_comments/error_msg')));
27
+ }
28
+
29
+ $this->_postComment();
30
+ $this->_event('wordpress_post_comment_after', array('post'=>$post));
31
+ Mage::getSingleton('core/session')->addSuccess($this->__(Mage::getStoreConfig('wordpress_blog/post_comments/success_msg')));
32
+ }
33
+ catch (Exception $e) {
34
+ Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
35
+ }
36
+
37
+ if ($postUrl = $post->getPermalink()) {
38
+ $this->_redirectUrl($postUrl);
39
+ return;
40
+ }
41
+
42
+ $this->_redirectUrl($this->_helper()->getUrl());
43
+ }
44
+
45
+ /**
46
+ * Post a comment
47
+ */
48
+ protected function _postComment()
49
+ {
50
+ if ($postData = $this->getRequest()->getPost()) {
51
+ $postUrl = $this->_helper()->getBaseUrl('wp-comments-post.php?');
52
+
53
+
54
+ exit($postUrl);
55
+ $curl = $this->_helper('curl')->post($postUrl, $postData, array('header' => 1, 'return_transfer' => 1), true);
56
+
57
+ $result = $curl->getResult();
58
+
59
+ if (strpos($result, 'error-page') !== false) {
60
+ $errorMsg = strip_tags(substr($result, strpos($result, '>', strpos($result, "<body"))+1));
61
+ throw new Exception($errorMsg);
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Return the post model that this comment is aimed for
68
+ *
69
+ * @return Fishpig_Wordpress_Model_Post
70
+ */
71
+ protected function _getCommentPost($postToken = 'comment_post_ID')
72
+ {
73
+ if ($postId = $this->getRequest()->getPost($postToken)) {
74
+ $post = Mage::getModel('wordpress/post')->load($postId);
75
+
76
+ if ($post->getId() > 0) {
77
+ return $post;
78
+ }
79
+ }
80
+
81
+ return false;
82
+ }
83
+
84
+ }
app/code/community/Fishpig/Wordpress/controllers/Post/ViewController.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_Post_ViewController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ protected function _init()
6
+ {
7
+ $this->_checkForPostedComment();
8
+
9
+ parent::_init();
10
+
11
+ if ($post = $this->_getPost()) {
12
+
13
+ if ($this->getSeoPlugin()->isEnabled()) {
14
+ $this->_title(($title = $post->getMetaTitle()) ? $title : $post->getPostTitle());
15
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
16
+ $headBlock->setDescription(($description = trim($post->getMetaDescription())) ? $description : strip_tags($post->getPostExcerpt()));
17
+ $headBlock->setKeywords($post->getMetaKeywords());
18
+ }
19
+ }
20
+ else {
21
+ $this->_title($post->getPostTitle());
22
+
23
+ if ($headBlock = $this->getLayout()->getBlock('head')) {
24
+ $headBlock->setDescription(strip_tags($post->getPostExcerpt()));
25
+ }
26
+ }
27
+
28
+ $this->_addCrumb('post', array('link' => $post->getPermalink(), 'label' => $post->getPostTitle()));
29
+ $this->_addCanonicalLink($post->getPermalink());
30
+ }
31
+
32
+ $this->_prepareSyntaxHighlighter();
33
+ }
34
+
35
+ protected function _prepareSyntaxHighlighter()
36
+ {
37
+ if (Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/display_post_view')) {
38
+ return parent::_prepareSyntaxHighlighter();
39
+ }
40
+
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Returns the current post model
46
+ *
47
+ * @return Fishpig_Wordpress_Model_Post
48
+ */
49
+ protected function _getPost()
50
+ {
51
+ return Mage::registry('wordpress_post');
52
+ }
53
+
54
+ protected function _checkForPostedComment()
55
+ {
56
+ if ($response = $this->getRequest()->getParam('cy')) {
57
+ Mage::getSingleton('core/session')->addSuccess($this->__(Mage::getStoreConfig('wordpress_blog/post_comments/success_msg')));
58
+ }
59
+ else if ($response = $this->getRequest()->getParam('cx')) {
60
+ Mage::getSingleton('core/session')->addError($this->__(Mage::getStoreConfig('wordpress_blog/post_comments/error_msg')));
61
+ }
62
+
63
+ return $this;
64
+ }
65
+ }
app/code/community/Fishpig/Wordpress/controllers/RedirectController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_RedirectController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ public function wpAdminAction()
7
+ {
8
+ return $this->_redirectTo(Mage::helper('wordpress')->getAdminUrl());
9
+ }
10
+
11
+ /**
12
+ * Forces a redirect to the given URL
13
+ *
14
+ * @param string $url
15
+ * @return bool
16
+ */
17
+ protected function _redirectTo($url)
18
+ {
19
+ return $this->getResponse()->setRedirect($url)->sendResponse();
20
+ }
21
+ }
app/code/community/Fishpig/Wordpress/controllers/SitemapController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_SitemapController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ public function indexAction()
6
+ {
7
+ if (Mage::getStoreConfigFlag('wordpress_blog/xml_sitemap/enabled')) {
8
+ // $map = Mage::getModel('wordpress/sitemap')->loadByStore(Mage::app()->getStore()->getId(), true);
9
+
10
+ try {
11
+ $this->getResponse()
12
+ ->setHeader('Content-Type','text/xml')
13
+ ->setBody($this->_getSitemapXml());
14
+ }
15
+ catch (Exception $e) {
16
+ $this->_helper()->log($e->getMessage());
17
+ throw $e;
18
+ }
19
+ }
20
+ else {
21
+ $this->_forward('noRoute');
22
+ }
23
+ }
24
+
25
+ protected function _getSitemapXml()
26
+ {
27
+ $ch = curl_init();
28
+ curl_setopt($ch, CURLOPT_URL, $this->_helper()->getBaseUrl('sitemap.xml'));
29
+ curl_setopt($ch, CURLOPT_HEADER, 0);
30
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
31
+ return curl_exec($ch);
32
+ }
33
+
34
+ }
app/code/community/Fishpig/Wordpress/controllers/TagController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Fishpig_Wordpress_TagController extends Fishpig_Wordpress_Controller_Abstract
4
+ {
5
+ /**
6
+ * Initialise the current category
7
+ */
8
+ protected function _init()
9
+ {
10
+ parent::_init();
11
+
12
+ if ($postTag = $this->_initPostTag()) {
13
+
14
+ $this->register('wordpress_post_tag', $postTag)
15
+ ->_title(ucwords($postTag->getName()))
16
+ ->_addCrumb('tags', array('link' => $postTag->getAllTagsUrl(), 'label' => $this->__('Tags')))
17
+ ->_addCrumb('tag', array('link' => $postTag->getUrl(), 'label' => ucwords($postTag->getName())))
18
+ ->_addCanonicalLink($postTag->getUrl())
19
+ ->_prepareSyntaxHighlighter();
20
+
21
+ }
22
+ else {
23
+ $this->throwInvalidObjectException('tag');
24
+ }
25
+
26
+ return $this;
27
+ }
28
+
29
+ protected function _prepareSyntaxHighlighter()
30
+ {
31
+ if (Mage::getStoreConfigFlag('wordpress_blog/syntaxhighlighter/display_post_list')) {
32
+ return parent::_prepareSyntaxHighlighter();
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Load user based on URI
40
+ *
41
+ * @return Fishpig_Wordpress_Model_User
42
+ */
43
+ protected function _initPostTag()
44
+ {
45
+ if ($slug = urldecode($this->getRequest()->getParam('tag'))) {
46
+ if ($postTag = Mage::getModel('wordpress/post_tag')->load($slug, 'slug')) {
47
+ if ($postTag->getId() > 0) {
48
+ return $postTag;
49
+ }
50
+ }
51
+ }
52
+
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * List all tags with associated posts
58
+ *
59
+ */
60
+ public function listAction()
61
+ {
62
+ parent::_init();
63
+
64
+ $this->_title($this->__('Tag Archives'))
65
+ ->_addCrumb('tags', array('link' => $this->_helper('post')->getTagsUrl(), 'label' => $this->__('Tags')))
66
+ ->_addCanonicalLink($this->_helper('post')->getTagsUrl())
67
+ ->renderLayout();
68
+ }
69
+ }
app/code/community/Fishpig/Wordpress/etc/adminhtml.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <adminhtml>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <wordpress translate="title" module="wordpress">
15
+ <title>WordPress Database and Integration Settings</title>
16
+ <sort_order>100</sort_order>
17
+ </wordpress>
18
+ <wordpress_blog translate="title" module="wordpress">
19
+ <title>WordPress Blog Display Settings</title>
20
+ <sort_order>101</sort_order>
21
+ </wordpress_blog>
22
+ <wordpress_admin translate="title" module="wordpress">
23
+ <title>WordPress Admin Settings</title>
24
+ <sort_order>102</sort_order>
25
+ </wordpress_admin>
26
+ </children>
27
+ </config>
28
+ </children>
29
+ </system>
30
+ <wordpress translate="title" module="wordpress">
31
+ <title>WordPress</title>
32
+ <children>
33
+ <auto_login translate="title">
34
+ <title>WP Admin</title>
35
+ <sort_order>89</sort_order>
36
+ </auto_login>
37
+ <configuration translate="title">
38
+ <title>Settings</title>
39
+ <sort_order>99</sort_order>
40
+ </configuration>
41
+ <support_bugs translate="title">
42
+ <title>Support / Bugs</title>
43
+ <sort_order>109</sort_order>
44
+ </support_bugs>
45
+ </children>
46
+ </wordpress>
47
+ </children>
48
+ </admin>
49
+ </resources>
50
+ </acl>
51
+ </adminhtml>
app/code/community/Fishpig/Wordpress/etc/config.xml ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Fishpig_Wordpress>
5
+ <version>0.8.6</version>
6
+ </Fishpig_Wordpress>
7
+ </modules>
8
+ <global>
9
+ <events>
10
+ <controller_front_init_routers>
11
+ <observers>
12
+ <wp_databaseSetup>
13
+ <type>singleton</type>
14
+ <class>wordpress/observer_databaseSetup</class>
15
+ <method>initConnection</method>
16
+ </wp_databaseSetup>
17
+ <wp_initRouter>
18
+ <type>singleton</type>
19
+ <class>Fishpig_Wordpress_Controller_Router</class>
20
+ <method>initController</method>
21
+ </wp_initRouter>
22
+ </observers>
23
+ </controller_front_init_routers>
24
+ </events>
25
+ <blocks>
26
+ <wordpress>
27
+ <class>Fishpig_Wordpress_Block</class>
28
+ </wordpress>
29
+ </blocks>
30
+ <models>
31
+ <wordpress>
32
+ <class>Fishpig_Wordpress_Model</class>
33
+ <resourceModel>wordpress_mysql4</resourceModel>
34
+ </wordpress>
35
+ <wordpress_mysql4>
36
+ <class>Fishpig_Wordpress_Model_Mysql4</class>
37
+ <entities>
38
+ <post>
39
+ <table>posts</table>
40
+ </post>
41
+ <page>
42
+ <table>posts</table>
43
+ </page>
44
+ <post_category>
45
+ <table>terms</table>
46
+ </post_category>
47
+ <link_category>
48
+ <table>terms</table>
49
+ </link_category>
50
+ <link>
51
+ <table>links</table>
52
+ </link>
53
+ <option>
54
+ <table>options</table>
55
+ </option>
56
+ <image>
57
+ <table>posts</table>
58
+ </image>
59
+ <user>
60
+ <table>users</table>
61
+ </user>
62
+ <post_comment>
63
+ <table>comments</table>
64
+ </post_comment>
65
+ <post_tag>
66
+ <table>terms</table>
67
+ </post_tag>
68
+ <admin_user>
69
+ <table>wordpress_autologin</table>
70
+ </admin_user>
71
+ </entities>
72
+ </wordpress_mysql4>
73
+ </models>
74
+ <helpers>
75
+ <wordpress>
76
+ <class>Fishpig_Wordpress_Helper</class>
77
+ </wordpress>
78
+ </helpers>
79
+ <resources>
80
+ <wordpress_setup>
81
+ <setup>
82
+ <module>Fishpig_Wordpress</module>
83
+ </setup>
84
+ <connection>
85
+ <use>core_setup</use>
86
+ </connection>
87
+ </wordpress_setup>
88
+ </resources>
89
+ </global>
90
+ <frontend>
91
+ <translate>
92
+ <modules>
93
+ <Fishpig_Wordpress>
94
+ <files>
95
+ <default>Fishpig_Wordpress.csv</default>
96
+ </files>
97
+ </Fishpig_Wordpress>
98
+ </modules>
99
+ </translate>
100
+ <layout>
101
+ <updates>
102
+ <wordpress>
103
+ <file>wordpress.xml</file>
104
+ </wordpress>
105
+ </updates>
106
+ </layout>
107
+ </frontend>
108
+ <adminhtml>
109
+ <menu>
110
+ <wordpress>
111
+ <title>WordPress</title>
112
+ <sort_order>89</sort_order>
113
+ <children>
114
+ <auto_login>
115
+ <title>WP Admin</title>
116
+ <sort_order>6</sort_order>
117
+ <action>wordpress/adminhtml_redirect</action>
118
+ <children>
119
+ <dashboard>
120
+ <title>Dashboard</title>
121
+ <action>wordpress/adminhtml_redirect</action>
122
+ <target>_blank</target>
123
+ </dashboard>
124
+ <posts>
125
+ <title>Posts</title>
126
+ <action>wordpress/adminhtml_redirect/index/wp_page/posts</action>
127
+ </posts>
128
+ <media>
129
+ <title>Media</title>
130
+ <action>wordpress/adminhtml_redirect/index/wp_page/media</action>
131
+ </media>
132
+ <links>
133
+ <title>Links</title>
134
+ <action>wordpress/adminhtml_redirect/index/wp_page/links</action>
135
+ </links>
136
+ <pages>
137
+ <title>Pages</title>
138
+ <action>wordpress/adminhtml_redirect/index/wp_page/pages</action>
139
+ </pages>
140
+ <comments>
141
+ <title>Comments</title>
142
+ <action>wordpress/adminhtml_redirect/index/wp_page/comments</action>
143
+ </comments>
144
+ <appearance>
145
+ <title>Appearance</title>
146
+ <action>wordpress/adminhtml_redirect/index/wp_page/appearance</action>
147
+ </appearance>
148
+ <plugins>
149
+ <title>Plugins</title>
150
+ <action>wordpress/adminhtml_redirect/index/wp_page/plugins</action>
151
+ </plugins>
152
+ <users>
153
+ <title>Users</title>
154
+ <action>wordpress/adminhtml_redirect/index/wp_page/users</action>
155
+ </users>
156
+ <tools>
157
+ <title>Tools</title>
158
+ <action>wordpress/adminhtml_redirect/index/wp_page/tools</action>
159
+ </tools>
160
+ <settings>
161
+ <title>Settings</title>
162
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings</action>
163
+ <children>
164
+ <general>
165
+ <title>General</title>
166
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings</action>
167
+ </general>
168
+ <writing>
169
+ <title>Writing</title>
170
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/writing</action>
171
+ </writing>
172
+ <reading>
173
+ <title>Reading</title>
174
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/reading</action>
175
+ </reading>
176
+ <discussion>
177
+ <title>Discussion</title>
178
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/discussion</action>
179
+ </discussion>
180
+ <media>
181
+ <title>Media</title>
182
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/media</action>
183
+ </media>
184
+ <privacy>
185
+ <title>Privacy</title>
186
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/privacy</action>
187
+ </privacy>
188
+ <permalink>
189
+ <title>Permalink</title>
190
+ <action>wordpress/adminhtml_redirect/index/wp_page/settings/wp_page_option/permalink</action>
191
+ </permalink>
192
+ </children>
193
+ </settings>
194
+ </children>
195
+ </auto_login>
196
+ <configuration>
197
+ <title>Settings</title>
198
+ <sort_order>46</sort_order>
199
+ <action>adminhtml/system_config/edit/section/wordpress</action>
200
+ <children>
201
+ <setup>
202
+ <title>Database / Integration</title>
203
+ <sort_order>6</sort_order>
204
+ <action>adminhtml/system_config/edit/section/wordpress</action>
205
+ </setup>
206
+ <posts_pages>
207
+ <title>Blog / Plugins</title>
208
+ <sort_order>11</sort_order>
209
+ <action>adminhtml/system_config/edit/section/wordpress_blog/</action>
210
+ </posts_pages>
211
+ <admin_settings>
212
+ <title>Admin Settings</title>
213
+ <sort_order>16</sort_order>
214
+ <action>adminhtml/system_config/edit/section/wordpress_admin/</action>
215
+ </admin_settings>
216
+ <auto_login>
217
+ <title>WP Auto-Login Details</title>
218
+ <sort_order>21</sort_order>
219
+ <action>wordpress/adminhtml_wpAdmin/login</action>
220
+ </auto_login>
221
+ </children>
222
+ </configuration>
223
+ <support_bugs>
224
+ <title>Support / Bugs</title>
225
+ <sort_order>51</sort_order>
226
+ <action>wordpress/adminhtml_support/index/</action>
227
+ </support_bugs>
228
+ </children>
229
+ </wordpress>
230
+ </menu>
231
+ <layout>
232
+ <updates>
233
+ <wordpress>
234
+ <file>wordpress.xml</file>
235
+ </wordpress>
236
+ </updates>
237
+ </layout>
238
+ <events>
239
+ <admin_system_config_changed_section_wordpress>
240
+ <observers>
241
+ <wp_config_saveAfter>
242
+ <type>singleton</type>
243
+ <class>wordpress/observer_adminhtml_system_config_saveAfter</class>
244
+ <method>postLogic</method>
245
+ </wp_config_saveAfter>
246
+ </observers>
247
+ </admin_system_config_changed_section_wordpress>
248
+ <catalog_product_save_after>
249
+ <observers>
250
+ <wp_product_saveAssociations>
251
+ <type>singleton</type>
252
+ <class>wordpress/observer_adminhtml_catalog_product_saveAssociations</class>
253
+ <method>saveAssociations</method>
254
+ </wp_product_saveAssociations>
255
+ </observers>
256
+ </catalog_product_save_after>
257
+ </events>
258
+ <!-- Added for Magento 1.3 compatility -->
259
+ <acl>
260
+ <resources>
261
+ <all>
262
+ <title>Allow Everything</title>
263
+ </all>
264
+ <admin>
265
+ <children>
266
+ <system>
267
+ <children>
268
+ <config>
269
+ <children>
270
+ <wordpress>
271
+ <title>WordPress Database and Integration Settings</title>
272
+ <sort_order>100</sort_order>
273
+ </wordpress>
274
+ <wordpress_blog>
275
+ <title>WordPress Blog Display Settings</title>
276
+ <sort_order>101</sort_order>
277
+ </wordpress_blog>
278
+ <wordpress_admin>
279
+ <title>WordPress Admin Settings</title>
280
+ <sort_order>102</sort_order>
281
+ </wordpress_admin>
282
+ </children>
283
+ </config>
284
+ </children>
285
+ </system>
286
+ <wordpress translate="title" module="wordpress">
287
+ <title>WordPress</title>
288
+ <children>
289
+ <auto_login translate="title">
290
+ <title>WP Admin</title>
291
+ <sort_order>89</sort_order>
292
+ </auto_login>
293
+ <configuration translate="title">
294
+ <title>Settings</title>
295
+ <sort_order>99</sort_order>
296
+ </configuration>
297
+ <support_bugs translate="title">
298
+ <title>Support / Bugs</title>
299
+ <sort_order>109</sort_order>
300
+ </support_bugs>
301
+ </children>
302
+ </wordpress>
303
+ </children>
304
+ </admin>
305
+ </resources>
306
+ </acl>
307
+ </adminhtml>
308
+ <admin>
309
+ <routers>
310
+ <wordpress>
311
+ <use>admin</use>
312
+ <args>
313
+ <module>Fishpig_Wordpress</module>
314
+ <frontName>wordpress</frontName>
315
+ </args>
316
+ </wordpress>
317
+ </routers>
318
+ </admin>
319
+ <default>
320
+ <wordpress>
321
+ <database>
322
+ <is_different_db>0</is_different_db>
323
+ <host/>
324
+ <username/>
325
+ <password/>
326
+ <dbname/>
327
+ <charset>utf8</charset>
328
+ <table_prefix>wp_</table_prefix>
329
+ </database>
330
+ <integration>
331
+ <full>0 </full>
332
+ <route>blog</route>
333
+ </integration>
334
+ <debug>
335
+ <log_enabled>1</log_enabled>
336
+ <disable_auto_test>0</disable_auto_test>
337
+ </debug>
338
+ </wordpress>
339
+ <wordpress_blog>
340
+ <filters>
341
+ <content_filters>shortcodes,auto_paragraph</content_filters>
342
+ <excerpt_filters>shortcodes</excerpt_filters>
343
+ <shortcodes>caption,youtube,product,associatedProducts</shortcodes>
344
+ </filters>
345
+ <posts>
346
+ <more_anchor>Continue Reading</more_anchor>
347
+ </posts>
348
+ <post_comments>
349
+ <success_msg>Your comment has been accepted for moderation and will be published shortly</success_msg>
350
+ <error_msg>There was an error posting your comment</error_msg>
351
+ </post_comments>
352
+ <syntaxhighlighter>
353
+ <enabled>0</enabled>
354
+ <display_post_view>1</display_post_view>
355
+ <display_post_list>1</display_post_list>
356
+ <css_theme>Default</css_theme>
357
+ </syntaxhighlighter>
358
+ <rss_feed>
359
+ <enabled>1</enabled>
360
+ </rss_feed>
361
+ <seo>
362
+ <aiosp_enabled>0</aiosp_enabled>
363
+ </seo>
364
+ <xml_sitemap>
365
+ <enabled>1</enabled>
366
+ </xml_sitemap>
367
+ </wordpress_blog>
368
+ <wordpress_admin>
369
+ <wp_admin>
370
+ <links_external_target>1</links_external_target>
371
+ </wp_admin>
372
+ </wordpress_admin>
373
+ </default>
374
+ </config>
app/code/community/Fishpig/Wordpress/etc/system.xml ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <wordpress translate="label" module="wordpress">
5
+ <label>WordPress</label>
6
+ <sort_order>500</sort_order>
7
+ </wordpress>
8
+ </tabs>
9
+ <sections>
10
+ <wordpress translate="label" module="wordpress">
11
+ <label>Database / Integration</label>
12
+ <tab>wordpress</tab>
13
+ <sort_order>501</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <database>
19
+ <label>Database</label>
20
+ <comment>
21
+ <![CDATA[<p style="font-weight:bold; padding:10px 5px;">If you are unsure about any of your WordPress database information, please consult your WordPress configuration file (<a href="http://fishpig.co.uk/wordpress-magento-integration/configuration/" style="text-decoration:none;" target="_blank">wp-config.php</a>). All neccessary information can be retrieved from this file.</p>]]>
22
+ </comment>
23
+ <sort_order>6</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <is_different_db>
29
+ <label>Database Location</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>wordpress/system_config_source_database_location</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </is_different_db>
37
+ <host>
38
+ <label>Host</label>
39
+ <comment>eg. localhost</comment>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>6</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <validate>required-entry</validate>
46
+ <depends><is_different_db>1</is_different_db></depends>
47
+ </host>
48
+ <username>
49
+ <label>Username</label>
50
+ <comment>This is your database username and NOT your WordPress username</comment>
51
+ <frontend_type>text</frontend_type>
52
+ <backend_model>wordpress/system_config_backend_encrypted</backend_model>
53
+ <sort_order>11</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <validate>required-entry</validate>
58
+ <depends><is_different_db>1</is_different_db></depends>
59
+ </username>
60
+ <password>
61
+ <label>Password</label>
62
+ <comment>This is your database password and NOT your WordPress password</comment>
63
+ <frontend_type>password</frontend_type>
64
+ <backend_model>wordpress/system_config_backend_encrypted</backend_model>
65
+ <sort_order>16</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ <validate>required-entry</validate>
70
+ <depends><is_different_db>1</is_different_db></depends>
71
+ </password>
72
+ <dbname>
73
+ <label>Database Name</label>
74
+ <frontend_type>text</frontend_type>
75
+ <backend_model>wordpress/system_config_backend_encrypted</backend_model>
76
+ <sort_order>21</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ <validate>required-entry</validate>
81
+ <depends><is_different_db>1</is_different_db></depends>
82
+ </dbname>
83
+ <charset>
84
+ <label>Database Charset</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>26</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <depends><is_different_db>1</is_different_db></depends>
91
+ </charset>
92
+ <table_prefix>
93
+ <label>Table Prefix</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>31</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </table_prefix>
100
+ </fields>
101
+ </database>
102
+ <integration>
103
+ <label>Integration</label>
104
+ <comment>
105
+ <![CDATA[<p style="font-weight:bold; padding:10px 5px;">For more information about the different integration levels and the blog route field, please read <a href="http://fishpig.co.uk/wordpress-magento-integration/configuration/" style="text-decoration:none;" target="_blank">this article</a>.</p>]]>
106
+ </comment>
107
+ <sort_order>16</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ <fields>
112
+ <full>
113
+ <label>Integration Level</label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>wordpress/system_config_source_integration</source_model>
116
+ <sort_order>6</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </full>
121
+ <route>
122
+ <label>Blog Route</label>
123
+ <comment><![CDATA[With your current settings you would access your blog using the following URL:<br/><br/><strong class="wp-blog-url"> </strong><br/><br/>]]></comment>
124
+ <frontend_type>text</frontend_type>
125
+ <validate>required-entry</validate>
126
+ <sort_order>11</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ <validate>required-entry</validate>
131
+ <depends><full>1</full></depends>
132
+ </route>
133
+ </fields>
134
+ </integration>
135
+ <debug>
136
+ <label>Logging and Debugging</label>
137
+ <comment><![CDATA[<p style="font-weight:bold; padding:10px 5px;">Your WordPress log file is located in <a href="#">var/log/wordpress.log</a>. For WordPress logs to be created, Magento logging must be enabled. Please include your log file when contacting support.</p>]]></comment>
138
+ <sort_order>21</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_store>1</show_in_store>
141
+ <show_in_website>1</show_in_website>
142
+ <fields>
143
+ <log_enabled>
144
+ <label>Enable Logging</label>
145
+ <sort_order>6</sort_order>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>adminhtml/system_config_source_yesno</source_model>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_store>1</show_in_store>
150
+ <show_in_website>1</show_in_website>
151
+ </log_enabled>
152
+ </fields>
153
+ </debug>
154
+ </groups>
155
+ </wordpress>
156
+ <wordpress_blog translate="label" module="wordpress">
157
+ <label>Blog / Plugins</label>
158
+ <tab>wordpress</tab>
159
+ <sort_order>506</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_store>1</show_in_store>
162
+ <show_in_website>1</show_in_website>
163
+ <groups>
164
+ <filters>
165
+ <label><![CDATA[Filters &amp; Shortcodes]]></label>
166
+ <sort_order>6</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>1</show_in_store>
170
+ <fields>
171
+ <content_filters>
172
+ <label>Content Filters</label>
173
+ <comment>These are default WordPress filters that are automatically applied to your page/post content. If you are unsure what they do, it is probably best to select them all.</comment>
174
+ <sort_order>6</sort_order>
175
+ <frontend_type>multiselect</frontend_type>
176
+ <source_model>wordpress/system_config_source_filters_content</source_model>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ </content_filters>
181
+ <excerpt_filters>
182
+ <label>Excerpt Filters</label>
183
+ <comment>These are default WordPress filters that are automatically applied to your page/post excerpt. If you are unsure what they do, it is probably best to select them all.</comment>
184
+ <sort_order>6</sort_order>
185
+ <frontend_type>multiselect</frontend_type>
186
+ <source_model>wordpress/system_config_source_filters_excerpt</source_model>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ </excerpt_filters>
191
+ <shortcodes>
192
+ <label>Shortcodes</label>
193
+ <comment>To enable shortcodes, you must select the 'Render Shortcodes' filter above</comment>
194
+ <sort_order>11</sort_order>
195
+ <frontend_type>multiselect</frontend_type>
196
+ <source_model>wordpress/system_config_source_shortcodes</source_model>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ </shortcodes>
201
+ </fields>
202
+ </filters>
203
+ <posts>
204
+ <label><![CDATA[Post Display]]></label>
205
+ <sort_order>16</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ <fields>
210
+ <more_anchor>
211
+ <label>Read More Anchor Test</label>
212
+ <comment>eg. Read More</comment>
213
+ <sort_order>6</sort_order>
214
+ <frontend_type>text</frontend_type>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ </more_anchor>
219
+ </fields>
220
+ </posts>
221
+ <post_comments>
222
+ <label><![CDATA[Comments]]></label>
223
+ <sort_order>18</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ <fields>
228
+ <success_msg>
229
+ <label>Success Message</label>
230
+ <comment></comment>
231
+ <sort_order>6</sort_order>
232
+ <frontend_type>text</frontend_type>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>1</show_in_store>
236
+ </success_msg>
237
+ <error_msg>
238
+ <label>Error Message</label>
239
+ <comment></comment>
240
+ <sort_order>7</sort_order>
241
+ <frontend_type>text</frontend_type>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </error_msg>
246
+ </fields>
247
+ </post_comments>
248
+ <syntaxhighlighter>
249
+ <label>Syntax Highlighter</label>
250
+ <sort_order>19</sort_order>
251
+ <show_in_default>1</show_in_default>
252
+ <show_in_website>1</show_in_website>
253
+ <show_in_store>1</show_in_store>
254
+ <fields>
255
+ <enabled>
256
+ <label>Enabled</label>
257
+ <comment>Enables the Syntax Highlighter plugin developed by Alex Gorbatchev</comment>
258
+ <sort_order>1</sort_order>
259
+ <frontend_type>select</frontend_type>
260
+ <source_model>adminhtml/system_config_source_yesno</source_model>
261
+ <show_in_default>1</show_in_default>
262
+ <show_in_website>1</show_in_website>
263
+ <show_in_store>1</show_in_store>
264
+ </enabled>
265
+ <display_post_view>
266
+ <label>Highlight syntax when viewing full post</label>
267
+ <sort_order>6</sort_order>
268
+ <frontend_type>select</frontend_type>
269
+ <source_model>adminhtml/system_config_source_yesno</source_model>
270
+ <show_in_default>1</show_in_default>
271
+ <show_in_website>1</show_in_website>
272
+ <show_in_store>1</show_in_store>
273
+ <depends><enabled>1</enabled></depends>
274
+ </display_post_view>
275
+ <display_post_list>
276
+ <label>Highlight syntax when viewing a list of posts</label>
277
+ <sort_order>8</sort_order>
278
+ <frontend_type>select</frontend_type>
279
+ <source_model>adminhtml/system_config_source_yesno</source_model>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>1</show_in_store>
283
+ <depends><enabled>1</enabled></depends>
284
+ </display_post_list>
285
+ <css_theme>
286
+ <label>CSS Theme</label>
287
+ <sort_order>12</sort_order>
288
+ <frontend_type>select</frontend_type>
289
+ <source_model>wordpress/system_config_source_syntaxHighlighter_theme</source_model>
290
+ <show_in_default>1</show_in_default>
291
+ <show_in_website>1</show_in_website>
292
+ <show_in_store>1</show_in_store>
293
+ <depends><enabled>1</enabled></depends>
294
+ </css_theme>
295
+ </fields>
296
+ </syntaxhighlighter>
297
+ <rss_feed>
298
+ <label>RSS Feed</label>
299
+ <sort_order>21</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ <fields>
304
+ <enabled>
305
+ <label>Enabled</label>
306
+ <comment>eg. http://www.yoursite.com/blog/feed/</comment>
307
+ <sort_order>1</sort_order>
308
+ <frontend_type>select</frontend_type>
309
+ <source_model>adminhtml/system_config_source_yesno</source_model>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>1</show_in_website>
312
+ <show_in_store>1</show_in_store>
313
+ </enabled>
314
+ </fields>
315
+ </rss_feed>
316
+ <seo>
317
+ <label>SEO (BETA)</label>
318
+ <sort_order>26</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>1</show_in_store>
322
+ <fields>
323
+ <aiosp_enabled>
324
+ <label>All in One SEO Pack</label>
325
+ <comment>This feature is currently in BETA</comment>
326
+ <sort_order>1</sort_order>
327
+ <frontend_type>select</frontend_type>
328
+ <source_model>adminhtml/system_config_source_yesno</source_model>
329
+ <show_in_default>1</show_in_default>
330
+ <show_in_website>1</show_in_website>
331
+ <show_in_store>1</show_in_store>
332
+ </aiosp_enabled>
333
+ </fields>
334
+ </seo>
335
+ <xml_sitemap>
336
+ <label>XML Sitemap</label>
337
+ <sort_order>31</sort_order>
338
+ <show_in_default>1</show_in_default>
339
+ <show_in_website>1</show_in_website>
340
+ <show_in_store>1</show_in_store>
341
+ <fields>
342
+ <enabled>
343
+ <label>Enabled</label>
344
+ <comment>For this to work, you must have a sitemap.xml in your WordPress root folder. To create this file, install a WordPress Google XML Sitemap plugin in the WordPress Admin</comment>
345
+ <sort_order>1</sort_order>
346
+ <frontend_type>select</frontend_type>
347
+ <source_model>adminhtml/system_config_source_yesno</source_model>
348
+ <show_in_default>1</show_in_default>
349
+ <show_in_website>1</show_in_website>
350
+ <show_in_store>1</show_in_store>
351
+ </enabled>
352
+ </fields>
353
+ </xml_sitemap>
354
+ </groups>
355
+ </wordpress_blog>
356
+ <wordpress_admin translate="label" module="wordpress">
357
+ <label>Admin Settings</label>
358
+ <tab>wordpress</tab>
359
+ <sort_order>507</sort_order>
360
+ <show_in_default>1</show_in_default>
361
+ <show_in_store>1</show_in_store>
362
+ <show_in_website>1</show_in_website>
363
+ <groups>
364
+ <wp_admin>
365
+ <label>WP Admin</label>
366
+ <sort_order>6</sort_order>
367
+ <show_in_default>1</show_in_default>
368
+ <show_in_website>1</show_in_website>
369
+ <show_in_store>1</show_in_store>
370
+ <fields>
371
+ <links_external_target>
372
+ <label>Open Quick Links in a New Tab</label>
373
+ <sort_order>6</sort_order>
374
+ <frontend_type>select</frontend_type>
375
+ <source_model>adminhtml/system_config_source_yesno</source_model>
376
+ <show_in_default>1</show_in_default>
377
+ <show_in_website>1</show_in_website>
378
+ <show_in_store>1</show_in_store>
379
+ </links_external_target>
380
+ </fields>
381
+ </wp_admin>
382
+ </groups>
383
+ </wordpress_admin>
384
+ </sections>
385
+ </config>
app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ $installer->run("
6
+ DROP TABLE IF EXISTS {$this->getTable('wordpress_autologin')};
7
+ CREATE TABLE {$this->getTable('wordpress_autologin')} (
8
+ `autologin_id` int(11) unsigned NOT NULL auto_increment,
9
+ `username` varchar(40) NOT NULL default '',
10
+ `password` varchar(40) NOT NULL default '',
11
+ `user_id` int(9) unsigned NOT NULL default 0,
12
+ `store_id` int(9) unsigned NOT NULL default 0,
13
+ PRIMARY KEY (`autologin_id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
16
+ ALTER TABLE {$this->getTable('wordpress_autologin')} ADD UNIQUE ( `user_id`);
17
+
18
+ ");
19
+ $installer->endSetup();
app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-0.3.2-0.3.3.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ $installer->run("
6
+ DROP TABLE IF EXISTS {$this->getTable('wordpress_product_post')};
7
+ CREATE TABLE {$this->getTable('wordpress_product_post')} (
8
+ `product_id` int(11) unsigned NOT NULL default 0,
9
+ `post_id` int(11) unsigned NOT NULL default 0,
10
+ PRIMARY KEY (`product_id`,`post_id`)
11
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12
+
13
+ DROP TABLE IF EXISTS {$this->getTable('wordpress_product_category')};
14
+ CREATE TABLE {$this->getTable('wordpress_product_category')} (
15
+ `product_id` int(11) unsigned NOT NULL default 0,
16
+ `category_id` int(11) unsigned NOT NULL default 0,
17
+ PRIMARY KEY (`product_id`,`category_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+
20
+
21
+ ");
22
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/wordpress.xml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <default>
5
+ <reference name="before_body_end">
6
+ <block type="adminhtml/template" name="wordpress.adminLinks" template="wordpress/admin-links-js.phtml"/>
7
+ </reference>
8
+ </default>
9
+
10
+ <wordpress_adminhtml_wpadmin_login>
11
+ <reference name="left">
12
+ <block type="wordpress/adminhtml_autologin_tabs" name="wordpress.autologin.tabs"/>
13
+ </reference>
14
+ <reference name="content">
15
+ <block type="wordpress/adminhtml_autologin" name="wordpress.autologin">
16
+ <block type="wordpress/adminhtml_autologin_form" name="form"/>
17
+ </block>
18
+ </reference>
19
+ </wordpress_adminhtml_wpadmin_login>
20
+
21
+ <adminhtml_system_config_edit>
22
+ <reference name="content">
23
+ <block type="wordpress/adminhtml_system_config_wrapper" name="wordpress.test.results" before="-" template="wordpress/config/test/results.phtml">
24
+ <block type="wordpress/adminhtml_system_config_test_results_grid" name="wp_test_results" as="wp_test_results"/>
25
+ </block>
26
+ <block type="wordpress/adminhtml_template" name="wordpress.js-database" template="wordpress/config/js.phtml" after="-" />
27
+ </reference>
28
+ </adminhtml_system_config_edit>
29
+
30
+ <wordpress_adminhtml_support_index>
31
+ <reference name="content">
32
+ <block type="wordpress/adminhtml_support" name="wordpress_support">
33
+ <block type="wordpress/adminhtml_support_form" name="form" />
34
+ </block>
35
+ <block type="wordpress/adminhtml_template" name="support.js" after="-" template="wordpress/support/js.phtml"/>
36
+ </reference>
37
+ <reference name="left">
38
+ <block type="wordpress/adminhtml_support_tabs" name="wordpress_support.tabs"/>
39
+ </reference>
40
+ </wordpress_adminhtml_support_index>
41
+
42
+ <adminhtml_catalog_product_edit>
43
+ <reference name="product_tabs">
44
+ <action method="addTab">
45
+ <name>wp_posts</name>
46
+ <block>wordpress/adminhtml_catalog_product_edit_tab_post_grid</block>
47
+ </action>
48
+ <action method="addTab">
49
+ <name>wp_categories</name>
50
+ <block>wordpress/adminhtml_catalog_product_edit_tab_category_grid</block>
51
+ </action>
52
+ </reference>
53
+ </adminhtml_catalog_product_edit>
54
+
55
+ </layout>
app/design/adminhtml/default/default/template/wordpress/admin-links-js.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <script type="text/javascript">document.observe('dom:loaded', function() { $('nav').select('li').each(function(rootLi) {if($(rootLi).select('a')[0].select('span')[0].innerHTML=='<?php echo $this->__('WP Admin') ?>') {var ulObj=$(rootLi).select('ul')[0];$(rootLi).select('a')[0].target='_blank';fishpig_wpadmin_links(ulObj);}});function fishpig_wpadmin_links(ulObj){$(ulObj).select('li').each(function(liObj){$($(liObj).select('a')[0]).addClassName('wpadmin-link')});}});</script>
8
+ <?php if (Mage::getStoreConfigFlag('wordpress_admin/wp_admin/links_external_target')): ?>
9
+ <script type="text/javascript">document.observe('dom:loaded', function() {$$('a.wpadmin-link').each(function(a){a.target = '_blank';});});</script>
10
+ <?php endif; ?>
11
+ <?php if (false): ?>
12
+ <?php if (!Mage::app()->isSingleStoreMode()): ?>
13
+ <div id="wpadmin-doorway" class="no-display" style="bottom:0; height:100%; position:fixed; width:100%; z-index:101;">
14
+ <div class="fader" style="background:#000; bottom:0; height:100%; opacity:.3; position:fixed; width:100%; z-index:102;">
15
+ <input type="hidden" name="fishpig_wp_url_cache" id="fishpig_wp_url_cache" value="0"/>
16
+ </div>
17
+ <div id="wpadmin-doorway-inner" style="background:url('<?php echo $this->getSkinUrl('images/footer_bg.gif') ?>') repeat-x left bottom #fff; border:3px solid #6F8992; margin:100px auto 0; padding:20px; position:relative; width: 400px; z-index:102;">
18
+ <h2 style="font-size:2em; margin-bottom:4px;"><?php echo $this->__('WordPress Quick Links') ?></h2>
19
+ <p style="font-size:1.1em;"><?php echo $this->__('Select the store that is associated with the WordPress admin you want to go to') ?></p>
20
+ <?php $stores = Mage::getResourceModel('core/store_collection') ?>
21
+ <ul style="height:1%; list-style: disc inside none; margin-top:20px; overflow:hidden;">
22
+ <?php foreach($stores as $store): ?>
23
+ <li style="float:left; width: 33%;">
24
+ <a href="#" id="store-<?php echo $store->getId() ?>" class="fish-store-link"><?php echo $store->getName() ?></a>
25
+ </li>
26
+ <?php endforeach; ?>
27
+ </ul>
28
+ <p style="margin-top:20px;">
29
+ <button type="button" class="cancel scalable"><span><?php echo $this->__('Cancel') ?></span></button>
30
+ </p>
31
+ </div>
32
+ </div>
33
+ <script type="text/javascript">
34
+ document.observe('dom:loaded', function() {
35
+ $$('a.wpadmin-link').each(function(a){
36
+ $(a).observe('click', function(e) {
37
+ $('fishpig_wp_url_cache').value = a.href;
38
+ $('wpadmin-doorway').removeClassName('no-display');
39
+ Event.stop(e);
40
+ });
41
+ });
42
+
43
+ $$('a.fish-store-link').each(function(a) {
44
+ $(a).observe('click', function(e) {
45
+ a.href = $('fishpig_wp_url_cache').value + 'store_id/' + a.id.substring(6);
46
+ });
47
+ });
48
+ });
49
+ </script>
50
+ <?php endif; ?>
51
+ <?php endif; ?>
app/design/adminhtml/default/default/template/wordpress/config/js.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php if ($this->isWordpressSection()): ?>
8
+ <script type="text/javascript">
9
+ document.observe("dom:loaded", function() {
10
+ function fishpig_CleanUrlForCompare(url) {
11
+ if (url.charAt(url.length - 1) != '/') {
12
+ url = url + '/';
13
+ }
14
+
15
+ return url;
16
+ }
17
+
18
+ <?php if (Mage::getStoreConfigFlag('web/seo/use_rewrites')): ?>
19
+ var magentoBaseUrl = fishpig_CleanUrlForCompare('<?php echo Mage::getBaseUrl("web", false) ?>');
20
+ <?php else: ?>
21
+ var magentoBaseUrl = fishpig_CleanUrlForCompare('<?php echo Mage::getBaseUrl("link", false) ?>');
22
+ <?php endif; ?>
23
+
24
+ fishpig_CraftBlogUrl();
25
+
26
+ Event.observe('wordpress_integration_route', 'change', function () {
27
+ fishpig_CraftBlogUrl();
28
+ });
29
+
30
+ function fishpig_CraftBlogUrl() {
31
+ var url = fishpig_CleanUrlForCompare(magentoBaseUrl + $('wordpress_integration_route').getValue().toString());
32
+
33
+ $$('.wp-blog-url').each( function(item) {
34
+ item.innerHTML = url;
35
+ });
36
+ }
37
+ });
38
+ </script>
39
+ <?php endif; ?>
app/design/adminhtml/default/default/template/wordpress/config/test/results.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php if ($this->isWordpressSection() && $this->isAclValid()): ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tbody>
11
+ <tr>
12
+ <td>
13
+ <h3><?php echo $this->__('Fishpig\'s Magento &amp; WordPress Integration') ?></h3>
14
+ </td>
15
+ <td class="form-buttons">
16
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_donate">
17
+ <input type="hidden" name="cmd" value="_s-xclick">
18
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYCwJZNThjvxQVYTltjWJKNGrXgNLs7bjSqB0rz1q/gm8E8YT+4Morx0ido4ZArrejfoyJDWWlsw+1WVdVldmRhY4RLL0x7qi+wD2lOSlwbpMlXrEFHuRrpWulwstbLNZHNeTRTJYVjpbMkfwCp7o2dN/iecrfNPh08I7bb4tMev7TELMAkGBSsOAwIaBQAwgcQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI8cRoe76hW2+AgaDGYHhM9JCpXgzScY511yR18mPZJK4OmXKtg3wtE4f4Y8fptrDhJlR9WtBKzgagiWmDcQTzemU9NXvhvWad3WHHgkMJC9oHRFnYj6T1Uv/xtMQS8nj8PXHjp6e2p0j3gdqI2PIMB4ltRG/+QGcJmjG6w7dlZbLx4HdlsyaDm035hsqUOGU2rSbehjDQQXaTONfi6H9QPpFDae0YJ9uWaCSYoIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTAwOTAxMTgyMjM3WjAjBgkqhkiG9w0BCQQxFgQUi6IO5Z4V00+fHWqlML5++7G/GpAwDQYJKoZIhvcNAQEBBQAEgYAcK/M8bD5/c6Ay7iMDujiLzIibLfQuUpEaFQrcRyLIXPD085/6cbz+zEuyfLkYuVnFsm2RT5qMJ9NKhz2TWgl0+MTGU+lxdi8Quvas56CRHpvrM6/K/fyrX1VXGD6JmtXbMu+cKydGvb2QT8uhAMmUg5wP4GwZCPksmz24/ZGajg==-----END PKCS7-----">
19
+ <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
20
+ <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>
21
+ </form>
22
+ </td>
23
+ </tr>
24
+ </tbody>
25
+ </table>
26
+ </div>
27
+ <?php if ($results = $this->getChildHtml('wp_test_results')): ?>
28
+ <?php echo $results ?>
29
+ <?php endif; ?>
30
+ <?php endif; ?>
app/design/adminhtml/default/default/template/wordpress/support/index.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <div class="entry-edit left" style="width:49%;">
8
+ <div class="entry-edit-head">
9
+ <h4><?php echo $this->__('Support Tickets') ?></h4>
10
+ </div>
11
+ <fieldset class="config">
12
+ <legend><?php echo $this->__('Support Tickets') ?></legend>
13
+ <p>
14
+ If you're struggling to install the module or can't quite achieve the configuration you desire, you can request support by clicking the button below.
15
+ </p>
16
+ <p>Before requesting support, please try and fix the problem yourself. In doing so, you may learn a little about how the module and Magento work.
17
+ <p>&nbsp;</p>
18
+ <p>
19
+ <button type="button" id="submit-support-ticket"><span><?php echo $this->__('Create a Support Ticket') ?></span></button>
20
+ </p>
21
+ </fieldset>
22
+ </div>
23
+ <div class="entry-edit right" style="width:49%;">
24
+ <div class="entry-edit-head">
25
+ <h4><?php echo $this->__('Bug Reports') ?></h4>
26
+ </div>
27
+ <fieldset class="config">
28
+ <legend><?php echo $this->__('Bug Reports') ?></legend>
29
+ <p>
30
+ Although the module has been tested, there are so many variables that it is impossible to test every single setup. This means that bugs often slip through the net into the live version. If you spot a bug or see something that just doesn't seem right, please let us know!
31
+ </p>
32
+ <p>&nbsp;</p>
33
+ <p>
34
+ <button type="button" id="submit-bug-report"><span><?php echo $this->__('Create a Bug Report') ?></span></button>
35
+ </p>
36
+ </fieldset>
37
+ </div>
38
+ <div style="clear:both;"></div>
app/design/adminhtml/default/default/template/wordpress/support/js.phtml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php $tabInnerHTML = '<span title="The information in this tab has been changed." class="changed"></span><span title="This tab contains invalid data. Please solve the problem before saving." class="error"></span>'; ?>
8
+ <script type="text/javascript">
9
+ //<![CDATA[
10
+ document.observe("dom:loaded", function() {
11
+
12
+ $('submit-support-ticket').observe('click', function() {
13
+ fishpig_SetSupport(0);
14
+ });
15
+
16
+ $('submit-bug-report').observe('click', function() {
17
+ fishpig_SetSupport(1);
18
+ });
19
+
20
+ $('enquiry_type').observe('change', function() {
21
+ fishpig_SetSupport(this.selectedIndex);
22
+ });
23
+
24
+ $$('.support-previous').each(function(e) {
25
+ e.observe('click', function() {
26
+ fish_PreviousTab();
27
+ });
28
+ });
29
+
30
+ function fish_PreviousTab()
31
+ {
32
+ try {
33
+ var tab = $('support_tabs').select('li a.active')[0];
34
+ var newTab = tab.up().previous('li').select('a')[0];
35
+ support_tabsJsTabs.showTabContent(newTab);
36
+ }
37
+ catch (e) {}
38
+ }
39
+
40
+ $$('.support-next').each(function(e) {
41
+ e.observe('click', function() {
42
+ fish_NextTab();
43
+ });
44
+ });
45
+
46
+ function fish_NextTab()
47
+ {
48
+ try {
49
+ var tab = $('support_tabs').select('li a.active')[0];
50
+ var newTab = tab.up().next('li').select('a')[0];
51
+ support_tabsJsTabs.showTabContent(newTab);
52
+ }
53
+ catch (e) {}
54
+ }
55
+
56
+
57
+
58
+ function fishpig_SetSupport(selectIndex)
59
+ {
60
+ $('enquiry_type').selectedIndex = selectIndex;
61
+ $$('.enquirytype').each(function(e) {
62
+ e.innerHTML = $('enquiry_type').value;
63
+ });
64
+
65
+ fish_NextTab();
66
+ }
67
+
68
+ <?php if (((int)$this->getParam('type')) == 1): ?>
69
+ fishpig_SetSupport(1);
70
+ fish_NextTab();
71
+ <?php endif; ?>
72
+
73
+ });
74
+ //]]>
75
+ </script>
app/design/adminhtml/default/default/template/wordpress/support/tab/complete.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <div class="entry-edit left" style="width:49%;">
8
+ <div class="entry-edit-head">
9
+ <h4>Submit your <span class="enquirytype"><?php echo $this->__('Support Ticket') ?></span></h4>
10
+ </div>
11
+ <fieldset class="config">
12
+ <legend>Submit your <span class="enquirytype"><?php echo $this->__('Support Ticket ') ?></span></legend>
13
+ <p>
14
+ Click the button below to complete your <span class="enquirytype" style="text-transform:lower;">Support Ticket </span>. Please allow us 24 hours to respond to your message.
15
+ </p>
16
+ <p>&nbsp;</p>
17
+ <p>
18
+ <button type="button" onclick="editForm.submit();" class="scalable save"><span>Send your <span class="enquirytype" style="background:none !important;padding-left:0;"><?php echo $this->__('Support Ticket') ?></span></span></button>
19
+ </p>
20
+ </fieldset>
21
+ </div>
22
+ <div class="entry-edit right" style="width:49%;">
23
+ <div class="entry-edit-head">
24
+ <h4><?php echo $this->__('Help us out!') ?></h4>
25
+ </div>
26
+ <fieldset class="config">
27
+ <legend><?php echo $this->__('Help us out!') ?></legend>
28
+ <p>
29
+ Fishpig's Magento WordPress integration extension has taken over 100 hours to get it to where it is now and we spend roughly 20 hours a week improving it further and offering free support. If you like this module and are using it in a commercial environment, please consider donating to us. All money will be used to further enhance the module and will allow us to keep the module, as well as support free of charge.
30
+ </p>
31
+ <p>
32
+ If you are unable to donate, you can help us just as much by writing good reviews about the module and maybe even tutorials to help other users overcome bugs you have experienced.
33
+ </p>
34
+ <p>&nbsp;</p>
35
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_donate">
36
+ <input type="hidden" name="cmd" value="_s-xclick">
37
+ <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYCwJZNThjvxQVYTltjWJKNGrXgNLs7bjSqB0rz1q/gm8E8YT+4Morx0ido4ZArrejfoyJDWWlsw+1WVdVldmRhY4RLL0x7qi+wD2lOSlwbpMlXrEFHuRrpWulwstbLNZHNeTRTJYVjpbMkfwCp7o2dN/iecrfNPh08I7bb4tMev7TELMAkGBSsOAwIaBQAwgcQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI8cRoe76hW2+AgaDGYHhM9JCpXgzScY511yR18mPZJK4OmXKtg3wtE4f4Y8fptrDhJlR9WtBKzgagiWmDcQTzemU9NXvhvWad3WHHgkMJC9oHRFnYj6T1Uv/xtMQS8nj8PXHjp6e2p0j3gdqI2PIMB4ltRG/+QGcJmjG6w7dlZbLx4HdlsyaDm035hsqUOGU2rSbehjDQQXaTONfi6H9QPpFDae0YJ9uWaCSYoIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTAwOTAxMTgyMjM3WjAjBgkqhkiG9w0BCQQxFgQUi6IO5Z4V00+fHWqlML5++7G/GpAwDQYJKoZIhvcNAQEBBQAEgYAcK/M8bD5/c6Ay7iMDujiLzIibLfQuUpEaFQrcRyLIXPD085/6cbz+zEuyfLkYuVnFsm2RT5qMJ9NKhz2TWgl0+MTGU+lxdi8Quvas56CRHpvrM6/K/fyrX1VXGD6JmtXbMu+cKydGvb2QT8uhAMmUg5wP4GwZCPksmz24/ZGajg==-----END PKCS7-----
38
+ ">
39
+ <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
40
+ <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>
41
+ </form>
42
+
43
+ </fieldset>
44
+ </div>
45
+
46
+ <div style="clear:both;"></div>
app/design/adminhtml/default/default/template/wordpress/support/tab/debug-info.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <div class="entry-edit">
8
+ <div class="entry-edit-head">
9
+ <h4><?php echo $this->__('System Information') ?></h4>
10
+ </div>
11
+ <fieldset class="config">
12
+ <legend><?php echo $this->__('System Information') ?></legend>
13
+ <?php $sections = $this->_helper('debug_environmentReport')->getReport() ?>
14
+ <?php if (count($sections) > 0): ?>
15
+ <div style="height:1%; overflow:hidden;">
16
+ <?php foreach($sections as $section => $values): ?>
17
+ <ul style="float:left; margin-right:40px; ">
18
+ <li>
19
+ <h3><a href="#" style="text-decoration:none;"><?php echo $section ?></a> </h3>
20
+ <?php if (count($values) > 0): ?>
21
+ <ul>
22
+ <?php foreach($values as $field => $value): ?>
23
+ <li>
24
+ <strong><?php echo $field ?></strong>
25
+ <span><?php echo $value ?></span>
26
+ </li>
27
+ <?php endforeach; ?>
28
+ <li>&nbsp;</li>
29
+ </ul>
30
+ <?php endif; ?>
31
+ </li>
32
+ </ul>
33
+ <?php endforeach; ?>
34
+ </div>
35
+ <?php endif; ?>
36
+ <div style="height:1%;overflow:hidden;"><button type="button" class="scalable back left support-previous" id="content_previous"><span><?php echo $this->__('Previous') ?></span></button><button type="button" class="scalable add right support-next" id="content_next"><span><?php echo $this->__('Next') ?></span></button></div>
37
+ </fieldset>
38
+ </div>
39
+
app/design/adminhtml/default/default/template/wordpress/support/tab/logs.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <div class="entry-edit">
8
+ <div class="entry-edit-head">
9
+ <h4><?php echo $this->__('Log Files') ?></h4>
10
+ </div>
11
+ <fieldset class="config">
12
+ <legend><?php echo $this->__('Log Files') ?></legend>
13
+ <?php $logs = $this->_helper('debug_environmentReport')->getLogEntries(30) ?>
14
+ <?php if ($logs): ?>
15
+ <p><?php echo nl2br(trim($logs)) ?></p>
16
+ <?php else: ?>
17
+ <p>No log files have been found. It is recommend that you enable logging before submitting this message as logs will help us a find a solution much more efficiently.</p>
18
+ <p>&nbsp;</p>
19
+ <?php endif; ?>
20
+ <div style="height:1%;overflow:hidden;"><button type="button" class="scalable back left support-previous" id="content_previous"><span><?php echo $this->__('Previous') ?></span></button><button type="button" class="scalable add right support-next" id="content_next"><span><?php echo $this->__('Next') ?></span></button></div>
21
+ </fieldset>
22
+ </div>
23
+
app/design/frontend/base/default/layout/wordpress.xml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <default>
5
+ <reference name="top.links">
6
+ <action method="addLink" translate="label title" module="wordpress">
7
+ <label>Blog</label>
8
+ <url helper="wordpress/getBlogRoute"/>
9
+ <title>Blog</title>
10
+ <position>90</position>
11
+ </action>
12
+ </reference>
13
+ </default>
14
+
15
+
16
+ <wordpress_default>
17
+ <reference name="root">
18
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
19
+ </reference>
20
+ <reference name="left">
21
+ <block type="wordpress/archive_list" name="wordpress_archive_list" template="wordpress/archive/list.phtml" before="-">
22
+ <action method="setTitle"><title>Archives</title></action>
23
+ </block>
24
+
25
+ <block type="wordpress/category_list" name="wordpress_category_list" template="wordpress/category/list.phtml" after="wordpress_archive_list">
26
+ <action method="setTitle"><title>Categories</title></action>
27
+ </block>
28
+
29
+ </reference>
30
+ </wordpress_default>
31
+
32
+ <wordpress_homepage_index>
33
+ <update handle="wordpress_default"/>
34
+ <reference name="content">
35
+ <block type="wordpress/homepage" name="wordpress_homepage" template="wordpress/homepage.phtml">
36
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
37
+ <block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
38
+ </block>
39
+ </block>
40
+ </reference>
41
+ </wordpress_homepage_index>
42
+
43
+ <wordpress_post_list_index>
44
+ <update handle="wordpress_default"/>
45
+ <reference name="content">
46
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml"/>
47
+ </reference>
48
+ </wordpress_post_list_index>
49
+
50
+ <wordpress_category_index>
51
+ <update handle="wordpress_default"/>
52
+ <reference name="content">
53
+ <block type="wordpress/category_view" name="wordpress_category" template="wordpress/category/view.phtml">
54
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
55
+ <block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
56
+ </block>
57
+ </block>
58
+ </reference>
59
+ </wordpress_category_index>
60
+
61
+ <wordpress_tag_index>
62
+ <update handle="wordpress_default"/>
63
+ <reference name="content">
64
+ <block type="wordpress/tag_view" name="wordpress_tag" template="wordpress/tag/view.phtml">
65
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
66
+ <block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
67
+ </block>
68
+ </block>
69
+ </reference>
70
+ </wordpress_tag_index>
71
+
72
+ <wordpress_archive_view_index>
73
+ <update handle="wordpress_default"/>
74
+ <reference name="content">
75
+ <block type="wordpress/archive_view" name="wordpress_archive" template="wordpress/archive/view.phtml">
76
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
77
+ <block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
78
+ </block>
79
+ </block>
80
+ </reference>
81
+ </wordpress_archive_view_index>
82
+
83
+ <wordpress_tag_list>
84
+ <update handle="wordpress_default"/>
85
+ <reference name="content">
86
+ <block type="wordpress/tag_list" name="wordpress_tag" template="wordpress/tag/list.phtml"/>
87
+ </reference>
88
+ </wordpress_tag_list>
89
+
90
+ <wordpress_author_index>
91
+ <update handle="wordpress_default"/>
92
+ <reference name="content">
93
+ <block type="wordpress/author_view" name="wordpress_author" template="wordpress/author/view.phtml">
94
+ <block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
95
+ <block type="wordpress/post_list_pager" name="wordpress_post_list_pager"/>
96
+ </block>
97
+ </block>
98
+ </reference>
99
+ </wordpress_author_index>
100
+
101
+ <wordpress_post_view_index>
102
+ <update handle="wordpress_default"/>
103
+ <reference name="head">
104
+ <action method="addJs"><script>fishpig/wordpress/comments.js</script></action>
105
+ </reference>
106
+ <reference name="content">
107
+ <block type="wordpress/post_view" name="wordpress_post_view" template="wordpress/post/view.phtml"/>
108
+ </reference>
109
+ <reference name="left">
110
+ <block type="wordpress/post_associated_products" name="wordpress_associated_products" template="wordpress/post/associated/product/list.phtml" before="-">
111
+ <action method="setTitle"><title>Related Products</title></action>
112
+ </block>
113
+ </reference>
114
+ </wordpress_post_view_index>
115
+
116
+ <catalog_product_view>
117
+ <reference name="product.info.additional">
118
+ <block type="wordpress/post_list_associated" name="wordpress_posts_associated" template="wordpress/post/associated.phtml">
119
+ <action method="setTitle"><title>Related blog posts</title></action>
120
+ </block>
121
+ </reference>
122
+ </catalog_product_view>
123
+
124
+
125
+ </layout>
app/design/frontend/base/default/template/wordpress/archive/list.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php $archives = $this->getArchives() ?>
9
+ <?php if (count($archives) > 0): ?>
10
+ <div class="block block-blog-archives">
11
+ <?php if ($title = $this->getTitle()): ?>
12
+ <div class="block-title">
13
+ <strong><?php echo $title ?></strong>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="block-content">
17
+ <ul>
18
+ <?php foreach($archives as $archive): ?>
19
+ <li>
20
+ <a href="<?php echo $archive->getUrl() ?>" title="<?php echo $archive->getName() ?>">
21
+ <?php echo $archive->getName() ?></a> (<?php echo $archive->getPostCount() ?>)
22
+ </li>
23
+ <?php endforeach; ?>
24
+ </ul>
25
+ </div>
26
+ </div>
27
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/archive/view.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $archive = $this->getArchive() ?>
7
+ <?php if ($archive): ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('Monthly Archives') ?>: <?php echo $archive->getName() ?></h1>
10
+ </div>
11
+ <?php echo $this->getPostListHtml() ?>
12
+ <?php endif; ?>
13
+
app/design/frontend/base/default/template/wordpress/author/view.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $_author = $this->getAuthor() ?>
7
+ <?php if ($_author): ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('User Archives') ?>: <?php echo $_author->getDisplayName() ?></h1>
10
+ </div>
11
+ <?php echo $this->getPostListHtml() ?>
12
+ <?php endif; ?>
13
+
app/design/frontend/base/default/template/wordpress/category/list.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php $categories = $this->getCategories() ?>
9
+ <?php if (count($categories) > 0): ?>
10
+ <div class="block block-blog-categories">
11
+ <?php if ($title = $this->getTitle()): ?>
12
+ <div class="block-title">
13
+ <strong><?php echo $title ?></strong>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="block-content">
17
+ <ul>
18
+ <?php foreach($categories as $category): ?>
19
+ <li>
20
+ <a href="<?php echo $category->getUrl() ?>" title="<?php echo $category->getName() ?>">
21
+ <?php echo $category->getName() ?>
22
+ </a>
23
+ </li>
24
+ <?php endforeach; ?>
25
+ </ul>
26
+ </div>
27
+ </div>
28
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/category/view.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $_category = $this->getCurrentCategory() ?>
7
+ <?php if ($_category): ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $_category->getName() ?></h1>
10
+ </div>
11
+ <?php if ($description = $_category->getDescription()): ?>
12
+ <p><?php echo $description ?></p>
13
+ <?php endif; ?>
14
+ <?php echo $this->getPostListHtml() ?>
15
+ <?php endif; ?>
16
+
app/design/frontend/base/default/template/wordpress/feed/rss2.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php echo $this->getDocType() ?>
9
+ <rss version="2.0"
10
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
11
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
12
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
13
+ xmlns:atom="http://www.w3.org/2005/Atom"
14
+ xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
15
+ xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
16
+ >
17
+ <channel>
18
+ <title><![CDATA[<?php echo $this->getRssTitle() ?>]]></title>
19
+ <atom:link href="<?php echo $this->getFeedUrl() ?>" rel="self" type="application/rss+xml" />
20
+ <link><![CDATA[<?php echo $this->_helper()->getUrl() ?>]]></link>
21
+ <description></description>
22
+ <lastBuildDate><?php echo date('D, d M Y H:i:s +0000') ?></lastBuildDate>
23
+ <language><?php echo $this->getRssLanguage() ?></language>
24
+ <sy:updatePeriod>hourly</sy:updatePeriod>
25
+ <sy:updateFrequency><![CDATA[http://wordpress.org/?v=3.0.1]]></sy:updateFrequency>
26
+ <?php $posts = $this->getPosts() ?>
27
+ <?php if (count($posts) > 0): ?>
28
+ <?php foreach($posts as $post): ?>
29
+ <item>
30
+ <title><![CDATA[<?php echo $post->getPostTitle() ?>]]></title>
31
+ <link><![CDATA[<?php echo $post->getPermalink() ?>]]></link>
32
+ <comments><![CDATA[<?php echo $post->getPermalink() ?>#respond]]></comments>
33
+ <pubDate><?php echo $post->getPostDate('D, d M Y H:i:s +0000') ?></pubDate>
34
+ <dc:creator><?php echo $post->getAuthorName() ?></dc:creator>
35
+ <?php if ($category = $post->getCategories()): ?>
36
+ <category><![CDATA[]]></category>
37
+ <?php endif; ?>
38
+ <guid isPermaLink="false"><![CDATA[<?php echo $post->getGuid() ?>]]></guid>
39
+ <?php if ($this->displayExceprt()) : ?>
40
+ <description><![CDATA[<?php echo $post->getPostExcerpt() ?>]]></description>
41
+ <?php else : ?>
42
+ <description><![CDATA[<?php echo $post->getPostContent() ?>]]></description>
43
+ <?php endif; ?>
44
+ </item>
45
+ <?php endforeach; ?>
46
+ <?php endif; ?>
47
+ </channel>
48
+ </rss>
app/design/frontend/base/default/template/wordpress/homepage.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <div class="page-title">
7
+ <h1><?php echo $this->getBlogTitle() ?></h1>
8
+ </div>
9
+ <?php echo $this->getPostListHtml() ?>
app/design/frontend/base/default/template/wordpress/links.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php $links = Mage::getResourceModel('wordpress/link_collection')
8
+ ->addCategoryIdFilter(2) ?>
9
+ <?php if (count($links) > 0): ?>
10
+ <ul>
11
+ <?php foreach($links as $link): ?>
12
+ <li>
13
+ <a href="<?php echo $link->getLinkUrl() ?>"><?php echo $link->getLinkName() ?>--</a>
14
+ </li>
15
+ <?php endforeach; ?>
16
+ </ul>
17
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/page/list.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php $pages = $this->getPages() ?>
9
+ <?php if (count($pages) > 0): ?>
10
+ <div class="block block-blog-pages">
11
+ <?php if ($title = $this->getTitle()): ?>
12
+ <div class="block-title">
13
+ <strong><?php echo $title ?></strong>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="block-content">
17
+ <ul>
18
+ <?php foreach($pages as $page): ?>
19
+ <li>
20
+ <a href="<?php echo $page->getUrl() ?>" title="<?php echo $page->getPostTitle() ?>">
21
+ <?php echo $page->getPostTitle() ?></a>
22
+ </li>
23
+ <?php endforeach; ?>
24
+ </ul>
25
+ </div>
26
+ </div>
27
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/page/view.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $post = $this->getPost() ?>
7
+ <?php if ($post): ?>
8
+ <?php $helper = $this->helper('wordpress') ?>
9
+ <?php $author = $post->getAuthor() ?>
10
+ <?php $comments = $post->getComments() ?>
11
+ <div class="page-title">
12
+ <h1><?php echo $post->getPostTitle() ?></h1>
13
+ </div>
14
+ <p class="when">
15
+ <?php echo $this->__('Posted on %s by %s', $post->getPostDate(), '<a href="'.$author->getUrl().'">'.$author->getDisplayName().'</a>') ?>
16
+ <span>
17
+ <?php if ($comments->count() == 0): ?>
18
+ <?php echo $this->__('There have been %s0 comments%s', '<a href="'.$post->getPermalink().'#respond">', '</a>') ?>
19
+ <?php else: ?>
20
+ <?php echo $this->__('There have been %s%s comment(s)%s', '<a href="'.$post->getPermalink().'#comments">', $comments->count(), '</a>') ?>
21
+ <?php endif; ?>
22
+ </span>
23
+ </p>
24
+ <div class="entry">
25
+ <?php echo $post->getPostContent() ?>
26
+ <br style="clear:both;"/>
27
+ </div>
28
+ <p class="details">
29
+ <?php $categories = $post->getParentCategories() ?>
30
+ <?php if (count($categories) > 0): ?>
31
+ <?php echo $this->__('This post was posted in') ?>
32
+ <?php $it = count($categories) ?>
33
+ <?php foreach($categories as $category): ?>
34
+ <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
35
+ <?php endforeach; ?>
36
+ <?php endif; ?>
37
+ <?php $tags = $post->getTags() ?>
38
+ <?php if (count($tags) > 0): ?>
39
+ <?php echo (count($categories) == 0) ? $this->__('This post was tagged with') : $this->__('and was tagged with') ?>
40
+ <?php $it = count($tags) ?>
41
+ <?php foreach($tags as $tag): ?>
42
+ <a href="<?php echo $tag->getUrl() ?>"><?php echo $tag->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
43
+ <?php endforeach; ?>
44
+ <?php endif; ?>
45
+ </p>
46
+ <?php echo $this->getCommentsHtml() ?>
47
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/associated.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php if ($postListHtml = $this->getPostListHtml()): ?>
7
+ <div class="box-collateral box-description">
8
+ <?php if ($title = $this->getTitle()): ?>
9
+ <h2><?php echo $this->__($title) ?></h2>
10
+ <?php endif; ?>
11
+ <div class="std">
12
+ <?php echo $postListHtml ?>
13
+ </div>
14
+ </div>
15
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/associated/list.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $posts = $this->getPosts() ?>
7
+ <?php if (count($posts) > 0): ?>
8
+ <ul>
9
+ <?php foreach($posts as $post): ?>
10
+ <li>
11
+ <a href="<?php echo $post->getPermalink() ?>"><?php echo $post->getPostTitle() ?></a>
12
+ </li>
13
+ <?php endforeach; ?>
14
+ </ul>
15
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/associated/product/list.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php $products = $this->getProducts() ?>
9
+ <?php if (count($products) > 0): ?>
10
+ <div class="block block-associated-products">
11
+ <?php if ($title = $this->getTitle()): ?>
12
+ <div class="block-title">
13
+ <strong><?php echo $title ?></strong>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="block-content">
17
+ <ul>
18
+ <?php foreach($products as $product): ?>
19
+ <li>
20
+ <a href="<?php echo $product->getProductUrl() ?>">
21
+ <?php echo $product->getName() ?>
22
+ </a>
23
+ </li>
24
+ <?php endforeach; ?>
25
+ </ul>
26
+ </div>
27
+ </div>
28
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/featured.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $post = $this->getPost() ?>
7
+ <?php if ($post): ?>
8
+ <div id="featured-post">
9
+ <div class="page-title">
10
+ <h2><?php echo $post->getPostTitle() ?></h2>
11
+ </div>
12
+ <div class="entry">
13
+ <?php echo $post->getPostContent() ?>
14
+ <br style="clear:both;"/>
15
+ </div>
16
+ </div>
17
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/list.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $posts = $this->getPosts() ?>
7
+ <?php if (count($posts) > 0): ?>
8
+ <div class="post-list">
9
+ <ul>
10
+ <?php foreach($posts as $post): ?>
11
+ <?php $author = $post->getAuthor() ?>
12
+ <li>
13
+ <h2><a href="<?php echo $post->getPermalink() ?>"><?php echo $post->getPostTitle() ?></a></h2>
14
+ <p class="on">
15
+ <?php echo $this->__('Posted on %s by %s', $post->getPostDate(), '<a href="'.$author->getUrl().'">'.$author->getDisplayName().'</a>') ?>
16
+ </p>
17
+ <div class="entry">
18
+ <?php if ($featuredImage = $post->getFeaturedImage()): ?>
19
+ <div class="featured-image left">
20
+ <img src="<?php echo $featuredImage->getAvailableImage() ?>" alt=""/>
21
+ </div>
22
+ <?php endif; ?>
23
+ <?php if ($excerpt = $post->getPostExcerpt()): ?>
24
+ <?php echo $excerpt ?>
25
+ <?php else: ?>
26
+ <?php echo $post->getPostContent() ?>
27
+ <?php endif; ?>
28
+ <br style="clear:both;"/>
29
+ </div>
30
+ <p class="details">
31
+ <?php $categories = $post->getParentCategories() ?>
32
+ <?php if (count($categories) > 0): ?>
33
+ <?php echo $this->__('This post was posted in') ?>
34
+ <?php $it = count($categories) ?>
35
+ <?php foreach($categories as $category): ?>
36
+ <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
37
+ <?php endforeach; ?>
38
+ <?php endif; ?>
39
+ <?php $tags = $post->getTags() ?>
40
+ <?php if (count($tags) > 0): ?>
41
+ <?php echo (count($categories) == 0) ? $this->__('This post was tagged with') : $this->__('and was tagged with') ?>
42
+ <?php $it = count($tags) ?>
43
+ <?php foreach($tags as $tag): ?>
44
+ <a href="<?php echo $tag->getUrl() ?>"><?php echo $tag->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
45
+ <?php endforeach; ?>
46
+ <?php endif; ?>
47
+ </p>
48
+ </li>
49
+ <?php endforeach; ?>
50
+ </ul>
51
+ <?php echo $this->getPagerHtml() ?>
52
+ </div>
53
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/recent.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php if ($title = $this->getTitle()): ?>
7
+ <div class="page-title">
8
+ <h2><?php echo $this->__($title) ?></h2>
9
+ </div>
10
+ <?php endif; ?>
11
+ <?php echo $this->getPostListHtml() ?>
app/design/frontend/base/default/template/wordpress/post/recent/list.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $posts = $this->getPosts() ?>
7
+ <?php if (count($posts) > 0): ?>
8
+ <ul>
9
+ <?php foreach($posts as $post): ?>
10
+ <li>
11
+ <h3><a href="<?php echo $post->getPermalink() ?>"><?php echo $post->getPostTitle() ?></a></h3>
12
+ </li>
13
+ <?php endforeach; ?>
14
+ </ul>
15
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/syntaxhighlighter/trigger.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php if ($this->helper('wordpress/filter_shortcode_syntaxhighlighter')->isEnabled()): ?>
8
+ <script type="text/javascript">
9
+ function SyntaxHighlighterBrushPath() {
10
+ var args = arguments, result = [];
11
+ for(var i = 0; i < args.length; i++) {
12
+ result.push(args[i].replace('@', '<?php echo $this->getUrl("js/syntaxhighlighter/") ?>'));
13
+ }
14
+ return result;
15
+ }
16
+
17
+ SyntaxHighlighter.autoloader.apply(null, SyntaxHighlighterBrushPath(
18
+ 'applescript @shBrushAppleScript.js',
19
+ 'actionscript3 as3 @shBrushAS3.js',
20
+ 'bash shell @shBrushBash.js',
21
+ 'coldfusion cf @shBrushColdFusion.js',
22
+ 'cpp c @shBrushCpp.js',
23
+ 'c# c-sharp csharp @shBrushCSharp.js',
24
+ 'css @shBrushCss.js',
25
+ 'delphi pascal @shBrushDelphi.js',
26
+ 'diff patch pas @shBrushDiff.js',
27
+ 'erl erlang @shBrushErlang.js',
28
+ 'groovy @shBrushGroovy.js',
29
+ 'java @shBrushJava.js',
30
+ 'jfx javafx @shBrushJavaFX.js',
31
+ 'js jscript javascript @shBrushJScript.js',
32
+ 'perl pl @shBrushPerl.js',
33
+ 'php @shBrushPhp.js',
34
+ 'text plain @shBrushPlain.js',
35
+ 'py python @shBrushPython.js',
36
+ 'ruby rails ror rb @shBrushRuby.js',
37
+ 'sass scss @shBrushSass.js',
38
+ 'scala @shBrushScala.js',
39
+ 'sql @shBrushSql.js',
40
+ 'vb vbnet @shBrushVb.js',
41
+ 'xml xhtml xslt html @shBrushXml.js'
42
+ ));
43
+
44
+ SyntaxHighlighter.all();
45
+ </script>
46
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/view.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $post = $this->getPost() ?>
7
+ <?php if ($post): ?>
8
+ <?php $helper = $this->helper('wordpress') ?>
9
+ <?php $author = $post->getAuthor() ?>
10
+ <?php $comments = $post->getComments() ?>
11
+ <div class="page-title">
12
+ <h1><?php echo $post->getPostTitle() ?></h1>
13
+ </div>
14
+ <p class="when">
15
+ <?php echo $this->__('Posted on %s by %s', $post->getPostDate(), '<a href="'.$author->getUrl().'">'.$author->getDisplayName().'</a>') ?>
16
+ <span>
17
+ <?php if ($comments->count() == 0): ?>
18
+ <?php echo $this->__('There have been %s0 comments%s', '<a href="'.$post->getPermalink().'#respond">', '</a>') ?>
19
+ <?php else: ?>
20
+ <?php echo $this->__('There have been %s%s comment(s)%s', '<a href="'.$post->getPermalink().'#comments">', $comments->count(), '</a>') ?>
21
+ <?php endif; ?>
22
+ </span>
23
+ </p>
24
+ <div class="entry">
25
+ <?php if ($featuredImage = $post->getFeaturedImage()): ?>
26
+ <div class="featured-image left">
27
+ <img src="<?php echo $featuredImage->getAvailableImage() ?>" alt=""/>
28
+ </div>
29
+ <?php endif; ?>
30
+ <?php echo $post->getPostContent() ?>
31
+ <br style="clear:both;"/>
32
+ </div>
33
+ <p class="details">
34
+ <?php $categories = $post->getParentCategories() ?>
35
+ <?php if (count($categories) > 0): ?>
36
+ <?php echo $this->__('This post was posted in') ?>
37
+ <?php $it = count($categories) ?>
38
+ <?php foreach($categories as $category): ?>
39
+ <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
40
+ <?php endforeach; ?>
41
+ <?php endif; ?>
42
+ <?php $tags = $post->getTags() ?>
43
+ <?php if (count($tags) > 0): ?>
44
+ <?php echo (count($categories) == 0) ? $this->__('This post was tagged with') : $this->__('and was tagged with') ?>
45
+ <?php $it = count($tags) ?>
46
+ <?php foreach($tags as $tag): ?>
47
+ <a href="<?php echo $tag->getUrl() ?>"><?php echo $tag->getName() ?></a><?php if (--$it > 0): ?>, <?php endif; ?>
48
+ <?php endforeach; ?>
49
+ <?php endif; ?>
50
+ </p>
51
+ <?php echo $this->getCommentsHtml() ?>
52
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/post/view/comment/form.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <form id="respond" method="post" action="<?php echo $this->getCommentFormAction() ?>">
9
+ <div class="display-none">
10
+ <input type="hidden" name="comment_post_ID" value="<?php echo $this->getPostId() ?>"/>
11
+ <input type="hidden" name="comment_parent" value="0"/>
12
+ <input type="hidden" name="redirect_to" value="<?php echo $this->getRedirectTo() ?>"/>
13
+ </div>
14
+ <div class="fieldset">
15
+ <h2 class="legend"><?php echo $this->__('Comments') ?></h2>
16
+ <ul class="form-list">
17
+ <li class="fields">
18
+ <div class="field">
19
+ <label for="author" class="required"><?php echo $this->__('Name') ?> <em>*</em></label>
20
+ <div class="input-box">
21
+ <input type="text" id="author" name="author" class="input-text required-entry" value="<?php echo $this->getCustomerName() ?>"/>
22
+ </div>
23
+ </div>
24
+ <div class="field">
25
+ <label for="email" class="required"><?php echo $this->__('Email') ?> <em>*</em></label>
26
+ <div class="input-box">
27
+ <input type="text" id="email" name="email" class="input-text required-entry validate-email" value="<?php echo $this->getCustomerEmail() ?>"/>
28
+ </div>
29
+ </div>
30
+ </li>
31
+ <li>
32
+ <label for="url"><?php echo $this->__('Website') ?></label>
33
+ <div class="input-box">
34
+ <input type="text" id="url" name="url" class="input-text" value=""/>
35
+ </div>
36
+ </li>
37
+ <li class="wide">
38
+ <label for="comment" class="required"><?php echo $this->__('Comment') ?> <em>*</em></label>
39
+ <div class="input-box">
40
+ <textarea id="comment" name="comment" rows="8" cols="45" class="required-entry"></textarea>
41
+ </div>
42
+ </li>
43
+ </ul>
44
+ </div>
45
+ <div class="buttons-set">
46
+ <button type="submit" name="submit" class="button" value="Post your comment" id="post-the-comment">
47
+ <span><span><?php echo $this->__('Post your comment') ?></span></span>
48
+ </button>
49
+ </div>
50
+ <script type="text/javascript">
51
+ //<![CDATA[
52
+ var commentForm = new WpCommentForm('respond', {
53
+ successUrl: '<?php echo $this->getSuccessUrl() ?>',
54
+ errorUrl: '<?php echo $this->getErrorUrl() ?>'
55
+ });
56
+ //]]>
57
+ </script>
58
+ </form>
app/design/frontend/base/default/template/wordpress/post/view/comments.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php $comments = $this->getComments() ?>
8
+ <?php $post = $this->getPost() ?>
9
+ <div id="comments">
10
+ <?php if ($comments->count() > 0): ?>
11
+ <h3><?php echo count($comments) ?> <?php echo $this->__('Response to %s', $post->getPostTitle()) ?></h3>
12
+ <ul>
13
+ <?php foreach($comments as $comment): ?>
14
+ <li id="comment-<?php echo $comment->getId() ?>">
15
+ <h4>
16
+ <a href="<?php echo $comment->getCommentAuthorUrl() ?>" rel="nofollow">
17
+ <?php echo $comment->getCommentAuthor() ?>
18
+ </a> <?php echo $this->__('says') ?>:
19
+ </h4>
20
+ <p class="entry">
21
+ <?php echo nl2br($comment->getCommentContent()) ?>
22
+ </p>
23
+ <p class="when">
24
+ <?php echo $this->__('Posted on %s at %s', $comment->getCommentDate(), $comment->getCommentTime()) ?>
25
+ </p>
26
+ </li>
27
+ <?php endforeach; ?>
28
+ </ul>
29
+ <?php endif; ?>
30
+ <?php if ($this->canComment()): ?>
31
+ <?php echo $this->getCommentFormHtml() ?>
32
+ <?php endif; ?>
33
+ </div>
app/design/frontend/base/default/template/wordpress/shortcode/associated-products.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ *
5
+ *
6
+ */
7
+ ?>
8
+ <?php $products = $this->getProducts() ?>
9
+ <?php if (count($products) > 0): ?>
10
+ <div class="block block-associated-products">
11
+ <?php if ($title = $this->getTitle()): ?>
12
+ <div class="block-title">
13
+ <strong><?php echo $title ?></strong>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="block-content">
17
+ <ul>
18
+ <?php foreach($products as $product): ?>
19
+ <li>
20
+ <a href="<?php echo $product->getProductUrl() ?>">
21
+ <?php echo $product->getName() ?>
22
+ </a>
23
+ </li>
24
+ <?php endforeach; ?>
25
+ </ul>
26
+ </div>
27
+ </div>
28
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/shortcode/product.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This block can be called a WordPress shortcode
4
+ *
5
+ * [product id="1" template="wordpress/shortcode/product.phtml"]
6
+ *
7
+ */
8
+ ?>
9
+ <?php $product = $this->getProduct() ?>
10
+ <?php if ($product): ?>
11
+ <div id="product-shortcode">
12
+ <h3><a href="<?php echo $product->getProductUrl() ?>"><?php echo $product->getName() ?></a></h3>
13
+ <img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize(200, 200) ?>" alt="<?php echo $product->getName() ?>"/>
14
+ <p><?php echo nl2br($product->getShortDescription()) ?></p>
15
+ </div>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/shortcode/youtube-video.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <?php if ($videoCode = $this->getYoutubeVideoCode()): ?>
8
+ <object width="480" height="385">
9
+ <param name="movie" value="http://www.youtube.com/v/<?php echo $videoCode ?>?fs=1&amp;hl=en_US"></param>
10
+ <param name="allowFullScreen" value="true"></param>
11
+ <param name="allowscriptaccess" value="always"></param>
12
+ <embed src="http://www.youtube.com/v/<?php echo $videoCode ?>?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
13
+ </object>
14
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/tag/list.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ ?>
7
+ <div class="page-title">
8
+ <h1><?php echo $this->__('Tags') ?></h1>
9
+ </div>
10
+ <?php $tags = $this->getTagCollection() ?>
11
+ <?php if (count($tags) > 0): ?>
12
+ <ul id="tag-list">
13
+ <?php foreach($tags as $tag): ?>
14
+ <li>
15
+ <a href="<?php echo $tag->getUrl() ?>"><?php echo $tag->getName() ?></a> (<?php echo $tag->getPostCount() ?>)
16
+ </li>
17
+ <?php endforeach; ?>
18
+ </ul>
19
+ <?php endif; ?>
app/design/frontend/base/default/template/wordpress/tag/view.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ *
4
+ **/
5
+ ?>
6
+ <?php $tag = $this->getTag() ?>
7
+ <?php if ($tag): ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('Tag Archives') ?>: <?php echo $tag->getName() ?></h1>
10
+ </div>
11
+ <?php if ($description = $tag->getDescription()): ?>
12
+ <p><?php echo $description ?></p>
13
+ <?php endif; ?>
14
+ <?php echo $this->getPostListHtml() ?>
15
+ <?php endif; ?>
16
+
app/etc/modules/Fishpig_Wordpress.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Fishpig_Wordpress>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Fishpig_Wordpress>
8
+ </modules>
9
+ </config>
js/fishpig/wordpress/comments.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AJAX comment system replaces the cURL system that people on shared hosts had trouble with
3
+ *
4
+ */
5
+ var WpCommentForm = Class.create({
6
+ initialize: function(formId, options){
7
+ this.form = $(formId);
8
+ this.validator = new Validation(this.form);
9
+ this.setOptions(options);
10
+ this.bindSubmitEvent();
11
+ },
12
+ setOptions: function (options){
13
+ this.options = {};
14
+
15
+ Object.extend(this.options, options || {});
16
+ },
17
+ bindSubmitEvent: function() {
18
+ var my = this;
19
+ Event.observe(this.form, 'submit', function(e) {
20
+ if(my.validator && my.validator.validate()){
21
+ my.postComment();
22
+ }
23
+ Event.stop(e);
24
+ });
25
+ },
26
+ postComment: function() {
27
+ var my = this;
28
+ $(this.form.id).request({
29
+ onSuccess: function(transport) {
30
+ setLocation(my.options.successUrl);
31
+ },
32
+ onFailure: function(transport) {
33
+ setLocation(my.options.errorUrl);
34
+ }
35
+ });
36
+ }
37
+ });
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Fishpigs_Wordpress_Integration</name>
4
+ <version>0.8.8</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily integrate Magento and Wordpress without modifying any core files.</summary>
10
+ <description>Easily integrate Magento and Wordpress without modifying any core files.</description>
11
+ <notes>Upgraded for Magento 1.5.1</notes>
12
+ <authors><author><name>fishpig</name><user>auto-converted</user><email>ben@fishpig.co.uk</email></author></authors>
13
+ <date>2011-03-05</date>
14
+ <time>21:26:31</time>
15
+ <contents><target name="magecommunity"><dir name="Fishpig"><dir name="Wordpress"><dir name="Block"><dir name="Adminhtml"><dir name="Autologin"><dir name="Tab"><file name="Form.php" hash="75bef3c74cb861811879cf049b88295b"/></dir><file name="Form.php" hash="71b9d372d37f7164bfd97abd14850bf1"/><file name="Tabs.php" hash="cd81f74a1a6ae88971061cc7142eaf88"/></dir><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><dir name="Category"><file name="Grid.php" hash="4025a994eefae9a71de4f3628325798f"/></dir><dir name="Grid"><file name="Abstract.php" hash="3a5d9c8283ab05d80daf68a34ef0f5f7"/></dir><dir name="Post"><file name="Grid.php" hash="ea2b62b824dba3bf9a23164ca301b586"/></dir></dir></dir></dir></dir><dir name="Support"><dir name="Tab"><dir name="Form"><file name="Abstract.php" hash="037ca74529a34c7cf37044cad91846f0"/></dir><file name="RequestForm.php" hash="b7248f6f621f9146d248740a682c7ae3"/></dir><file name="Form.php" hash="ee7592099b9335da6388ab1b0f907014"/><file name="Tabs.php" hash="7159f8515cc9c6c20e6adcb638f6394b"/></dir><dir name="System"><dir name="Config"><dir name="Test"><dir name="Results"><dir name="Column"><file name="Result.php" hash="08a45aaed7047b1d3f323f140e707c50"/></dir><file name="Grid.php" hash="2b80356ec8ffcb9c15eddebd2e4cb94d"/></dir></dir><file name="Wrapper.php" hash="963ed263279a99ebdceebd1c9eeb6480"/></dir></dir><file name="Autologin.php" hash="92e8fb38d0be73ec060dfb31209ae16b"/><file name="Support.php" hash="117d9caf3c3b830733e5674d1556117e"/><file name="Template.php" hash="c85079bf192fec0d4b3986dee1394fdd"/></dir><dir name="Archive"><file name="List.php" hash="b511a7b0064c97c5a7007fa6e3e5b719"/><file name="View.php" hash="8b0bb82b2d744426ab7a23818a0ce8ec"/></dir><dir name="Author"><file name="View.php" hash="3e72dd9cf546e152af638f066b3aea65"/></dir><dir name="Category"><file name="List.php" hash="b55483c743b1c3dfb832fedd647ab405"/><file name="View.php" hash="8533c046f40cc1c347a06e0a20d3c881"/></dir><dir name="Feed"><file name="Rss2.php" hash="93d3c0f474d46cf78807677a07386cdd"/></dir><dir name="Post"><dir name="Associated"><file name="Products.php" hash="612912587bb8eac8971ad3e2fe758eac"/></dir><dir name="List"><dir name="Wrapper"><file name="Abstract.php" hash="00060f6e9903f7b08abb917e2f0c587c"/></dir><file name="Associated.php" hash="76bb2f531318be7d7d2c3a63816f0f5b"/><file name="Pager.php" hash="83566a7dd9cf2823db1a778e212e2d02"/><file name="Recent.php" hash="2c662793743484d646ede6eb479ded75"/></dir><dir name="View"><dir name="Comment"><file name="Form.php" hash="c741936fbfd28ec52ff458a74170aaa6"/></dir><file name="Abstract.php" hash="f7bb5775ba2475a606b33ef44059746a"/><file name="Comments.php" hash="48cad23bffeb880fd85b0e430c577797"/></dir><file name="List.php" hash="9168acf1925885b476fe8244839e3896"/><file name="View.php" hash="448453bd6ec72b9f2564dddb5cc2b53e"/></dir><dir name="Tag"><file name="List.php" hash="1849c0446459bebf560a94bbb334c2e8"/><file name="View.php" hash="3db5cef3789057626bdadb00d2536a2f"/></dir><file name="Abstract.php" hash="199aa6331c270690e69c9d8004cf40ce"/><file name="Homepage.php" hash="087166dd2d9b2a70407a03cf9b93b500"/></dir><dir name="Controller"><dir name="Adminhtml"><file name="Abstract.php" hash="347fc8c131789e6fcfa4c118f964ada4"/></dir><file name="Abstract.php" hash="ae810bbb0accf09cf578599b69c543e2"/><file name="Router.php" hash="970dc07445687f247fe041046aaa9074"/></dir><dir name="Docs"><file name="Example-XML-Blocks.xml" hash="0135ed9a2db3ef74e707f3f9428258b8"/><file name="readme.txt" hash="89d7dbf749f28098486297e3a93043e8"/></dir><dir name="Helper"><dir name="Catalog"><file name="Product.php" hash="2d8a7d5241493972b5b584a8df04d4df"/></dir><dir name="Debug"><dir name="Test"><file name="Abstract.php" hash="e1c05b001f8b5be91e3987654049898a"/><file name="BlogRoute.php" hash="a05cbf3aee51f6460e1089a1d689d762"/><file name="Connection.php" hash="1dab48d098111a392906c8200f8d2556"/><file name="Query.php" hash="a9730e63373864b26fb975040f56cda8"/><file name="ResultCollection.php" hash="523d1f81d0871b91c5cc37bbd3bf5c7b"/><file name="WpUrls.php" hash="13e917969194893bb632248234ebb5d0"/></dir><file name="EnvironmentReport.php" hash="1c8aca24f2624fc85721044ac8d99767"/><file name="Test.php" hash="61798fcf45aeb64e0eaa7105113c4267"/></dir><dir name="Filter"><dir name="Shortcode"><file name="Abstract.php" hash="e459204eaaff940f49e985b05d5bce6a"/><file name="AssociatedProducts.php" hash="ed9a19ae1b0297958f956f589ab6f284"/><file name="Caption.php" hash="447e1bc76a8e61f78d75399361197cba"/><file name="Product.php" hash="c5c68cd73935a388461b83409d31362e"/><file name="SyntaxHighlighter.php" hash="9428c5dbb74586734c1d08dbf040d16e"/><file name="Youtube.php" hash="76877e9e5fc65632ab27a262ac583549"/></dir><file name="Abstract.php" hash="ec1a1177935c09b70419c574a02986e1"/><file name="AutoParagraph.php" hash="5bd8a84c176a643a539e23dd9e9d0e1f"/><file name="RemoveHtml.php" hash="ce61f7a884fa8368c165bce808c774bf"/><file name="Shortcodes.php" hash="7b93fb49ad08924ef0579aff12b0ca0d"/></dir><dir name="Plugin"><file name="Abstract.php" hash="eb9d4b4692dcc1e0144136d47b2122b2"/><file name="AllInOneSeo.php" hash="9478b8933349d5eb47e011d5caad7d7b"/></dir><dir name="Post"><dir name="Content"><dir name="Shortcode"><file name="Abstract.php" hash="830d9a545ca0214f38cd3ae5f4c34d31"/><file name="Caption.php" hash="b807b2d51b00ad0d2e0f672b2e93fe60"/></dir></dir></dir><file name="Abstract.php" hash="d24ca27ab90dd3a5bb1457d0ec1343b4"/><file name="Adminhtml.php" hash="dd1f1985d945c9534600fc4d8a288f22"/><file name="Curl.php" hash="40aa296d20223f62999c330c7e4e45e5"/><file name="Data.php" hash="5e2ee932a595ae0877034544fb322178"/><file name="Db.php" hash="fc9e27021b16be8a7aa0e6aeac6a2470"/><file name="Debug.php" hash="5941c25e996ecf6a59ad481d1b962618"/><file name="Filter.php" hash="4f9159a8f2b32480e67111d09d48fcf4"/><file name="Object.php" hash="d09c765070fb03d2db94144f30b87f29"/><file name="Post.php" hash="11c51b85ee4be058edc7d32d3ef66599"/></dir><dir name="Model"><dir name="Admin"><file name="User.php" hash="109fb4df076f9bc335dfd0ac88544621"/></dir><dir name="Category"><file name="Abstract.php" hash="cade2e9a5aa06dd649ade74d319195eb"/></dir><dir name="Link"><file name="Category.php" hash="18c4711a02aa492c4e5b88de163c7fc7"/></dir><dir name="Mysql4"><dir name="Admin"><dir name="User"><file name="Collection.php" hash="830f030c106883012454a095b581910d"/></dir><file name="User.php" hash="297e9629fced98b9a929b92cef1812b0"/></dir><dir name="Category"><dir name="Collection"><file name="Abstract.php" hash="a4676f9e94b125d1795da574b2a98f1d"/></dir><file name="Abstract.php" hash="19bc30f3f2a9e36769e6e444d9a36576"/></dir><dir name="Collection"><file name="Abstract.php" hash="bbc03b01cad0cf15ac9032184a2b3206"/></dir><dir name="Image"><file name="Collection.php" hash="9dc66a0aabee1b3171a35aaadec48ed9"/></dir><dir name="Link"><dir name="Category"><file name="Collection.php" hash="dede74be8c761a75942ac2cdd645460b"/></dir><file name="Category.php" hash="da42b811984e70b15c2f21ad8cd6f4f6"/><file name="Collection.php" hash="869c2581bc1c1ecffbc5c04eba09ed54"/></dir><dir name="Option"><file name="Collection.php" hash="96ba9ca68de593a56b85cdf1579ecffa"/></dir><dir name="Page"><file name="Collection.php" hash="c5ca02a02265267ac939f2037dfb7e48"/></dir><dir name="Post"><dir name="Attachment"><dir name="Collection"><file name="Abstract.php" hash="0158b82b7b85f1769424be2f69ae5c0d"/></dir><file name="Abstract.php" hash="82c08dfa2ab539a93deb9abdc94b652c"/></dir><dir name="Category"><file name="Collection.php" hash="05d712157a31f73db7b5359f1a45f8b0"/></dir><dir name="Collection"><file name="Abstract.php" hash="446e4b902cf188009b337bfefcdaff33"/></dir><dir name="Comment"><file name="Collection.php" hash="a257e2830fc33e51292224942f3af972"/></dir><dir name="Tag"><file name="Collection.php" hash="3914daf268b5e6ea4c482a5f7f62114c"/></dir><file name="Category.php" hash="6d7ee67988eadd11155710db627346c7"/><file name="Collection.php" hash="ff7d880f69146547c4e17fd60f356e30"/><file name="Comment.php" hash="f36cf9cfe895d85daa6ec01f8a8081bd"/><file name="Tag.php" hash="e97c0503478b469b1027ad0829cbd361"/></dir><dir name="User"><file name="Collection.php" hash="37f3241dcd58e6f1c1578d30a18f7afe"/></dir><file name="Abstract.php" hash="fe969df8300a8f7042f6f69a27898fb3"/><file name="Image.php" hash="a3380aaf912a7e1e9c08a9982984be97"/><file name="Link.php" hash="6219c896fea1fd5ce3c2696445008177"/><file name="Option.php" hash="af79a9cfbe4f67f1322d5c319e92056d"/><file name="Page.php" hash="94552183337d9951ff9b85392eb0bba4"/><file name="Post.php" hash="df8f0373f0f5705834a1da5e5117b15c"/><file name="User.php" hash="1876d8f318b1a308ceca88afa4f39db4"/></dir><dir name="Observer"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="SaveAssociations.php" hash="4ff1c4fcd940f7999f529924ffd4f682"/></dir></dir><dir name="System"><dir name="Config"><file name="SaveAfter.php" hash="47bb0e950b717593562fb9e5de98b3f9"/></dir></dir></dir><file name="Abstract.php" hash="db3bbac9ffe900bb18a72515b9149c21"/><file name="DatabaseSetup.php" hash="c8b658216cb0b0ff70e11fb7bcd65d60"/></dir><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="388747d05e26d739025b551ba8ec35cd"/></dir><file name="Abstract.php" hash="02e290b300d9aa147bdcaff0ffd85609"/><file name="Category.php" hash="e5c1039668bef25905475f44d6e40cb5"/><file name="Comment.php" hash="fc666a346dbaa7b8c10e764a32b4ad38"/><file name="Tag.php" hash="dabe00a1c9f103cb8c57e9ea8b81d8cd"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Encrypted.php" hash="8696c784417ce9dbf2fb90dd819bb0a9"/></dir><dir name="Source"><dir name="Database"><file name="Location.php" hash="a555c7f95dc26b2848b945a2090db9b6"/></dir><dir name="Filters"><file name="Content.php" hash="9cf4083316a985ab73949485c9295654"/><file name="Excerpt.php" hash="47a5ccf8643d965b8703955094b77499"/></dir><dir name="SyntaxHighlighter"><file name="Theme.php" hash="8370e608fca65472b5185bd26d5190cf"/></dir><file name="Integration.php" hash="595db1258f80aa9835b21c40291608c0"/><file name="Shortcodes.php" hash="ad0881fcdd1565d7a0186759e27a7fc8"/></dir></dir></dir><file name="Abstract.php" hash="7ba22a49a03f617b901a8cb3cd3daeb2"/><file name="Archive.php" hash="39724e9dc367e2fb8674a6fdf098c8ee"/><file name="Image.php" hash="3dd451d77753f13715f517012f486c6c"/><file name="Link.php" hash="c0f581d5283b2e806d6e5768fa671247"/><file name="Option.php" hash="d9840105ba2d77c77c30d0748e939d72"/><file name="Page.php" hash="66f2b09961ae673879439fd1e83a51b4"/><file name="Post.php" hash="a96b9463ac8498ee3513fe39b84b526a"/><file name="User.php" hash="53c6c271a9aa519c526be0acadae9b1a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DebugController.php" hash="f760654b05e006a84bd7159da78c4520"/><file name="RedirectController.php" hash="337b42134fe5bf1926b301c63a35d0fb"/><file name="SupportController.php" hash="7ba999f0be601aa9edd5bb5dd66b7738"/><file name="WpAdminController.php" hash="66ce3df8e7ae7cfdcf562d6390a89ad0"/></dir><dir name="Archive"><file name="ViewController.php" hash="74b678a748a87937352eaed15b4a5ac8"/></dir><dir name="Post"><dir name="View"><file name="CommentController.php" hash="645e222818d04a5824fa678e5b521c93"/></dir><file name="ViewController.php" hash="09b17455ad6d2eff03ade4bcf72facea"/></dir><file name="AuthorController.php" hash="fb71e79448d3d17efade4268f408424c"/><file name="CategoryController.php" hash="4728e2fe794c61b3baf8fce0930abb08"/><file name="FeedController.php" hash="aeed91dd2c635a342210a8b6a0ffb8ea"/><file name="HomepageController.php" hash="12562249cbe07ad510da86106f1f99f7"/><file name="PageController.php" hash="97ca64d4789e580e2355e33a5a912915"/><file name="RedirectController.php" hash="e057c010fdbf6d3899765aab1a12c200"/><file name="SitemapController.php" hash="baedfcbefc39638a40d6e702ee6a59c7"/><file name="TagController.php" hash="0f24ebae6469be3a715fc3d07394270f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="52393a279fddeb5c49019e63c22a6a25"/><file name="config.xml" hash="12fd9e71647ca510e23e25c2c219f3c1"/><file name="system.xml" hash="ba33c2c3d0ae90f11a5abec4b9268095"/></dir><dir name="sql"><dir name="wordpress_setup"><file name="mysql4-install-0.1.0.php" hash="ffc7783f7922333bc7a8d0a051098c30"/><file name="mysql4-upgrade-0.3.2-0.3.3.php" hash="c8a807f11ae9492c1a7d1485a366a2fc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="wordpress"><dir name="config"><dir name="test"><file name="results.phtml" hash="8865ab68b59793a980e2cad712042c31"/></dir><file name="js.phtml" hash="d847e96110a76ed83e334b138e46fcba"/></dir><dir name="support"><dir name="tab"><file name="complete.phtml" hash="432c4b1dce5df986bf7905ab806dcbd5"/><file name="debug-info.phtml" hash="bda19d313723fc9473e71b416cbf9701"/><file name="logs.phtml" hash="6d37c611da0259d08d113a3dff80e842"/></dir><file name="index.phtml" hash="e6a2d9832c3f5b6e28c2df07100014de"/><file name="js.phtml" hash="27b2f1478f5ea7416fc18be9aa1f5350"/></dir><file name="admin-links-js.phtml" hash="2847e8d1d5a830232bd579357503e750"/></dir></dir><dir name="layout"><file name="wordpress.xml" hash="a0ce1382f154b245793994593cb0f93c"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="wordpress"><dir name="archive"><file name="list.phtml" hash="a8e9db156c022fef234d6b220419bf25"/><file name="view.phtml" hash="095c8b4d29aa2c485dbee7c0aaa8fd97"/></dir><dir name="author"><file name="view.phtml" hash="1ab44cf2e6538195db849d22d4196dc3"/></dir><dir name="category"><file name="list.phtml" hash="36bf253eed74087d9f57745a6cb42584"/><file name="view.phtml" hash="19f2ca27290b8c492cce2b3390db3524"/></dir><dir name="feed"><file name="rss2.phtml" hash="f4782a7529b48d4913e94e97a3960480"/></dir><dir name="page"><file name="list.phtml" hash="32d63bce4b3a40ac0339622a8297e9b5"/><file name="view.phtml" hash="a6c772dcfede9dc2a95dc815699aaa68"/></dir><dir name="post"><dir name="associated"><dir name="product"><file name="list.phtml" hash="b9540e7057379c446d044c4d426c02c0"/></dir><file name="list.phtml" hash="e17911a285e6b73ff8dceddc48eaf43a"/></dir><dir name="recent"><file name="list.phtml" hash="713771a76442cbbd3f496d46be3242cc"/></dir><dir name="syntaxhighlighter"><file name="trigger.phtml" hash="ef6afa31eae4c55dcb147d11af47991f"/></dir><dir name="view"><dir name="comment"><file name="form.phtml" hash="90c09048e66af97a6475e9de8052f58a"/></dir><file name="comments.phtml" hash="5d7c39b5ca72197bbe2b7aad7add46b5"/></dir><file name="associated.phtml" hash="97854fc29fddad0ec168f17690dd5b4b"/><file name="featured.phtml" hash="c53474b5a7da69ff693838bb9978d296"/><file name="list.phtml" hash="707a8465cd24e014538f923767532b28"/><file name="recent.phtml" hash="3be37c74c34d01109ab4a89bc4ab12c8"/><file name="view.phtml" hash="399dd435385d1d03ae56787aa4bcd4a6"/></dir><dir name="shortcode"><file name="associated-products.phtml" hash="b9540e7057379c446d044c4d426c02c0"/><file name="product.phtml" hash="d71a783afb264c4a812c9293c2b91d67"/><file name="youtube-video.phtml" hash="c030a50500bda503ef13998fa95aa81f"/></dir><dir name="tag"><file name="list.phtml" hash="c41fa2780965d78144a85ef1b93d6f37"/><file name="view.phtml" hash="db5093ec438c1d353b1c7225b48f3ff0"/></dir><file name="homepage.phtml" hash="5718db9476a821752a5a5b56803aa18f"/><file name="links.phtml" hash="5084dc1fc65b68227432adf9d1095244"/></dir></dir><dir name="layout"><file name="wordpress.xml" hash="ec4a474b4a6ba56fe3c66f61b11d479c"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="fishpig"><dir name="wordpress"><file name="comments.js" hash="45f99658ede43a4fa600e3991d224ffa"/></dir></dir></dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Fishpig_Wordpress.xml" hash="18b53504339bdbf43d9cc267b23eb7b6"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>