Fishpig_Wordpress_Integration - Version 4.2.1.1

Version Notes

For changes, please see http://fishpig.co.uk/magento/wordpress-integration/#changelog

Download this release

Release Info

Developer fishpig
Extension Fishpig_Wordpress_Integration
Version 4.2.1.1
Comparing to
See all releases


Code changes from version 4.2.1.0 to 4.2.1.1

Files changed (150) hide show
  1. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Abstract.php +0 -22
  2. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Abstract.php +0 -399
  3. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Category/Category.php +0 -20
  4. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Category/Post.php +0 -20
  5. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Cms/Page/Category.php +0 -20
  6. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Cms/Page/Post.php +0 -20
  7. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Product/Category.php +0 -20
  8. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Product/Post.php +0 -20
  9. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Extend.php +0 -624
  10. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Frontend/Autologin.php +0 -42
  11. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Form/Field/Route.php +0 -89
  12. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Update.php +0 -59
  13. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Ajax.php +0 -117
  14. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Archive/View.php +0 -61
  15. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Author/View.php +0 -31
  16. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Abstract.php +0 -179
  17. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Post.php +0 -123
  18. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Post/Comment.php +0 -88
  19. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Homepage.php +0 -62
  20. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Menu.php +0 -175
  21. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Page/View.php +0 -12
  22. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Abstract.php +0 -193
  23. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Associated.php +0 -97
  24. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php +0 -49
  25. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List.php +0 -172
  26. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php +0 -81
  27. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php +0 -65
  28. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Renderer.php +0 -20
  29. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php +0 -86
  30. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Meta.php +0 -105
  31. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View.php +0 -60
  32. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Abstract.php +0 -127
  33. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php +0 -85
  34. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Pager.php +0 -92
  35. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Wrapper.php +0 -46
  36. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php +0 -47
  37. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Search/Result.php +0 -78
  38. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Shortcode/Product.php +0 -11
  39. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar.php +0 -324
  40. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Abstract.php +0 -225
  41. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Archives.php +0 -103
  42. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Calendar.php +0 -174
  43. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Categories.php +0 -99
  44. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Comments.php +0 -40
  45. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Image.php +0 -65
  46. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Links.php +0 -72
  47. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Menu.php +0 -40
  48. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Meta.php +0 -30
  49. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Pages.php +0 -82
  50. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Posts.php +0 -247
  51. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Rss.php +0 -43
  52. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Rss/Abstract.php +0 -152
  53. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Search.php +0 -56
  54. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Tagcloud.php +0 -100
  55. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Taxonomy.php +0 -161
  56. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Text.php +0 -28
  57. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Yarpp.php +0 -22
  58. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/System/Config/Form/Field/Post/Type.php +0 -23
  59. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Template.php +0 -11
  60. app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Term/View.php +0 -39
  61. app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Instagram.php +131 -0
  62. app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller/Abstract.php +0 -476
  63. app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller/Router.php +0 -408
  64. app/code/community/Fishpig/Wordpress/Exception.php +0 -96
  65. app/code/community/Fishpig/Wordpress/Exception.php app/code/community/Fishpig/Wordpress/Exception.php app/code/community/Fishpig/Wordpress/Exception.php +0 -96
  66. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Abstract.php +0 -256
  67. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/App.php +0 -538
  68. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Associations.php +0 -549
  69. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Catalog/Product.php +0 -124
  70. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Data.php +0 -408
  71. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Database.php +0 -40
  72. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Filter.php +0 -260
  73. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin.php +0 -115
  74. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin/Abstract.php +0 -71
  75. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin/Seo/Abstract.php +0 -223
  76. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Router.php +0 -294
  77. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Abstract.php +0 -324
  78. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/AssociatedProducts.php +0 -45
  79. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Caption.php +0 -51
  80. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Code.php +0 -47
  81. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Dailymotion.php +0 -69
  82. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Gallery.php +0 -82
  83. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Gist.php +0 -82
  84. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Instagram.php +0 -81
  85. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Product.php +0 -124
  86. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Scribd.php +0 -69
  87. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Spotify.php +0 -62
  88. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Vimeo.php +0 -88
  89. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Youtube.php +0 -99
  90. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Social.php +0 -154
  91. app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/System.php +0 -533
  92. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Abstract.php +0 -324
  93. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Archive.php +0 -93
  94. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Image.php +0 -184
  95. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Menu.php +0 -120
  96. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Menu/Item.php +0 -201
  97. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Observer.php +0 -242
  98. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post.php +0 -699
  99. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Attachment/Abstract.php +0 -49
  100. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Comment.php +0 -232
  101. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Type.php +0 -335
  102. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Abstract.php +0 -110
  103. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Collection/Abstract.php +0 -145
  104. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Image.php +0 -27
  105. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Image/Collection.php +0 -30
  106. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu.php +0 -15
  107. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Collection.php +0 -30
  108. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Item.php +0 -15
  109. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Item/Collection.php +0 -61
  110. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post.php +0 -451
  111. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Attachment/Abstract.php +0 -12
  112. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Attachment/Collection/Abstract.php +0 -55
  113. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Collection.php +0 -469
  114. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Comment.php +0 -15
  115. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Comment/Collection.php +0 -101
  116. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Setup.php +0 -28
  117. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Term.php +0 -103
  118. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Term/Collection.php +0 -213
  119. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/User.php +0 -112
  120. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/User/Collection.php +0 -29
  121. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Sitemap/Sitemap.php +0 -23
  122. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Autologin.php +0 -132
  123. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Encrypted.php +0 -23
  124. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Menu.php +0 -32
  125. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Social/Media/Service.php +0 -31
  126. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Term.php +0 -222
  127. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Term/Taxonomy.php +0 -132
  128. app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/User.php +0 -267
  129. app/code/community/Fishpig/Wordpress/change-log.txt app/code/community/Fishpig/Wordpress/change-log.txt app/code/community/Fishpig/Wordpress/change-log.txt +0 -256
  130. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/Adminhtml/Wordpress/AssociationsController.php +0 -244
  131. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/Adminhtml/WordpressController.php +0 -108
  132. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/AjaxController.php +0 -56
  133. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/ArchiveController.php +0 -79
  134. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/AuthorController.php +0 -89
  135. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/IndexController.php +0 -156
  136. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/PostController.php +0 -306
  137. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/SearchController.php +0 -58
  138. app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/TermController.php +0 -106
  139. app/code/community/Fishpig/Wordpress/controllers/PostController.php +11 -11
  140. app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/adminhtml.xml +0 -56
  141. app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/config.xml +0 -314
  142. app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/fishpig.xml +0 -2
  143. app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/system.xml +0 -367
  144. app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/widget.xml +0 -40
  145. app/code/community/Fishpig/Wordpress/etc/config.xml +1 -1
  146. app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-install-0.1.0.php +0 -10
  147. app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-2.5.9.0-2.5.9.1.php +0 -117
  148. app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-3.2.0.0-3.2.0.1.php +0 -28
  149. app/design/frontend/base/default/template/wordpress/sidebar/widget/instagram.phtml +23 -0
  150. package.xml +4 -4
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Abstract.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Abstract extends Mage_Core_Block_Template
10
- {
11
- /**
12
- * Allows for legacy Magento
13
- *
14
- * @param string $data
15
- * @param array $allowedTags = null
16
- * @return string
17
- */
18
- public function escapeHtml($data, $allowedTags = null)
19
- {
20
- return Mage::helper('wordpress')->escapeHtml($data, $allowedTags);
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Abstract.php DELETED
@@ -1,399 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract extends Mage_Adminhtml_Block_Widget_Grid
10
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
11
- {
12
- /**
13
- * Retrieve the association type for the particular class
14
- *
15
- * @return string
16
- */
17
- abstract public function getAssociationType();
18
-
19
- /**
20
- * Setup the grid
21
- */
22
- public function __construct()
23
- {
24
- parent::__construct();
25
-
26
- $this->setId($this->_getMagentoEntity() . $this->_getWpEntity());
27
- $this->setDefaultSort($this->_getDefaultSort());
28
- $this->setDefaultDir($this->_getDefaultDir());
29
- $this->setSaveParametersInSession(false);
30
- $this->setUseAjax(true);
31
-
32
- if (is_object($this->_getObject())) {
33
- $this->setDefaultFilter(array('is_associated' => 1));
34
- }
35
- }
36
-
37
- /**
38
- * Returns an array of all of the object's associated WP ID's
39
- *
40
- * @return array
41
- */
42
- public function getSelectedWpItems()
43
- {
44
- return array_keys($this->getSelectedWpItemPositions());
45
- }
46
-
47
- /**
48
- * Retrieves an array of associated WP ID's and their position
49
- *
50
- * @return array
51
- */
52
- public function getSelectedWpItemPositions()
53
- {
54
- if ($this->_getObject()) {
55
- $wpObjectIds = Mage::helper('wordpress/associations')->getAssociations($this->getAssociationType(), $this->_getObject()->getId(), $this->getStoreId());
56
-
57
- if ($wpObjectIds !== false) {
58
- foreach($wpObjectIds as $wpObjectId => $position) {
59
- $wpObjectIds[$wpObjectId] = array('associated_position' => $position);
60
- }
61
-
62
- return $wpObjectIds;
63
- }
64
- }
65
-
66
- return array();
67
- }
68
-
69
- /**
70
- * Add in the position field to the grid
71
- *
72
- */
73
- protected function _prepareColumns()
74
- {
75
- $this->addColumn('is_associated', array(
76
- 'header_css_class' => 'a-center',
77
- 'type' => 'checkbox',
78
- 'name' => 'is_associated',
79
- 'align' => 'center',
80
- 'index' => $this->_getWpPrimaryKey(),
81
- 'values' => array_values($this->getSelectedWpItems()),
82
- ));
83
-
84
- if ($this->_getWpEntity() === 'post') {
85
- $this->addColumn('post_title', array(
86
- 'header'=> 'Post Title',
87
- 'index' => 'post_title',
88
- ));
89
-
90
- $postTypes = array_keys(Mage::helper('wordpress/app')->getPostTypes());
91
-
92
- $this->addColumn('post_type', array(
93
- 'header'=> 'Type',
94
- 'index' => 'post_type',
95
- 'type' => 'options',
96
- 'options' => array_combine($postTypes, $postTypes),
97
- ));
98
-
99
- $this->addColumn('post_date', array(
100
- 'header'=> 'Post Date',
101
- 'index' => 'post_date',
102
- 'type' => 'date',
103
- 'format' => 'd MMMM YYYY',
104
- ));
105
- }
106
- else if ($this->_getWpEntity() === 'category') {
107
- $this->addColumn('name', array(
108
- 'header'=> 'Name',
109
- 'index' => 'name',
110
- ));
111
-
112
- $this->addColumn('slug', array(
113
- 'header'=> 'Slug',
114
- 'index' => 'slug',
115
- ));
116
-
117
- $taxonomies = array_keys(Mage::helper('wordpress/app')->getTaxonomies());
118
-
119
- $this->addColumn('taxonomy', array(
120
- 'header'=> 'Type',
121
- 'index' => 'taxonomy',
122
- 'type' => 'options',
123
- 'options' => array_combine($taxonomies, $taxonomies),
124
- ));
125
- }
126
-
127
- $this->addColumn('associated_position', array(
128
- 'header' => Mage::helper('catalog')->__('Position'),
129
- 'name' => 'associated_position',
130
- 'type' => 'number',
131
- 'validate_class' => 'validate-number',
132
- 'index' => 'associated_position',
133
- 'width' => 100,
134
- 'editable' => true,
135
- 'filterable' => false,
136
- 'sortable' => false,
137
- ));
138
-
139
- return parent::_prepareColumns();
140
- }
141
-
142
- protected function _prepareCollection()
143
- {
144
- if (!$this->getCollection()) {
145
- if ($this->_getWpEntity() === 'post') {
146
- $collection = Mage::getResourceModel('wordpress/post_collection')
147
- ->addPostTypeFilter(array_keys(Mage::helper('wordpress/app')->getPostTypes()))
148
- # ->removePermalinkFromSelect()
149
- ->addIsViewableFilter();
150
- }
151
- else if ($this->_getWpEntity() === 'category') {
152
- $collection = Mage::getResourceModel('wordpress/term_collection')->addTaxonomyFilter(
153
- array_keys(Mage::helper('wordpress/app')->getTaxonomies())
154
- );
155
- }
156
- else {
157
- return false;
158
- }
159
-
160
- # Mage::dispatchEvent('wordpress_association_' . $this->_getWpEntity() . '_collection_load_before', array('collection' => $collection, 'grid' => $this));
161
-
162
- Mage::helper('wordpress/associations')->addRelatedPositionToSelect($collection, $this->getAssociationType(), $this->_getObject()->getId(), $this->getStoreId());
163
-
164
- $this->setCollection($collection);
165
- }
166
-
167
- try {
168
- return parent::_prepareCollection();
169
- }
170
- catch (Exception $e) {
171
- echo sprintf('<div><ul class="messages"><li class="error-msg"><ul><li><span>%s</span></li></ul></li></ul></div>', $e->getMessage());
172
- echo '<p>Your WordPress database user does not have permission to access the association tables in the Magento database. To fix this, either grant SELECT permission for your WordPress database user to the Magento tables that start with wordpress_ or merge your WordPress and Magento databases.</p>';
173
- echo '<p>If you are having trouble doing this or just want it handling quickly for you, FishPig offer a <a href="http://fishpig.co.uk/magento/wordpress-integration/services/merge-databases/?ref=errassoc" target="_blank">WordPress and Magento database merging</a> service.</p>';
174
- exit;
175
- }
176
- }
177
-
178
- /**
179
- * Add a custom filter for the in_product column
180
- *
181
- */
182
- protected function _addColumnFilterToCollection($column)
183
- {
184
- if ($column->getId() === 'is_associated') {
185
- $ids = $this->getSelectedWpItems();
186
-
187
- if (empty($ids)) {
188
- $ids = array(0);
189
- }
190
-
191
- $op = $column->getFilter()->getValue() ? 'in' : 'nin';
192
-
193
- $this->getCollection()->addFieldToFilter("main_table." . $this->_getWpPrimaryKey(), array($op => $ids));
194
- }
195
- else {
196
- parent::_addColumnFilterToCollection($column);
197
- }
198
-
199
- return $this;
200
- }
201
-
202
- /**
203
- * Displays the tab if integration is valid
204
- *
205
- * @return true
206
- */
207
- public function canShowTab()
208
- {
209
- return $this->integrationIsEnabled() && (is_object($this->_getObject()) && $this->_getObject()->getId());
210
- }
211
-
212
- /**
213
- * Determine whether integration is enabled
214
- *
215
- * @return bool
216
- */
217
- public function integrationIsEnabled()
218
- {
219
- return Mage::helper('wordpress/app')->getDbConnection() !== false;
220
- }
221
-
222
- /**
223
- * Stops the tab being hidden
224
- *
225
- * @return bool
226
- */
227
- public function isHidden()
228
- {
229
- return false;
230
- }
231
-
232
- /**
233
- * Retrieve the class name of the tab
234
- *
235
- * return string
236
- */
237
- public function getTabClass()
238
- {
239
- return 'ajax';
240
- }
241
-
242
- /**
243
- * Determine whether to generate content on load or via AJAX
244
- *
245
- * @return bool
246
- */
247
- public function getSkipGenerateContent()
248
- {
249
- return true;
250
- }
251
-
252
- /**
253
- * Retrieve the default sort
254
- *
255
- * @return string
256
- */
257
- protected function _getDefaultSort()
258
- {
259
- return 'assoc.position';
260
- }
261
-
262
- /**
263
- * Retrieve the default sort direction
264
- *
265
- * @return string
266
- */
267
- protected function _getDefaultDir()
268
- {
269
- return 'asc';
270
- }
271
-
272
- /**
273
- * Retrieve the parameters for the URL
274
- *
275
- * @return array
276
- */
277
- protected function _getUrlParams()
278
- {
279
- $params = array(
280
- 'associations_type' => $this->getAssociationType(),
281
- );
282
-
283
- if ($this->_getObject()) {
284
- $params['id'] = $this->_getObject()->getId();
285
- }
286
-
287
- if ($store = Mage::app()->getRequest()->getParam('store', false)) {
288
- $params['store'] = $store;
289
- }
290
-
291
- return $params;
292
- }
293
-
294
- /**
295
- * Retrieve the URL used to access the grid (AJAX)
296
- *
297
- * @return string
298
- */
299
- public function getCurrentUrl($params = array())
300
- {
301
- return $this->getUrl('adminhtml/wordpress_associations/gridRefresh', array('_query' => $this->_getUrlParams()));
302
- }
303
-
304
- /**
305
- * Retrieve the URL used to load the tab content
306
- *
307
- * @return string
308
- */
309
- public function getTabUrl()
310
- {
311
- return $this->getUrl('adminhtml/wordpress_associations/grid', array('_query' => $this->_getUrlParams()));
312
- }
313
-
314
- /**
315
- * Retrieve the Magento entity type
316
- *
317
- * @return string
318
- */
319
- protected function _getMagentoEntity()
320
- {
321
- return substr($this->getAssociationType(), 0, strpos($this->getAssociationType(), '/'));
322
- }
323
-
324
- /**
325
- * Retrieve the WordPress entity type
326
- *
327
- * @return string
328
- */
329
- protected function _getWpEntity()
330
- {
331
- return substr($this->getAssociationType(), strpos($this->getAssociationType(), '/')+1);
332
- }
333
-
334
- /**
335
- * Retrieve the WordPress entity primary key
336
- *
337
- * @return string
338
- */
339
- protected function _getWpPrimaryKey()
340
- {
341
- if ($this->_getWpEntity() === 'category') {
342
- return 'term_id';
343
- }
344
-
345
- return 'ID';
346
- }
347
-
348
- /**
349
- * Returns the current product model
350
- *
351
- * @return Mage_Catalog_Model_Product
352
- */
353
- protected function _getObject()
354
- {
355
- return Mage::registry($this->_getMagentoEntity());
356
- }
357
-
358
- /**
359
- * Retrieve the label used for the tab relating to this block
360
- *
361
- * @return string
362
- */
363
- public function getTabLabel()
364
- {
365
- if ($this->_getWpEntity() === 'post') {
366
- return $this->__('Associated Blog Posts');
367
- }
368
- else if ($this->_getWpEntity() === 'category') {
369
- return $this->__('Associated Blog Categories');
370
- }
371
-
372
- return '';
373
- }
374
-
375
- /**
376
- * Retrieve the title used by this tab
377
- *
378
- * @return string
379
- */
380
- public function getTabTitle()
381
- {
382
- return $this->getTabLabel();
383
- }
384
-
385
- /**
386
- * Retrieve the store ID set in the controller
387
- *
388
- * @return int
389
- */
390
- public function getStoreId()
391
- {
392
- return Mage::app()->getFrontController()->getAction()->getStoreId();
393
- }
394
-
395
- public function getMultipleRows($item)
396
- {
397
- return false;
398
- }
399
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Category/Category.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Category_Category extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'category/category';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Category/Post.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Category_Post extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'category/post';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Cms/Page/Category.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Cms_Page_Category extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'cms_page/category';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Cms/Page/Post.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Cms_Page_Post extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'cms_page/post';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Product/Category.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Product_Category extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'product/category';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Associations/Product/Post.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Associations_Product_Post extends Fishpig_Wordpress_Block_Adminhtml_Associations_Abstract
10
- {
11
- /**
12
- * Retrieve the association type for this grid
13
- *
14
- * @return string
15
- */
16
- public function getAssociationType()
17
- {
18
- return 'product/post';
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Extend.php DELETED
@@ -1,624 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @author Ben Tideswell <ben@fishpig.co.uk>
6
- */
7
-
8
- class Fishpig_Wordpress_Block_Adminhtml_Extend extends Mage_Core_Block_Text
9
- implements Mage_Adminhtml_Block_Widget_Tab_Interface
10
- {
11
- /**
12
- * Tracking string for GA
13
- *
14
- * @var const string
15
- */
16
- const TRACKING_STRING = '?utm_source=%s&utm_medium=%s&utm_term=%s&utm_campaign=Extend';
17
-
18
- /**
19
- * XML Data
20
- *
21
- * @var const string
22
- */
23
- const DATA = "<config><Fishpig_Bolt><url><![CDATA[magento/extensions/full-page-cache/]]></url><image>bolt.png</image><title>Bolt</title><subtitle>Full Page Cache</subtitle><short_definition>Add enterprise level caching to Magento community with Bolt, Magento's fastest Full Page Cache extension.</short_definition></Fishpig_Bolt><Fishpig_Opti><url><![CDATA[magento/extensions/minify/]]></url><image>opti.png</image><title>Opti</title><subtitle>Minify Magento</subtitle><short_definition>Opti automatically minifies your HTML, CSS and Javascript and works on any server.</short_definition></Fishpig_Opti><Fishpig_NoBots><url><![CDATA[magento/extensions/block-robots-stop-spam/]]></url><image>nobots.png</image><title>NoBots</title><subtitle>Stop Magento Spam Bots</subtitle><short_definition>NoBots automatically blocks spam bots from your website giving you less spam and a faster server.</short_definition></Fishpig_NoBots><Fishpig_CrossLink><url><![CDATA[magento/extensions/seo-internal-links/]]></url><image>crosslink.png</image><title>Crosslink</title><subtitle>SEO Internal Links</subtitle><short_definition>Automatically cross link your products, categories, splash pages, CMS pages, blog posts and categories using Crosslinks.</short_definition></Fishpig_CrossLink><Fishpig_AttributeSplashPro><url><![CDATA[magento/extensions/attribute-splash-pro/]]></url><image>splash-pro.png</image><title>AttributeSplash Pro</title><subtitle>SEO Landing Pages</subtitle><short_definition>Create SEO landing pages quickly and easily using AttributeSplash Pro. Decide which products you want to display based on multiple attribute filters, category filters and price filters.</short_definition></Fishpig_AttributeSplashPro><Fishpig_BasketShipping><url><![CDATA[magento/extensions/automatically-set-shipping-method/]]></url><image>basket-shipping.png</image><title>Basket Shipping</title><subtitle>Automatically set the Shipping Method</subtitle><short_definition>Automatically set the shipping method as soon as your customer hits your shopping cart.</short_definition></Fishpig_BasketShipping><Fishpig_Wordpress_Addon_Multisite><url><![CDATA[magento/wordpress-integration/multisite/]]></url><image>wordpress-multisite.png</image><title>Multisite Integration</title><subtitle>Add a blog to each store</subtitle><require_multistore>1</require_multistore><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_Multisite><Fishpig_Wordpress_Addon_Root><url><![CDATA[magento/wordpress-integration/root/]]></url><image>root.gif</image><title>Root</title><subtitle>Use WordPress to create CMS pages</subtitle><short_definition>Remove the blog sub-directory from your integrated blog URLs.</short_definition><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_Root><Fishpig_Wordpress_Addon_VisualComposer><url><![CDATA[magento/wordpress-integration/visual-composer/]]></url><image>visual-composer.png</image><title>Visual Composer</title><subtitle>Add sliders, image galleries and more</subtitle><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_VisualComposer><Fishpig_Wordpress_Addon_GravityForms><url><![CDATA[magento/wordpress-integration/gravity-forms/]]></url><image>gravity-forms.png</image><title>Gravity Forms</title><subtitle>Add awesome forms easily!</subtitle><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_GravityForms><Fishpig_Wordpress_Addon_Tablepress><url><![CDATA[magento/wordpress-integration/tablepress/]]></url><image>tablepress.png</image><title>TablePress</title><subtitle>Add tables from the WP Admin</subtitle><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_Tablepress><Fishpig_Wordpress_Addon_CPT><url><![CDATA[magento/wordpress-integration/post-types-taxonomies/]]></url><image>posttypes.png</image><title><![CDATA[Post Types &amp; Taxonomies]]></title><subtitle>Use post types and taxonomies</subtitle><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_CPT><Fishpig_Wordpress_Addon_ACF><url><![CDATA[magento/wordpress-integration/advanced-custom-fields/]]></url><image>advanced-custom-fields.png</image><title>Advanced Custom Fields</title><subtitle>Supports ACF Free and Pro</subtitle><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_ACF><Fishpig_Wordpress><url><![CDATA[magento/wordpress-integration/]]></url><image>wordpress.png</image><title>WordPress Integration</title><subtitle>WordPress blog integration</subtitle><short_definition>Manage multiple blogs from a single WordPress Admin and integrate each blog with a different Magento store view</short_definition><require_multistore>0</require_multistore></Fishpig_Wordpress><Fishpig_Wordpress_Addon_CS><url><![CDATA[magento/wordpress-integration/customer-synchronisation/]]></url><image>cs.png</image><title>Customer Synchronisation</title><subtitle>WordPress Single Sign-on</subtitle><short_definition>Synchronise WordPress users and Magento customers and provide a single login for your customers.</short_definition><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_CS><Fishpig_Wordpress_Addon_IntegratedSearch><url><![CDATA[magento/wordpress-integration/integrated-search/]]></url><image>integrated-search.png</image><title>Integrated Search</title><subtitle>Search products and posts</subtitle><short_definition>Integrate your Magento and WordPress search systems automatically and make searching your site easier for your customers.</short_definition><depends><Fishpig_Wordpress /></depends></Fishpig_Wordpress_Addon_IntegratedSearch><Fishpig_AttributeSplash_Addon_XmlSitemap><url><![CDATA[magento/extensions/attribute-splash-pages/xml-sitemap/]]></url><image>splash-pages.png</image><title>Attribute AttributeSplash</title><subtitle>XML Sitemap</subtitle><short_definition>Add an XML sitemap for your AttributeSplash Pages and AttributeSplash Group so search engines can index your pages.</short_definition><depends><Fishpig_AttributeSplash /></depends></Fishpig_AttributeSplash_Addon_XmlSitemap><Fishpig_AttributeSplash_Addon_QuickCreate><url><![CDATA[magento/extensions/attribute-splash-pages/quick-create/]]></url><image>splash-pages.png</image><title>Attribute AttributeSplash</title><subtitle>Quick Create</subtitle><short_definition>Quickly create AttributeSplash Pages for any attributes with this extension and save yourself from hours of manual work.</short_definition><depends><Fishpig_AttributeSplash /></depends></Fishpig_AttributeSplash_Addon_QuickCreate></config>";
24
-
25
- /**
26
- * Base URL for links
27
- *
28
- * @var const string
29
- */
30
- const BASE_URL = 'http://fishpig.co.uk/';
31
-
32
- /**
33
- * The URL for the S3 bucket for images
34
- *
35
- * @var const string
36
- */
37
- const S3_BUCKET_URL = 'https://s3.amazonaws.com/FishPig-Extend/image/';
38
-
39
- /**
40
- * Cache for all available extensions
41
- *
42
- * @var array
43
- */
44
- static protected $_extensions = null;
45
-
46
- /**
47
- *
48
- * @return
49
- */
50
- protected function _construct()
51
- {
52
- $this->setTemplate('small.phtml');
53
-
54
- return parent::_construct();
55
- }
56
-
57
- /**
58
- *
59
- * @return
60
- */
61
- protected function _beforeToHtml()
62
- {
63
- if ($this->getTemplate() === 'small.phtml') {
64
- $this->_setTextForSmallTemplate();
65
- }
66
- else if ($this->getTemplate() === 'large.phtml') {
67
- $this->_setTextForLargeTemplate();
68
- }
69
-
70
- return parent::_beforeToHtml();
71
- }
72
-
73
- /**
74
- *
75
- * @return
76
- */
77
- protected function _setTextForLargeTemplate()
78
- {
79
- if ($extensions = $this->getSelectedExtensions()) {
80
- $html = '';
81
-
82
- foreach($extensions as $extension) {
83
- $innerHtml = $this->_createHtmlElement('a', array(
84
- 'href' => $this->getTrackedUrl($extension, $this->getModule(), 'image'),
85
- 'class' => 'image'
86
- ),
87
- $this->_createHtmlElement('img', array('src' => $this->getImageUrl($extension)))
88
- )
89
- . $this->_createHtmlElement('h2', array(),
90
- $this->_createHtmlElement('a', $this->getTrackedUrl($extension, $this->getModule(), 'title'),
91
- $this->_createHtmlElement('strong', null, $this->escapeHtml($this->getTitle($extension)))
92
- . ' ' . $this->_createHtmlElement('span', null, $this->escapeHtml($this->getSubTitle($extension)))
93
- ))
94
- . $this->_createHtmlElement('p', null, $this->getShortDefinition($extension))
95
- . $this->_createHtmlElement('div', null, $this->_createHtmlElement('a', $this->getTrackedUrl($extension, $this->getModule(), 'view-more'), 'View Add-On'));
96
-
97
- $html .= $this->_createHtmlElement(
98
- 'li',
99
- array('class' => 'item' . ($this->isLast($extension) ? ' last' : '')),
100
- $this->_createHtmlElement('div', array('class' => 'pad'), $innerHtml)
101
- );
102
- }
103
-
104
- $html = $this->_createHtmlElement('div', array('id' => $this->getId()), $this->_createHtmlElement('ul', null, $html));
105
-
106
- $html .= $this->_createHtmlElement(
107
- 'style',
108
- array('type' => 'text/css'),
109
- str_replace("{{ID}}", $this->getId(), "#{{ID}} { max-width: 1600px; margin: 50px auto 0; }
110
- #{{ID}} ul { /*height: 1%; overflow: hidden; */text-align: center; }
111
- #{{ID}} li.item { display: inline-block; width: 24.5%; }
112
- #{{ID}} li.item .pad { padding: 10% 8%; border-right: 1px solid #ccc; }
113
- #{{ID}} li.item.last .pad { border-right: 0px none; }
114
- #{{ID}} li.item .image { display: block; margin-bottom: 10px; }
115
- #{{ID}} h2 a { color: #000; text-decoration: none; font-family: Tahoma, Verdana, Arial;, }
116
- #{{ID}} h2 strong { display: block; text-transform: uppercase; line-height: 1em; }
117
- #{{ID}} h2 span { font-size: 70%; font-family: Georgia, 'Times New Roman'; font-style: italic; }
118
- #{{ID}} p { min-height: 80px; }"));
119
-
120
- $this->setText($html);
121
- }
122
-
123
- return $this;
124
- }
125
-
126
- /**
127
- *
128
- * @return
129
- */
130
- protected function _setTextForSmallTemplate()
131
- {
132
- if ($extensions = $this->getSelectedExtensions()) {
133
- $html = '';
134
-
135
- foreach($extensions as $extension) {
136
- $innerHtml = $this->_createHtmlElement('a', array(
137
- 'href' => $this->getTrackedUrl($extension, $this->getModule(), 'image'),
138
- ),
139
- $this->_createHtmlElement('img', array('src' => $this->getImageUrl($extension)))
140
- . $this->_createHtmlElement('span', null, $this->escapeHtml($this->getTitle($extension)))
141
- )
142
- .$this->_createHtmlElement('p', array(
143
-
144
-
145
-
146
- ), $this->escapeHtml($this->getSubtitle($extension)));
147
-
148
-
149
-
150
- $html .= $this->_createHtmlElement(
151
- 'li',
152
- array('class' => 'item' . ($this->isLast($extension) ? ' last' : '')),
153
- $this->_createHtmlElement('div', array('class' => 'pad'), $innerHtml)
154
- );
155
- }
156
-
157
- $html = $this->_createHtmlElement('div', array('id' => $this->getId()), $this->_createHtmlElement('ul', null, $html));
158
- $html .= $this->_createHtmlElement('script', array('type' => 'text/javascript'), "decorateList($('" . $this->getId() . "').select('ul').first());");
159
-
160
- $html .= $this->_createHtmlElement(
161
- 'style',
162
- array('type' => 'text/css'),
163
- str_replace("{{ID}}", $this->getId(), "#{{ID}} { margin: 0; }
164
- #{{ID}} ul { height: 1%; overflow: hidden; }
165
- #{{ID}} li.item { margin: 0 0 10px; width: 16.5%; float: left; border-right:1px solid #ddd; }
166
- #{{ID}} li.item.last { border-right: 0; }
167
- #{{ID}} li.item .pad {padding: 10px; height: 1%; overflow: hidden; margin: 0 5px 0 0; }
168
- #{{ID}} li.item.even .pad { margin: 0 0 0 5px; }
169
- #{{ID}} li.item a { display: block; text-align: center; text-decoration: none; }
170
- #{{ID}} li.item img { max-height: 60px; }
171
- #{{ID}} li.item a span { font-size: 14px; font-family: Tahoma, Verdana, Arial; line-height: 1em; margin: 5px 0 2px; display: block;}
172
- #{{ID}} li.item p { text-align: center; } "));
173
-
174
- $this->setText($html);
175
- }
176
-
177
- return $this;
178
- }
179
-
180
- /**
181
- * Retrieve extensions set via XML
182
- *
183
- * @return array
184
- */
185
- public function getSelectedExtensions()
186
- {
187
- return $this->getExtensions($this->getLimit(), $this->getPreferred() ? ($this->getPreferred()) : null);
188
- }
189
-
190
- /**
191
- * Retrieve the available extensions taking into account $count and $pref
192
- *
193
- * @param int $count = 0
194
- * @param array $pref = array()
195
- * @return false|array
196
- */
197
- public function getExtensions($count = 0, array $pref = array(), $rand = false)
198
- {
199
- if (!isset($pref[0])) {
200
- $pref = array_keys($pref);
201
- }
202
-
203
- if (($pool = $this->_getAllExtensions()) !== false) {
204
- $winners = array();
205
-
206
- foreach($pref as $code) {
207
- if (isset($pool[$code])) {
208
- $winners[$code] = $pool[$code];
209
- unset($pool[$code]);
210
- }
211
-
212
- if (!$rand && $count > 0 && count($winners) >= $count) {
213
- break;
214
- }
215
- }
216
-
217
- if ($rand) {
218
- $winners = $this->shuffleArray($winners);
219
-
220
- if ($count > 0 && count($winners) > $count) {
221
- $xcount = count($winners);
222
-
223
- while($xcount-- > $count) {
224
- array_pop($winners);
225
- }
226
- }
227
- }
228
-
229
- while(count($winners) < $count && count($pool) > 0) {
230
- $code = key($pool);
231
-
232
- $winners[$code] = $pool[$code];
233
- unset($pool[$code]);
234
- }
235
-
236
- end($winners);
237
-
238
- $winners[key($winners)]['last'] = true;
239
-
240
- return $winners;
241
- }
242
-
243
- return false;
244
- }
245
-
246
- /**
247
- * Retrieve all of the available extensions
248
- *
249
- * @return array
250
- */
251
- protected function _getAllExtensions()
252
- {
253
- if (!is_null(self::$_extensions)) {
254
- return self::$_extensions;
255
- }
256
-
257
- $installedModules = array_keys((array)$this->_getConfig()->getNode('modules'));
258
-
259
- $config = json_decode(json_encode(simplexml_load_string(self::DATA, null, LIBXML_NOCDATA)), true);
260
- self::$_extensions = array();
261
-
262
- foreach($config as $code => $extension) {
263
- $extension['module'] = $code;
264
- $reqMultistore = isset($extension['require_multistore']) ? (int)$extension['require_multistore'] : null;
265
-
266
- if (in_array($code, $installedModules)) {
267
- continue;
268
- }
269
- else if (!is_null($reqMultistore) && $reqMultistore === (int)Mage::app()->isSingleStoreMode()) {
270
- continue;
271
- }
272
- else if (isset($extension['depends'])) {
273
- $depends = array_keys((array)$extension['depends']);
274
-
275
- if (count(array_diff($depends, $installedModules)) > 0) {
276
- continue;
277
- }
278
- }
279
-
280
- self::$_extensions[$code] = (array)$extension;
281
- }
282
-
283
- if (count(self::$_extensions) === 0) {
284
- self::$_extensions = false;
285
- }
286
-
287
- return self::$_extensions;
288
- }
289
-
290
- /**
291
- * Retrieve the title of the extension
292
- *
293
- * @param array $e
294
- * @return string
295
- */
296
- public function getTitle(array $e = null)
297
- {
298
- // Being called as a tab
299
- if (is_null($e)) {
300
- return $this->_getData('title');
301
- }
302
-
303
- return $this->_getField($e, 'title');
304
- }
305
-
306
- /**
307
- * Retrieve the subtitle of the extension
308
- *
309
- * @param array $e
310
- * @return string
311
- */
312
- public function getSubTitle(array $e)
313
- {
314
- return $this->_getField($e, 'subtitle');
315
- }
316
-
317
- /**
318
- * Rertrieve the URL for $e with the tracking code
319
- *
320
- * @param array $e
321
- * @param string $campaign
322
- * @param string $source
323
- * @param string $medium
324
- * @return string
325
- */
326
- public function getTrackedUrl(array $e, $source, $content = null)
327
- {
328
- $term = $this->_getField($e, 'module');
329
-
330
- $trackedUrl = sprintf(self::BASE_URL . $this->_getField($e, 'url') . self::TRACKING_STRING, $source, $this->getMedium(), $term);
331
-
332
- if (!is_null($content)) {
333
- $trackedUrl .= '&utm_content=' . $content;
334
- }
335
-
336
- return $trackedUrl;
337
- }
338
-
339
- /**
340
- * Retrieve the utm_medium parameter
341
- *
342
- * @return string
343
- */
344
- public function getMedium()
345
- {
346
- return $this->_getData('medium')
347
- ? $this->_getData('medium')
348
- : 'Magento Admin';
349
- }
350
-
351
- /**
352
- * Retrieve the short definition of the extension
353
- *
354
- * @param array $e
355
- * @return string
356
- */
357
- public function getShortDefinition(array $e)
358
- {
359
- return $this->_getField($e, 'short_definition');
360
- }
361
-
362
- /**
363
- * Retrieve the image URL of the extension
364
- *
365
- * @param array $e
366
- * @return string
367
- */
368
- public function getImageUrl(array $e)
369
- {
370
- return self::S3_BUCKET_URL . $this->_getField($e, 'image');
371
- }
372
-
373
- /**
374
- * Retrieve a field from the extension
375
- *
376
- * @param array $e
377
- * @param string $field
378
- * @return string
379
- */
380
- protected function _getField(array $e, $field)
381
- {
382
- return $e && is_array($e) && isset($e[$field]) ? $e[$field] : '';
383
- }
384
-
385
- /**
386
- * Determine wether $e is the last $e in the array
387
- *
388
- * @param array $e
389
- * @return bool
390
- */
391
- public function isLast(array $e)
392
- {
393
- return $this->_getField($e, 'last') === true;
394
- }
395
-
396
- /**
397
- * Retrieve the Magento config model
398
- *
399
- * @return Mage_Core_Model_Config
400
- */
401
- protected function _getConfig()
402
- {
403
- return Mage::app()->getConfig();
404
- }
405
-
406
- /**
407
- * Retrieve the ID
408
- *
409
- * @return string
410
- */
411
- public function getId()
412
- {
413
- if (!$this->_getData('id')) {
414
- $this->setId('fp-extend-' . rand(1111, 9999));
415
- }
416
-
417
- return $this->_getData('id');
418
- }
419
-
420
- /**
421
- * Retrieve the full path to the template
422
- *
423
- * @return string
424
- */
425
- public function getTemplateFile()
426
- {
427
- if (($dir = $this->_getFPAdminDir()) !== false) {
428
- return $dir . 'template' . DS . $this->getTemplate();
429
- }
430
- }
431
-
432
- /**
433
- * Set the template include path
434
- *
435
- * @param string $dir
436
- * @return $this
437
- */
438
- public function setScriptPath($dir)
439
- {
440
- $this->_viewDir = '';
441
-
442
- return $this;
443
- }
444
-
445
- /**
446
- * Retrieve any available FPAdmin directory
447
- *
448
- * @return false|string
449
- */
450
- protected function _getFPAdminDir()
451
- {
452
- $candidates = array(
453
- $this->getModule(),
454
- 'Fishpig_Wordpress',
455
- 'Fishpig_AttributeSplash',
456
- 'Fishpig_iBanners'
457
- );
458
-
459
- foreach(array_unique($candidates) as $candidate) {
460
- if (!$candidate) {
461
- continue;
462
- }
463
-
464
- $dir = Mage::getModuleDir('', $candidate) . DS . 'FPAdmin' . DS;
465
-
466
- if (is_dir($dir)) {
467
- return $dir;
468
- }
469
- }
470
-
471
- return false;
472
- }
473
-
474
- /**
475
- * If tab, always show
476
- *
477
- * @return bool
478
- */
479
- public function canShowTab()
480
- {
481
- return true;
482
- }
483
-
484
- /**
485
- * Don't hide if a tab
486
- *
487
- * @return bool
488
- */
489
- public function isHidden()
490
- {
491
- return false;
492
- }
493
-
494
- /**
495
- * Retrieve the tab title
496
- *
497
- * @return string
498
- */
499
- public function getTabTitle()
500
- {
501
- return $this->getTabLabel();
502
- }
503
-
504
- /**
505
- * Retrieve the tab label
506
- *
507
- * @return string
508
- */
509
- public function getTabLabel()
510
- {
511
- return $this->_getData('tab_label');
512
- }
513
-
514
- /**
515
- * Determine whether to skip generate content
516
- *
517
- * @return bool
518
- */
519
- public function getSkipGenerateContent()
520
- {
521
- return true;
522
- }
523
-
524
- /**
525
- * Retrieve the tab class name
526
- *
527
- * @return string
528
- */
529
- public function getTabClass()
530
- {
531
- if ($this->getSkipGenerateContent()) {
532
- return 'ajax';
533
- }
534
-
535
- return parent::getTabClass();
536
- }
537
-
538
- /**
539
- * Retrieve the URL used to load the tab content
540
- *
541
- * @return string
542
- */
543
- public function getTabUrl()
544
- {
545
- if ($tabUrl = $this->_getData('tab_url')) {
546
- return $this->getUrl($tabUrl);
547
- }
548
-
549
- return '#';
550
- }
551
-
552
- /**
553
- * Legacy fix that stops the HTML output from displaying
554
- *
555
- * @param string $fileName
556
- * @return string
557
- */
558
- public function fetchView($fileName)
559
- {
560
- return is_file($fileName)
561
- ? parent::fetchView($fileName)
562
- : '';
563
- }
564
-
565
- /**
566
- * Shuffle an array and preserve the keys
567
- *
568
- * @param array $a
569
- * @return array
570
- */
571
- public function shuffleArray(array $a)
572
- {
573
- $keys = array_keys($a);
574
-
575
- shuffle($keys);
576
-
577
- $random = array();
578
-
579
- foreach ($keys as $key) {
580
- $random[$key] = $a[$key];
581
- }
582
-
583
- return $random;
584
- }
585
-
586
- /**
587
- * Create a HTML element
588
- *
589
- * @param string $element
590
- * @param string|array|null $params = array
591
- * @param string $content = ''
592
- * @return string
593
- */
594
- protected function _createHtmlElement($element, $params = array(), $content = '')
595
- {
596
- if (is_null($params)) {
597
- $params = array();
598
- }
599
-
600
- if (!is_array($params)) {
601
- if ($element === 'a') {
602
- $params = array('href' => $params);
603
- }
604
- else if ($element === 'img') {
605
- $params = array('img' => $params);
606
- }
607
- }
608
-
609
- if ($element === 'a') {
610
- $params = array_merge($params, array('target' => '_blank'));
611
- }
612
- else if ($element === 'img') {
613
- $params = array_merge($params, array('alt' => ''));
614
- }
615
-
616
- foreach($params as $key => $value) {
617
- $params[$key] = sprintf('%s="%s"', $key, $value);
618
- }
619
-
620
- $closer = in_array($element, array('img')) ? '' : '</' . $element . '>';
621
-
622
- return sprintf('<%s%s>%s%s', $element, count($params) > 0 ? ' ' . implode(' ', $params) : '', $content, $closer);
623
- }
624
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Frontend/Autologin.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Frontend_Autologin extends Mage_Adminhtml_Block_System_Config_Form_Field
10
- {
11
- /**
12
- * Singleton flag
13
- *
14
- * @var bool
15
- */
16
- static $_singleton = false;
17
-
18
- /**
19
- * If cannot display fields, display error message
20
- *
21
- * @param Varien_Data_Form_Element_Abstract $element
22
- * @return string|false
23
- */
24
- public function render(Varien_Data_Form_Element_Abstract $element)
25
- {
26
- $version = Mage::getVersion();
27
-
28
- if (version_compare($version, '1.5.9.9', '<') && version_compare($version, '1.3.0.0', '>')) {
29
- if (self::$_singleton === false) {
30
- self::$_singleton = true;
31
-
32
- return '<tr>
33
- <td class="comment" colspan="3"><em>This feature is not supported with your version of Magento.</em></td>
34
- </tr>';
35
- }
36
-
37
- return false;
38
- }
39
-
40
- return parent::render($element);
41
- }
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/System/Config/Form/Field/Route.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_System_Config_Form_Field_Route extends Mage_Adminhtml_Block_System_Config_Form_Field
10
- {
11
- /**
12
- * Retrieve the HTML for the element
13
- *
14
- * @param Varien_Data_Form_Element_Abstract $element
15
- * @return string
16
- */
17
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
18
- {
19
- return parent::_getElementHtml($element)
20
- . $this->_getRouteJs($element);
21
- }
22
-
23
- /**
24
- * Retrieve the JS to display the route
25
- *
26
- * @param Varien_Data_Form_Element_Abstract $element
27
- * @return string
28
- */
29
- protected function _getRouteJs($element)
30
- {
31
- return sprintf("
32
- <script type=\"text/javascript\">
33
- (function() {
34
- var inp = $('%s');
35
- var MAGE_URL = '%s';
36
-
37
- var dp = new Element('p', {'class': 'note', 'id': inp.id + '-note'})
38
- inp.insert({'after': dp});
39
-
40
- var nt = $(inp.id + '-note');
41
-
42
- inp.observe('blur', function(event) {
43
- inp.setValue(inp.getValue().toLowerCase().replace(/([^a-z0-9\-\/]{1,})/, ''));
44
- nt.innerHTML = MAGE_URL + inp.getValue() + '/';
45
- });
46
-
47
- setTimeout(function() {
48
- inp.focus();
49
- inp.blur();
50
- }.bind(this), 1000);
51
- })();
52
- </script>
53
- ", $element->getHtmlId(), $this->_getBaseUrl());
54
- }
55
-
56
- /**
57
- * Retrieve the Magento base URL for the current store
58
- *
59
- * @return string
60
- */
61
- protected function _getBaseUrl()
62
- {
63
- $helper = Mage::helper('wordpress');
64
-
65
- $baseUrl = rtrim($helper->getUrl(), '/');
66
-
67
- if ($helper->getBlogRoute()) {
68
- return substr($baseUrl, 0, -strlen($helper->getBlogRoute()));
69
- }
70
-
71
- $params = array(
72
- '_direct' => trim($this->getBlogRoute(), '/'),
73
- '_secure' => false,
74
- '_nosid' => true,
75
- '_store' => Mage::app()->getStore()->getId(),
76
- );
77
-
78
- if (Mage::app()->getStore()->getCode() == 'admin') {
79
- if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
80
- $params['_store'] = $storeCode;
81
- }
82
- else {
83
- $params['_store'] = $helper->getDefaultStore(Mage::app()->getRequest()->getParam('website', null))->getId();
84
- }
85
- }
86
-
87
- return Mage::getUrl('', $params);
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Adminhtml/Update.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Adminhtml_Update extends Mage_Core_Block_Text
10
- {
11
- /**
12
- * Ensure any URL's generated are Adminhtml URL's
13
- *
14
- * @return string
15
- */
16
- protected function _getUrlModelClass()
17
- {
18
- return 'adminhtml/url';
19
- }
20
-
21
- /**
22
- * Ensure the required JS is included
23
- *
24
- * @return $this
25
- */
26
- protected function _prepareLayout()
27
- {
28
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
29
- $headBlock->addJs('fishpig/wordpress/update.js');
30
- }
31
-
32
- return parent::_prepareLayout();
33
- }
34
-
35
- /**
36
- * Generate the JS required to load the update routine
37
- *
38
- * @return $this
39
- */
40
- protected function _beforeToHtml()
41
- {
42
- if (Mage::getStoreConfigFlag('wordpress/module/check_for_updates')) {
43
- $current = str_replace('.', '_', Mage::helper('wordpress/system')->getExtensionVersion());
44
-
45
- $text = implode('', array(
46
- '<script type="text/javascript">',
47
- sprintf("var WP_VERSION_LATEST = '%s';", $latestVersion = Mage::app()->getCache()->load('wordpress_integration_update' . $current)),
48
- sprintf("var WP_VERSION_CURRENT = '%s';", Mage::helper('wordpress/system')->getExtensionVersion()),
49
- sprintf("var WP_VERSION_LOOKUP_URL = '%s';", $this->getUrl('adminhtml/wordpress/checkVersion')),
50
- 'new fishpig.WP.Update();',
51
- '</script>',
52
- ));
53
-
54
- $this->setText($text);
55
- }
56
-
57
- return parent::_beforeToHtml();
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Ajax.php DELETED
@@ -1,117 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Ajax extends Mage_Core_Block_Text
10
- {
11
- /**
12
- * Retrieve the ID of the block
13
- *
14
- * @return string
15
- */
16
- public function getId()
17
- {
18
- if (!$this->hasId()) {
19
- $this->setId(
20
- 'wp-ajax-' . substr(md5($this->getType() . '_' . $this->getHandle() . $this->getBlock() . rand(1111, 9999)), 0, 6) . rand(1111, 9999)
21
- );
22
- }
23
-
24
- return $this->_getData('id');
25
- }
26
-
27
- /**
28
- * Retrieve the request type
29
- * This can either be 'block' or 'handle'
30
- *
31
- * @return string
32
- */
33
- public function getType()
34
- {
35
- return $this->hasBlock() ? 'block' : 'handle';
36
- }
37
-
38
- /**
39
- * Retrieve the URL of the blog we are requesting
40
- *
41
- * @return string
42
- */
43
- public function getBlogUrl()
44
- {
45
- if ($blogUrl = $this->_getData('blog_url')) {
46
- if (strpos($blogUrl, 'http') === false) {
47
- $blogUrl = Mage::getUrl('', array('_direct' => $blogUrl));
48
- }
49
-
50
- return rtrim($blogUrl, '/') . '/';
51
- }
52
-
53
- return false;
54
- }
55
-
56
- /**
57
- * Retrieve the URL used for the AJAX call
58
- *
59
- * @return string
60
- */
61
- public function getAjaxUrl()
62
- {
63
- if ($this->hasAjaxUrl()) {
64
- return $this->_getData('ajax_url');
65
- }
66
-
67
- $url = $this->getBlogUrl() . 'ajax/' . $this->getType() . '/'
68
- . ($this->getType() === 'block' ? $this->getBlock() : $this->getHandle());
69
-
70
- $params = array_diff_key($this->getData(), array(
71
- 'type' => '',
72
- 'block' => '',
73
- 'handle' => '',
74
- 'blog_url' => '',
75
- 'type' => '',
76
- 'block_params' => '',
77
- 'id' => '',
78
- 'module_name' => '',
79
- 'loader' => '',
80
- ));
81
-
82
- $url .= '?' . http_build_query($params);
83
-
84
- $this->setAjaxUrl($url);
85
-
86
- return $url;
87
- }
88
-
89
- /**
90
- * Retrieve the loader HTML
91
- * Specify loader="1" (setLoader) to include AJAX loading image
92
- *
93
- * @return string
94
- */
95
- protected function _getLoader()
96
- {
97
- if ($this->getLoader()) {
98
- return sprintf('<img src="%s" alt="%s" />', $this->getSkinUrl('wordpress/ajax-loader.gif'), $this->__('Loading'));
99
- }
100
-
101
- return '';
102
- }
103
-
104
- /**
105
- * Set the HTML output
106
- *
107
- * @return $this
108
- */
109
- protected function _beforeToHtml()
110
- {
111
- $html = '<div id="%s">%s</div><script type="text/javascript">new Ajax.Updater("%s", "%s", {});</script>';
112
-
113
- $this->setText(sprintf($html, $this->getId(), $this->_getLoader(), $this->getId(), $this->getAjaxUrl()));
114
-
115
- return parent::_beforeToHtml();
116
- }
117
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Archive/View.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Archive_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Caches and returns the archive model
13
- *
14
- * @return Fishpig_Wordpress_Model_Archive
15
- */
16
- public function getArchive()
17
- {
18
- if (!$this->hasArchive()) {
19
- $this->setArchive(Mage::registry('wordpress_archive'));
20
- }
21
-
22
- return $this->_getData('archive');
23
- }
24
-
25
- /**
26
- * Retrieve the Archive ID
27
- *
28
- * @return false|int
29
- */
30
- public function getArchiveId()
31
- {
32
- if ($archive = $this->getArchive()) {
33
- return $archive->getId();
34
- }
35
-
36
- return false;
37
- }
38
-
39
- /**
40
- * Generates and returns the collection of posts
41
- *
42
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
43
- */
44
- protected function _getPostCollection()
45
- {
46
- return parent::_getPostCollection()
47
- ->addArchiveDateFilter($this->getArchiveId(), $this->getArchive()->getIsDaily());
48
- }
49
-
50
- /**
51
- * Split a date by spaces and translate
52
- *
53
- * @param string $date
54
- * @param string $splitter = ' '
55
- * @return string
56
- */
57
- public function translateDate($date, $splitter = ' ')
58
- {
59
- return $this->helper('wordpress')->translateDate($date, $splitter);
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Author/View.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Author_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Caches and returns the current category
13
- *
14
- * @return Fishpig_Wordpress_Model_User
15
- */
16
- public function getAuthor()
17
- {
18
- return Mage::registry('wordpress_author');
19
- }
20
-
21
- /**
22
- * Generates and returns the collection of posts
23
- *
24
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
25
- */
26
- protected function _getPostCollection()
27
- {
28
- return parent::_getPostCollection()
29
- ->addFieldToFilter('post_author', $this->getAuthor()->getId());
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Abstract.php DELETED
@@ -1,179 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Feed_Abstract extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- *
13
- * @param $feed
14
- * @return
15
- */
16
- abstract protected function _addEntriesToFeed($feed);
17
-
18
- /**
19
- * Generate and return the feed
20
- *
21
- * @return string
22
- */
23
- protected function _toHtml()
24
- {
25
- return $this->getFeedWriter()->export($this->getFeedType());
26
- }
27
-
28
- /**
29
- * Retrieve the items array
30
- *
31
- * @return array
32
- */
33
- public function getFeedWriter()
34
- {
35
- $feed = new Zend_Feed_Writer_Feed;
36
-
37
- $feed->setTitle($this->getTitle());
38
- $feed->setLink($this->getLink());
39
- $feed->setDescription($this->getDescription());
40
- $feed->setFeedLink($this->getFeedLink(), 'atom');
41
- $feed->setDateModified(time());
42
- $feed->setLanguage($this->getLanguage());
43
- $feed->setGenerator($this->getGenerator());
44
- $this->_addEntriesToFeed($feed);
45
-
46
- return $feed;
47
- }
48
-
49
- /**
50
- * Allow subclasses to filter items
51
- *
52
- * @return $this
53
- */
54
- protected function _prepareItemCollection($collection)
55
- {
56
- $collection->setPageSize(
57
- Mage::helper('wordpress')->getWpOption('posts_per_rss', 10)
58
- );
59
-
60
- return $this;
61
- }
62
-
63
- /**
64
- * Retrieve the blog charset
65
- *
66
- * @return string
67
- */
68
- public function getCharset()
69
- {
70
- return 'UTF-8';
71
- }
72
-
73
- /**
74
- * Retrieve the feed title
75
- *
76
- * @return string
77
- */
78
- public function getTitle()
79
- {
80
- if (($blogName = $this->decode(trim(Mage::helper('wordpress')->getWpOption('blogname')))) !== '') {
81
- return $blogName;
82
- }
83
-
84
- if (($storeName = $this->decode(trim(Mage::getStoreConfig('general/store_information/name')))) !== '') {
85
- return $storeName . ' ' . $this->__('Blog Feed');
86
- }
87
-
88
- return $this->__('Blog Feed');
89
- }
90
-
91
- /**
92
- * Retrieve the feed link
93
- *
94
- * @return string
95
- */
96
- public function getLink()
97
- {
98
- return Mage::helper('wordpress')->getUrl();
99
- }
100
-
101
- /**
102
- * Retrieve the feed description
103
- *
104
- * @return string
105
- */
106
- public function getDescription()
107
- {
108
- if (($description = trim($this->decode(Mage::helper('wordpress')->getWpOption('blogdescription')))) !== '') {
109
- return $description;
110
- }
111
-
112
- return $this->getTitle();
113
- }
114
-
115
- /**
116
- * Retrieve the feed language
117
- *
118
- * @return string
119
- */
120
- public function getLanguage()
121
- {
122
- if (($language = trim(Mage::helper('wordpress')->getWpOption('rss_language'))) !== '') {
123
- return $language;
124
- }
125
-
126
- return 'en-US';
127
- }
128
-
129
- /**
130
- * Decode a values html entities
131
- *
132
- * @param string $value
133
- * @return string
134
- */
135
- public function decode($value)
136
- {
137
- return html_entity_decode($value, ENT_NOQUOTES, $this->getCharset());
138
- }
139
-
140
- /**
141
- * Retrieve the generator value
142
- *
143
- * @return string
144
- */
145
- public function getGenerator()
146
- {
147
- return 'http://fishpig.co.uk/magento/wordpress-integration/?v='
148
- . (string)Mage::getConfig()->getNode('modules/Fishpig_Wordpress/version');
149
- }
150
-
151
- /**
152
- * Retrieve the feed link
153
- *
154
- * @return string
155
- */
156
- public function getFeedLink()
157
- {
158
- return Mage::helper('core/url')->getCurrentUrl();
159
- }
160
-
161
- /**
162
- * Retrieve the feed type
163
- *
164
- * @return string
165
- */
166
- public function getFeedType()
167
- {
168
- $validTypes = array(
169
- 'rss',
170
- 'atom',
171
- );
172
-
173
- if (in_array($this->_getData('feed_type'), $validTypes)) {
174
- return $this->_getData('feed_type');
175
- }
176
-
177
- return 'rss';
178
- }
179
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Post.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Feed_Post extends Fishpig_Wordpress_Block_Feed_Abstract
10
- {
11
- /**
12
- * Generate the entries and add them to the RSS feed
13
- *
14
- * @param Zend_Feed_Writer_Feed $feed
15
- * @return $this
16
- */
17
- protected function _addEntriesToFeed($feed)
18
- {
19
- $this->getItemAfterContent();
20
-
21
- $posts = Mage::getSingleton('core/layout')->createBlock($this->getSourceBlock())
22
- ->getPostCollection();
23
-
24
- $this->_prepareItemCollection($posts);
25
-
26
- foreach($posts as $post) {
27
- $entry = $feed->createEntry();
28
-
29
- if (!$post->getPostTitle()) {
30
- continue;
31
- }
32
-
33
- if (!($postDate = strtotime($post->getData('post_date_gmt')))) {
34
- continue;
35
- }
36
-
37
- $entry->setDateModified($postDate);
38
-
39
- $entry->setTitle($post->getPostTitle());
40
- $entry->setLink($post->getPermalink());
41
-
42
- $_author = $post->getAuthor();
43
-
44
- if ($_author->getUserEmail() && $_author->getDisplayName()) {
45
- $entry->addAuthor(array(
46
- 'name' => $_author->getDisplayName(),
47
- 'email' => $_author->getUserEmail(),
48
- ));
49
- }
50
-
51
- $description = $this->_applyVars(Mage::helper('wp_addon_wordpressseo')->getData('rssbefore'), $post)
52
- . ($this->displayExceprt() ? $post->getPostExcerpt() : $post->getPostContent())
53
- . $this->_applyVars(Mage::helper('wp_addon_wordpressseo')->getData('rssafter'), $post);
54
-
55
- $entry->setDescription($description ? $description : '&nbsp;');
56
-
57
- foreach($post->getParentCategories() as $category) {
58
- $entry->addCategory(array(
59
- 'term' => $category->getUrl(),
60
- ));
61
- }
62
-
63
- $feed->addEntry($entry);
64
- }
65
-
66
-
67
- return $this;
68
- }
69
-
70
- /**
71
- * Determine whether to display the excerpt
72
- *
73
- * @return bool
74
- */
75
- public function displayExceprt()
76
- {
77
- return Mage::helper('wordpress')->getWpOption('rss_use_excerpt');
78
- }
79
-
80
- /**
81
- * Apply variables to a string
82
- *
83
- * @param string $str
84
- * @param Fishpig_Wordpress_Model_Post $post
85
- * @return string
86
- */
87
- protected function _applyVars($str, $post)
88
- {
89
- if (trim($str) === '') {
90
- return '';
91
- }
92
-
93
- $_helper = Mage::helper('wordpress');
94
-
95
- return str_replace(
96
- array(
97
- '%%AUTHORLINK%%',
98
- '%%POSTLINK%%',
99
- '%%BLOGLINK%%',
100
- '%%BLOGDESCLINK%%',
101
- ),
102
- array(
103
- $this->_createATag($post->getAuthor()->getUrl(), $post->getAuthor()->getDisplayName()),
104
- $this->_createATag($post->getPermalink(), $post->getPostTitle()),
105
- $this->_createATag($_helper->getUrl(), $_helper->getWpOption('blogname')),
106
- $this->_createATag($_helper->getUrl(), $_helper->getWpOption('blogname') . ' - ' . $_helper->getWpOption('blogdescription')),
107
- ),
108
- $str
109
- );
110
- }
111
-
112
- /**
113
- * Create an 'A' HTML tag
114
- *
115
- * @param string $href
116
- * @param string $anchor
117
- * @return string
118
- */
119
- protected function _createATag($href, $anchor)
120
- {
121
- return sprintf('<a href="%s">%s</a>', $href, htmlentities($anchor));
122
- }
123
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Feed/Post/Comment.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Feed_Post_Comment extends Fishpig_Wordpress_Block_Feed_Abstract
10
- {
11
- /**
12
- * Generate the entries and add them to the RSS feed
13
- *
14
- * @param Zend_Feed_Writer_Feed $feed
15
- * @return $this
16
- */
17
- protected function _addEntriesToFeed($feed)
18
- {
19
- $comments = Mage::getResourceModel('wordpress/post_comment_collection')
20
- ->addCommentApprovedFilter()
21
- ->addOrderByDate('desc');
22
-
23
- $this->_prepareItemCollection($comments);
24
-
25
- foreach($comments as $comment) {
26
- $entry = $feed->createEntry();
27
-
28
- if ($this->getSource()) {
29
- $entry->setTitle(
30
- Mage::helper('wordpress')->__('By: %s', $comment->getCommentAuthor())
31
- );
32
- }
33
- else {
34
- $entry->setTitle(
35
- Mage::helper('wordpress')->__('Comment on %s by %s', $comment->getPost()->getPostTitle(), $comment->getCommentAuthor())
36
- );
37
- }
38
-
39
- if (strpos($comment->getUrl(), 'http') !== false) {
40
- $entry->setLink($comment->getUrl());
41
- }
42
-
43
- if ($comment->getCommentAuthorEmail() && $comment->getCommentAuthor()) {
44
- $entry->addAuthor(array(
45
- 'name' => $comment->getCommentAuthor(),
46
- 'email' => $comment->getCommentAuthorEmail(),
47
- ));
48
- }
49
-
50
- $entry->setDescription($comment->getCommentContent());
51
- $entry->setDateModified(strtotime($comment->getData('comment_date_gmt')));
52
-
53
- $feed->addEntry($entry);
54
- }
55
-
56
- return $this;
57
- }
58
-
59
- /**
60
- * Apply the source filter if available
61
- *
62
- * @param $collection
63
- * @return $this
64
- */
65
- protected function _prepareItemCollection($collection)
66
- {
67
- if ($this->getSource()) {
68
- $collection->addPostIdFilter($this->getSource()->getId());
69
- }
70
-
71
- return parent::_prepareItemCollection($collection);
72
- }
73
-
74
- /**
75
- * Retrieve the feed title
76
- *
77
- * @return string
78
- */
79
- public function getTitle()
80
- {
81
- if ($this->getSource()) {
82
- return sprintf('Comments on: %s', $this->getSource()->getPostTitle());
83
- }
84
- else {
85
- return sprintf('Comments for %s', parent::getTitle());
86
- }
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Homepage.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Homepage extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Get's the blog title
13
- *
14
- * @return string
15
- */
16
- public function getBlogTitle()
17
- {
18
- return Mage::helper('wordpress')->getWpOption('blogname');
19
- }
20
-
21
- /**
22
- * Retrieve the tag line set in the WordPress Admin
23
- *
24
- * @return string
25
- */
26
- public function getTagLine()
27
- {
28
- return trim($this->helper('wordpress')->getWpOption('blogdescription'));
29
- }
30
-
31
- /**
32
- * Returns the blog homepage URL
33
- *
34
- * @return string
35
- */
36
- public function getBlogHomepageUrl()
37
- {
38
- return Mage::helper('wordpress')->getUrl();
39
- }
40
-
41
- /**
42
- * Determine whether the first page of posts are being displayed
43
- *
44
- * @return bool
45
- */
46
- public function isFirstPage()
47
- {
48
- return $this->getRequest()->getParam('page', '1') === '1';
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
- return parent::_getPostCollection()
59
- ->addStickyPostsToCollection()
60
- ->addPostTypeFilter('post');
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Menu.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Menu extends Mage_Page_Block_Html_Topmenu
10
- {
11
- /**
12
- * Get top menu html
13
- *
14
- * @param string $outermostClass
15
- * @param string $childrenWrapClass
16
- * @return string
17
- */
18
- public function getHtml($outermostClass = '', $childrenWrapClass = '')
19
- {
20
- $this->_menu->setOutermostClass($outermostClass);
21
- $this->_menu->setChildrenWrapClass($childrenWrapClass);
22
-
23
- return trim($this->_getHtml($this->_menu, $childrenWrapClass));
24
- }
25
-
26
- /**
27
- * Load and render the menu
28
- *
29
- * @return bool
30
- */
31
- protected function _beforeToHtml()
32
- {
33
- if ($this->getMenuId()) {
34
- $menu = Mage::getModel('wordpress/menu')->load($this->getMenuId());
35
-
36
- if ($menu->getId()) {
37
- $this->setMenu($menu);
38
-
39
- if ($menu->applyToTreeNode($this->_menu)) {
40
- if (($html = trim($this->getHtml())) !== '') {
41
- if ($this->includeWrapper()) {
42
- $html = sprintf('<ul %s>%s</ul>', $this->_getListParams(), $html);
43
- }
44
-
45
- $this->setMenuHtml($this->_beforeRenderMenuHtml($html));
46
- }
47
-
48
- return true;
49
- }
50
- }
51
- }
52
-
53
- return false;
54
- }
55
-
56
- /**
57
- * Determine whether to include the wrapping UL tag
58
- *
59
- * @param bool $val = null
60
- * @return $this|bool
61
- */
62
- public function includeWrapper($val = null)
63
- {
64
- if (!is_null($val)) {
65
- return $this->setIncludeWrapper($val);
66
- }
67
-
68
- return is_null($this->getIncludeWrapper())
69
- ? false
70
- : $this->getIncludeWrapper();
71
- }
72
-
73
- /*
74
- * Generate the list element parameters
75
- *
76
- * @return string
77
- */
78
- protected function _getListParams()
79
- {
80
- $params = array();
81
-
82
- if ($this->getListClass()) {
83
- $params[] = sprintf('class="%s"', $this->getListClass());
84
- }
85
-
86
- if ($this->getListId()) {
87
- $params[] = sprintf('id="%s"', $this->getListId());
88
- }
89
-
90
- return implode(' ', $params);
91
- }
92
-
93
- /**
94
- * Add the wrapper div if required
95
- *
96
- * @param string $html
97
- * @return string
98
- */
99
- protected function _beforeRenderMenuHtml($html)
100
- {
101
- if ($this->getIncludeWrapper() || $this->getWrapperId() || $this->getWrapperClass()) {
102
- $params = array();
103
-
104
- if ($this->getWrapperId()) {
105
- $params[] = sprintf('id="%s"', $this->getWrapperId());
106
- }
107
-
108
- if ($this->getWrapperClass()) {
109
- $params[] = sprintf('class="%s"', $this->getWrapperClass());
110
- }
111
-
112
- return sprintf('<div %s>%s</div>', implode(' ', $params), $html);
113
- }
114
-
115
- return $html;
116
- }
117
-
118
- /**
119
- * Return the menu HTML
120
- *
121
- * @return string
122
- */
123
- protected function _toHtml()
124
- {
125
- if (!$this->getTemplate()) {
126
- if ($this->_beforeToHtml() === false) {
127
- return '';
128
- }
129
-
130
- return $this->getMenuHtml();
131
- }
132
-
133
- return parent::_toHtml();
134
- }
135
-
136
- /**
137
- * Retrieve the Menu title
138
- *
139
- * @return string
140
- */
141
- public function getTitle()
142
- {
143
- if ($this->getMenu()) {
144
- return $this->getMenu()->getName();
145
- }
146
-
147
- return '';
148
- }
149
-
150
- /**
151
- * Escape the HTML. Allows for legacy
152
- *
153
- * @param string $data
154
- * @param array $allowedTags = null
155
- * @return string
156
- */
157
- public function escapeHtml($data, $allowedTags = null)
158
- {
159
- return Mage::helper('wordpress')->escapeHtml($data, $allowedTags);
160
- }
161
-
162
- /**
163
- * Retrieve cache key data
164
- *
165
- * @return array
166
- */
167
- public function getCacheKeyInfo()
168
- {
169
- $cacheId = parent::getCacheKeyInfo();
170
-
171
- $cacheId['menu_id'] = $this->getMenuId();
172
-
173
- return $cacheId;
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Page/View.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Page_View extends Fishpig_Wordpress_Block_Post_View
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Abstract.php DELETED
@@ -1,193 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Post_Abstract extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Retrieve the current post object
13
- *
14
- * @return null|Fishpig_Wordpress_Model_Post
15
- */
16
- public function getPost()
17
- {
18
- return $this->hasPost() ? $this->_getData('post') : Mage::registry('wordpress_post');
19
- }
20
-
21
- /**
22
- * Legacy function so that old templates continue to work
23
- *
24
- * @return Fishpig_Wordpress_Model_Post
25
- */
26
- public function getPage()
27
- {
28
- return $this->getPost();
29
- }
30
-
31
- /**
32
- * Returns the ID of the currently loaded post
33
- *
34
- * @return int|false
35
- */
36
- public function getPostId()
37
- {
38
- return $this->getPost() ? $this->getPost()->getId() : false;
39
- }
40
-
41
- /**
42
- * Returns true if comments are enabled for this post
43
- *
44
- * @return bool
45
- */
46
- protected function canComment()
47
- {
48
- return $this->getPost()
49
- && $this->getPost()->getCommentStatus() === 'open';
50
- }
51
-
52
- /**
53
- * Determine whether previous/next links are enabled in the config
54
- *
55
- * @return bool
56
- */
57
- public function canDisplayPreviousNextLinks()
58
- {
59
- return (bool)$this->_getData('display_previous_next_links');
60
- }
61
-
62
- /**
63
- * Retrieve the HTML for the password protect form
64
- *
65
- * @param Fishpig_Wordpress_Model_Post $post
66
- * @return string
67
- */
68
- public function getPasswordProtectHtml($post = null)
69
- {
70
- if (is_null($post)) {
71
- $post = $this->getPost();
72
- }
73
-
74
- return $this->getLayout()
75
- ->createBlock('wordpress/template')
76
- ->setTemplate('wordpress/protected.phtml')
77
- ->setEntityType('post')
78
- ->setPost($post)
79
- ->toHtml();
80
- }
81
-
82
- /**
83
- * Determine whether to display the full post content or the excerpt
84
- *
85
- * @return bool
86
- */
87
- public function displayExcerptInFeed()
88
- {
89
- return Mage::helper('wordpress')->getWpOption('rss_use_excerpt') == '1';
90
- }
91
-
92
- /**
93
- * If post view, setup the post with child blocks
94
- *
95
- * @return $this
96
- */
97
- protected function _beforeToHtml()
98
- {
99
- if ($this->getPost() && $this->_getBlockForPostPrepare() !== false) {
100
- $this->preparePost($this->getPost());
101
- }
102
-
103
- return parent::_beforeToHtml();
104
- }
105
-
106
- /**
107
- * Set the post as the current post in all child blocks
108
- *
109
- * @param Fishpig_Wordpress_Model_Post $post
110
- * @return $this
111
- */
112
- public function preparePost(Fishpig_Wordpress_Model_Post $post)
113
- {
114
- if (($rootBlock = $this->_getBlockForPostPrepare()) !== false) {
115
- foreach($rootBlock->getChild('') as $alias => $block) {
116
- $block->setPost($post);
117
-
118
- foreach($block->getChild('') as $calias => $cblock) {
119
- $cblock->setPost($post);
120
- }
121
- }
122
- }
123
-
124
- return $this;
125
- }
126
-
127
- /**
128
- * Retrieve the block used to prepare the post
129
- * This should be the root post block
130
- *
131
- * @return Fishpig_Wordpress_Block_Post_Abstract
132
- */
133
- protected function _getBlockForPostPrepare()
134
- {
135
- return $this;
136
- }
137
-
138
- /**
139
- * Retrieve the after_post_content HTML
140
- *
141
- * @return string
142
- */
143
- public function getAfterPostContentHtml()
144
- {
145
- return $this->_getChildTextList('after_post_content');
146
- }
147
-
148
- /**
149
- * Retrieve the before_post_content HTML
150
- *
151
- * @return string
152
- */
153
- public function getBeforePostContentHtml()
154
- {
155
- return $this->_getChildTextList('before_post_content');
156
- }
157
-
158
- /**
159
- * Validate and retrieve a child core/text_list HTML
160
- *
161
- * @param string $name
162
- * @return string
163
- */
164
- protected function _getChildTextList($name)
165
- {
166
- if (($block = $this->_getBlockForPostPrepare()) !== false) {
167
- if (($child = $block->getChild($name)) !== false) {
168
- if ($child->getChild('')) {
169
- return $child->toHtml();
170
- }
171
- }
172
- }
173
-
174
- return '';
175
- }
176
-
177
- /**
178
- * Get the Meta block
179
- *
180
- * @return Fishpig_Wordpress_Block_Post_Meta
181
- */
182
- public function getMetaBlock()
183
- {
184
- if (!$this->hasMetaBlock()) {
185
- $this->setMetaBlock(
186
- $this->getLayout()->createBlock('wordpress/post_meta')
187
- ->setTemplate('wordpress/post/meta.phtml')
188
- );
189
- }
190
-
191
- return $this->_getData('meta_block');
192
- }
193
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Associated.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_Associated extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Cache for post collection
13
- *
14
- * @param null|Fishpig_Wordpress_Model_Resource_Post_Collection
15
- */
16
- protected $_postCollection = null;
17
-
18
- /**
19
- * Retrieve the association entity type
20
- *
21
- * @param string
22
- */
23
- public function getEntity()
24
- {
25
- if (!$this->hasEntity()) {
26
- $this->setEntity('product');
27
- }
28
-
29
- return $this->_getData('entity');
30
- }
31
-
32
- /**
33
- * Retrieve the current Magento entity object
34
- *
35
- * @return false|Mage_Core_Model_Abstract
36
- */
37
- public function getObject()
38
- {
39
- if (!$this->hasObject()) {
40
- if (!$this->getEntity()) {
41
- $this->setObject(false);
42
- return false;
43
- }
44
-
45
- if ($this->getEntity()==='cms_page') {
46
- $this->setObject(Mage::getSingleton('cms/page'));
47
- }
48
- else {
49
- $this->setObject(Mage::registry($this->getEntity()));
50
- }
51
- }
52
-
53
- return $this->_getData('object');
54
- }
55
-
56
- /**
57
- * Retrieve the posts collection
58
- *
59
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
60
- */
61
- public function getPostCollection()
62
- {
63
- if (is_null($this->_postCollection)) {
64
- $this->_postCollection = false;
65
-
66
- if (!$this->getObject()) {
67
- return false;
68
- }
69
-
70
- $helper = $this->helper('wordpress/associations');
71
-
72
- if ($this->getObject() instanceof Mage_Catalog_Model_Product) {
73
- $collection = $helper->getAssociatedPostsByProduct($this->getObject());
74
- }
75
- else if ($this->getObject() instanceof Mage_Cms_Model_Page) {
76
- $collection = $helper->getAssociatedPostsByCmsPage($this->getObject());
77
- }
78
-
79
- if ($collection) {
80
- if ($this->getCount()) {
81
- $collection->setCurPage(1)->setPageSize($this->getCount());
82
- }
83
-
84
- if ($this->getOrder()) {
85
- $dir = $this->getOrderDir() ? $this->getOrderDir() : 'asc';
86
- $collection->getSelect()->order($this->getOrder() . ' ' . $dir);
87
- }
88
- }
89
-
90
- Mage::dispatchEvent('wordpress_association_post_collection_load_before', array('collection' => $collection));
91
-
92
- $this->_postCollection = $collection;
93
- }
94
-
95
- return $this->_postCollection;
96
- }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Associated/Products.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_Associated_Products extends Mage_Catalog_Block_Product_Abstract
10
- {
11
- /**
12
- * Retrieve a collection of products
13
- *
14
- * @return array|Mage_Catalog_Model_Mysql4_Resource_Eav_Mysql4_Product_Collection
15
- */
16
- public function getProducts($attributes = null)
17
- {
18
- if ($this->getPost() !== null) {
19
- $collection = Mage::helper('wordpress/associations')->getAssociatedProductsByPost($this->getPost());
20
-
21
- if ($collection !== false) {
22
- if (is_null($attributes)) {
23
- $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
24
- }
25
-
26
- if ($this->getCount()) {
27
- $collection->setPageSize($this->getCount())
28
- ->setCurPage(1);
29
- }
30
-
31
-
32
-
33
- return $collection->addAttributeToSelect($attributes);
34
- }
35
- }
36
-
37
- return array();
38
- }
39
-
40
- /**
41
- * Retrieve the post object
42
- *
43
- * @return false|Fishpig_Wordpress_Model_Post
44
- */
45
- public function getPost()
46
- {
47
- return Mage::registry('wordpress_post');
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List.php DELETED
@@ -1,172 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_List extends Fishpig_Wordpress_Block_Post_Abstract
10
- {
11
- /**
12
- * Cache for post collection
13
- *
14
- * @var Fishpig_Wordpress_Model_Resource_Post_Collection
15
- */
16
- protected $_postCollection = null;
17
-
18
- /**
19
- * Returns the collection of posts
20
- *
21
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
22
- */
23
- public function getPosts()
24
- {
25
- return $this->_getPostCollection();
26
- }
27
-
28
- /**
29
- * Generates and returns the collection of posts
30
- *
31
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
32
- */
33
- protected function _getPostCollection()
34
- {
35
- if (is_null($this->_postCollection) && $this->getWrapperBlock()) {
36
- $this->_postCollection = $this->getWrapperBlock()->getPostCollection();
37
-
38
- if ($this->_postCollection) {
39
- if ($this->getPostType()) {
40
- $this->_postCollection->addPostTypeFilter($this->getPostType());
41
- }
42
-
43
- if ($this->getPagerBlock()) {
44
- $this->getPagerBlock()->setCollection($this->_postCollection);
45
- }
46
- }
47
- }
48
-
49
- return $this->_postCollection;
50
- }
51
-
52
- /**
53
- * Sets the parent block of this block
54
- * This block can be used to auto generate the post list
55
- *
56
- * @param Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper
57
- * @return $this
58
- */
59
- public function setWrapperBlock(Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract $wrapper)
60
- {
61
- return $this->setData('wrapper_block', $wrapper);
62
- }
63
-
64
- /**
65
- * Get the pager block
66
- * If the block isn't set in the layout XML, it will be created and will use the default template
67
- *
68
- * @return Fishpig_Wordpress_Post_List_Pager
69
- */
70
- public function getPagerBlock()
71
- {
72
- if (!$this->hasPagerBlock()) {
73
- $this->setPagerBlock(false);
74
-
75
- if (!$this->getChild('pager')) {
76
- $this->setChild('pager', $this->getLayout()
77
- ->createBlock('wordpress/post_list_pager')
78
- ->setNameInLayout('wordpress_post_list')
79
- ->setAlias('pager')
80
- );
81
- }
82
-
83
- if ($pager = $this->getChild('pager')) {
84
- $this->setPagerBlock(
85
- $pager->setPostListBlock($this)
86
- );
87
- }
88
- }
89
-
90
- return $this->_getData('pager_block');
91
- }
92
-
93
- /**
94
- * Get the HTML for the pager block
95
- *
96
- * @return string
97
- */
98
- public function getPagerHtml()
99
- {
100
- return $this->getChildHtml('pager');
101
- }
102
-
103
- /**
104
- * Retrieve the correct renderer and template for $post
105
- *
106
- * @param Fishpig_Wordpress_Model_Post $post
107
- * @return Fishpig_Wordpress_Block_Post_List_Renderer
108
- */
109
- public function getPostRenderer(Fishpig_Wordpress_Model_Post $post)
110
- {
111
- if (!$this->hasPostRenderer()) {
112
- $this->setPostRenderer(
113
- $this->getLayout()->createBlock('wordpress/post_list_renderer')
114
- ->setParentBlock($this)
115
- ->setExcerptSize($this->getExcerptSize())
116
- );
117
- }
118
-
119
- return $this->_getData('post_renderer')
120
- ->setPost($post)
121
- ->setTemplate(
122
- $this->getPostRendererTemplate($post)
123
- );
124
- }
125
-
126
- /**
127
- * Get the post renderer template
128
- *
129
- * @param Fishpig_Wordpress_Model_Post $post
130
- * @return string
131
- */
132
- public function getPostRendererTemplate(Fishpig_Wordpress_Model_Post $post)
133
- {
134
- if ($archiveTemplate = $post->getTypeInstance()->getArchiveTemplate()) {
135
- return $archiveTemplate;
136
- }
137
-
138
- if ($this->hasPostRendererTemplate()) {
139
- return $this->_getData('post_renderer_template');
140
- }
141
-
142
- return 'wordpress/post/list/renderer/default.phtml';
143
- }
144
-
145
- /**
146
- * Ensure that the post list handle is set (adds the pager)
147
- *
148
- * @return $this
149
- */
150
- protected function _prepareLayout()
151
- {
152
- $this->getLayout()
153
- ->getUpdate()
154
- ->addHandle('wordpress_post_list');
155
-
156
- return parent::_prepareLayout();
157
- }
158
-
159
- /**
160
- * Ensure a valid template is set
161
- *
162
- * @return $this
163
- */
164
- protected function _beforeToHtml()
165
- {
166
- if (!$this->getTemplate()) {
167
- $this->setTemplate('wordpress/post/list.phtml');
168
- }
169
-
170
- return parent::_beforeToHtml();
171
- }
172
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Associated.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_List_Associated extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Set the number of posts to display to 5
13
- * This can be overridden using self::setPostCount($postCount)
14
- */
15
- public function __construct()
16
- {
17
- parent::__construct();
18
- $this->_pagerLimit = 5;
19
- $this->setPostListTemplate('wordpress/post/associated/list.phtml');
20
- $this->setTitle('Blog Posts Associated With This Product');
21
- }
22
-
23
- /**
24
- * Sets the number of posts to display
25
- *
26
- * @param string $postCount
27
- */
28
- public function setPostCount($postCount = 5)
29
- {
30
- $this->_pagerLimit = $postCount;
31
- return $this;
32
- }
33
-
34
- /**
35
- * Adds on cateogry/author ID filters
36
- *
37
- * @return array|Fishpig_Wordpress_Model_Mysql4_Post_Collection
38
- */
39
- protected function _getPostCollection()
40
- {
41
- if ($this->getProduct()) {
42
- $collection = Mage::helper('wordpress/associations')->getAssociatedPostsByProduct($this->getProduct());
43
-
44
- if ($collection !== false) {
45
- return $collection->setCurPage(1);
46
- }
47
- }
48
-
49
- return false;
50
- }
51
-
52
- /**
53
- * Get's the current product if 1 hasn't been set
54
- *
55
- * @return Mage_Catalog_Model_Product
56
- */
57
- public function getProduct()
58
- {
59
- if (!$this->hasProduct()) {
60
- if (!$this->hasProductId()) {
61
- $this->setProduct(Mage::registry('product'));
62
- }
63
- else {
64
- $this->setProduct(Mage::getModel('catalog/product')->load($this->getProductId()));
65
- }
66
- }
67
-
68
- return $this->getData('product');
69
- }
70
-
71
- /**
72
- * Retrieve the base URI to be used for the pager
73
- * This isn't needed for this page but has to be included anyway
74
- *
75
- * @return false|string
76
- */
77
- protected function _getPagerUri()
78
- {
79
- return '/';
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Pager.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_List_Pager extends Mage_Page_Block_Html_Pager
10
- {
11
- /**
12
- * Construct the pager and set the limits
13
- *
14
- */
15
- protected function _construct()
16
- {
17
- parent::_construct();
18
-
19
- $this->setPageVarName('page');
20
-
21
- $baseLimit = $this->helper('wordpress')->getWpOption('posts_per_page', 10);
22
-
23
- $this->setDefaultLimit($baseLimit);
24
- $this->setLimit($baseLimit);
25
-
26
- $this->setAvailableLimit(array(
27
- $baseLimit => $baseLimit,
28
- ));
29
-
30
- $this->setFrameLength(5);
31
- }
32
-
33
- /**
34
- * Return the URL for a certain page of the collection
35
- *
36
- * @return string
37
- */
38
- public function getPagerUrl($params=array())
39
- {
40
- $pageVarName = $this->getPageVarName();
41
-
42
- $slug = isset($params[$pageVarName])
43
- ? $pageVarName . '/' . $params[$pageVarName] . '/'
44
- : '';
45
-
46
- $slug = ltrim($slug, '/');
47
-
48
- $baseUrl = $this->getUrl('*/*/*', array(
49
- '_current' => true,
50
- '_escape' => true,
51
- '_use_rewrite' => true,
52
- '_nosid' => true,
53
- '_query' => array('___refresh' => null),
54
- ));
55
-
56
- $queryString = '';
57
-
58
- if (strpos($baseUrl, '?') !== false) {
59
- $queryString = substr($baseUrl, strpos($baseUrl, '?'));
60
- $baseUrl = substr($baseUrl, 0, strpos($baseUrl, '?'));
61
- }
62
-
63
- return rtrim($baseUrl, '/') . '/' . $slug . $queryString;
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Renderer.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_List_Renderer extends Fishpig_Wordpress_Block_Post_Abstract
10
- {
11
- /**
12
- * Retrieve the correct block to prepare posts
13
- *
14
- * @return Fishpig_Wordpress_Block_Post_List
15
- */
16
- protected function _getBlockForPostPrepare()
17
- {
18
- return $this->getParentBlock();
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/List/Wrapper/Abstract.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Returns the collection of posts
13
- *
14
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
15
- */
16
- public function getPostCollection()
17
- {
18
- if (!$this->hasPostCollection() && ($collection = $this->_getPostCollection()) !== false) {
19
- $collection->addIsViewableFilter()->addOrder('post_date', 'desc');
20
-
21
- $this->setPostCollection($collection);
22
-
23
- $collection->setFlag('after_load_event_name', $this->_getPostCollectionEventName() . '_after_load');
24
- $collection->setFlag('after_load_event_block', $this);
25
-
26
- Mage::dispatchEvent('wordpress_post_collection_before_load', array('block' => $this, 'collection' => $collection));
27
- Mage::dispatchEvent($this->_getPostCollectionEventName() . '_before_load', array('block' => $this, 'collection' => $collection));
28
- }
29
-
30
- return $this->_getData('post_collection');
31
- }
32
-
33
- /**
34
- * Retrieve the event name for before the post collection is loaded
35
- *
36
- * @return string
37
- */
38
- protected function _getPostCollectionEventName()
39
- {
40
- $class = get_class($this);
41
-
42
- return 'wordpress_block_' . strtolower(substr($class, strpos($class, 'Block')+6)) . '_post_collection';
43
- }
44
-
45
- /**
46
- * Generates and returns the collection of posts
47
- *
48
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
49
- */
50
- protected function _getPostCollection()
51
- {
52
- return Mage::getResourceModel('wordpress/post_collection');
53
- }
54
-
55
- /**
56
- * Returns the HTML for the post collection
57
- *
58
- * @return string
59
- */
60
- public function getPostListHtml()
61
- {
62
- if (($postListBlock = $this->getPostListBlock()) !== false) {
63
- return $postListBlock->toHtml();
64
- }
65
-
66
- return '';
67
- }
68
-
69
- /**
70
- * Gets the post list block
71
- *
72
- * @return Fishpig_Wordpress_Block_Post_List|false
73
- */
74
- public function getPostListBlock()
75
- {
76
- if (($postListBlock = $this->getChild('post_list')) !== false) {
77
- if (!$postListBlock->getWrapperBlock()) {
78
- $postListBlock->setWrapperBlock($this);
79
- }
80
-
81
- return $postListBlock;
82
- }
83
-
84
- return false;
85
- }
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/Meta.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_Meta extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Retrieve the category string (Posted in %s, %s and %s)
13
- *
14
- * @param Fishpig_Wordpress_Model_Post $post,
15
- * @param array $params = array
16
- * @return string
17
- */
18
- public function getTermsAsHtml(Fishpig_Wordpress_Model_Post $post, $taxonomy)
19
- {
20
- $html = array();
21
- $taxonomy = Mage::helper('wordpress/app')->getTaxonomy($taxonomy);
22
-
23
- if ($taxonomy) {
24
- $terms = $taxonomy->getPostTermsCollection($post);
25
-
26
- if (count($terms) > 0) {
27
- foreach($terms as $term) {
28
- $html[] = $this->_generateAnchor($term->getUrl(), $term->getName());
29
- }
30
- }
31
- }
32
-
33
- return implode(', ', $html);
34
- }
35
-
36
- /**
37
- * Retrieve the author string
38
- *
39
- * @param Fishpig_Wordpress_Model_Post $post,
40
- * @param array $params = array
41
- * @return string
42
- */
43
- public function getAuthorString(Fishpig_Wordpress_Model_Post $post)
44
- {
45
- $author = $post->getAuthor();
46
-
47
- return $this->_generateAnchor($author->getUrl(), $author->getDisplayName());
48
- }
49
-
50
- /**
51
- * Generate an anchor tag
52
- *
53
- * @param string $href
54
- * @param string $anchor
55
- * @param array $params = array
56
- * @return string
57
- */
58
- protected function _generateAnchor($href, $anchor)
59
- {
60
- return sprintf('<a href="%s">%s</a>', $href, $anchor);
61
- }
62
-
63
- /**
64
- * Determine whether previous/next links are enabled in the config
65
- *
66
- * @return bool
67
- */
68
- public function canDisplayPreviousNextLinks()
69
- {
70
- return $this->_getData('display_previous_next_links');
71
- }
72
-
73
- /**
74
- * Retrieve the category string (Posted in %s, %s and %s)
75
- *
76
- * @param Fishpig_Wordpress_Model_Post $post,
77
- * @return string
78
- */
79
- public function getCategoryString(Fishpig_Wordpress_Model_Post $post, array $params = array())
80
- {
81
- return $this->getTermsAsHtml($post, 'post_category');
82
- }
83
-
84
- /**
85
- * Retrieve the tag string (tagged with %s, %s and %s)
86
- *
87
- * @param Fishpig_Wordpress_Model_Post $post,
88
- * @return string
89
- */
90
- public function getTagString(Fishpig_Wordpress_Model_Post $post, array $params = array())
91
- {
92
- return $this->getTermsAsHtml($post, 'post_tag');
93
- }
94
-
95
- /**
96
- * Determine whether a post has tags
97
- *
98
- * @param Fishpig_Wordpress_Model_Post $post
99
- * @return bool
100
- */
101
- public function hasTags(Fishpig_Wordpress_Model_Post $post)
102
- {
103
- return trim($this->getTermsAsHtml($post, 'post_tag')) !== '';
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_View extends Fishpig_Wordpress_Block_Post_Abstract
10
- {
11
- /**
12
- * Returns the HTML for the comments block
13
- *
14
- * @return string
15
- */
16
- public function getCommentsHtml()
17
- {
18
- return $this->getChildHtml('comments');
19
- }
20
-
21
- /**
22
- * Setup the comments block
23
- *
24
- */
25
- protected function _beforeToHtml()
26
- {
27
- if ($this->getChild('comments')) {
28
- $this->getChild('comments')->setPost($this->getPost());
29
- }
30
-
31
- $this->_initPostViewTemplate();
32
-
33
- return parent::_beforeToHtml();
34
- }
35
-
36
- /**
37
- * Get the post renderer template
38
- *
39
- * @param Fishpig_Wordpress_Model_Post $post
40
- * @return string
41
- */
42
- protected function _initPostViewTemplate()
43
- {
44
- if ($this->getTemplate()) {
45
- return $this;
46
- }
47
-
48
- if ($viewTemplate = $this->getPost()->getTypeInstance()->getViewTemplate()) {
49
- return $this->setTemplate($viewTemplate);
50
- }
51
- else if ($this->getPost()->getPostViewTemplate()) {
52
- return $this->setTemplate($this->getPost()->getPostViewTemplate());
53
- }
54
- else {
55
- $this->setTemplate('wordpress/post/view.phtml');
56
- }
57
-
58
- return $this;
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Abstract.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Post_View_Comment_Abstract extends Fishpig_Wordpress_Block_Post_Abstract
10
- {
11
- /**
12
- * Returns a collection of comments for the current post
13
- *
14
- * @return Fishpig_Wordpress_Model_Resource_Post_Comments_Collection
15
- */
16
- public function getComments()
17
- {
18
- if (!$this->hasComments()) {
19
- if ($this->getCommentCount() > 0 && ($post = $this->getPost()) !== false) {
20
- $this->setComments($post->getResource()->getPostComments($post));
21
-
22
- if (($pager = $this->getChild('pager')) !== false) {
23
- $this->_getData('comments')->setPageSize($pager->getLimit());
24
- }
25
- }
26
- else {
27
- $this->setComments(new Varien_Data_Collection());
28
- }
29
- }
30
-
31
- return $this->_getData('comments');
32
- }
33
-
34
- /**
35
- * Retrieve the amount of comments for the current post
36
- *
37
- * @return int
38
- */
39
- public function getCommentCount()
40
- {
41
- return $this->getPost()->getCommentCount();
42
- }
43
-
44
- /**
45
- * Determine whether comments are enabled
46
- *
47
- * @return bool
48
- */
49
- public function isCommentsEnabled()
50
- {
51
- return $this->getPost()->getCommentStatus() !== 'closed';
52
- }
53
-
54
- /**
55
- * Get the comment content
56
- * Filter out certain HTML tags
57
- *
58
- * @param Fishpig_Wordpress_Model_Post_Comment $comment
59
- * @return string
60
- */
61
- public function getCommentContent(Fishpig_Wordpress_Model_Post_Comment $comment)
62
- {
63
- $content = strip_tags(trim($comment->getCommentContent()), $this->getAllowedHtmlTags());
64
-
65
- return $this->canConvertNewLines()
66
- ? nl2br($content)
67
- : $content;
68
- }
69
-
70
-
71
- public function getCommentsFormHtml()
72
- {
73
- return $this->getFormHtml();
74
- }
75
-
76
- /**
77
- * Returns the HTML for the comment form
78
- *
79
- * @return string
80
- */
81
- public function getFormHtml()
82
- {
83
- if ($this->isCommentsEnabled()) {
84
- return $this->getChildHtml('form');
85
- }
86
-
87
- return '';
88
- }
89
-
90
-
91
- /**
92
- * Get the HTML for the pager block
93
- *
94
- * @return null|string
95
- */
96
- public function getPagerHtml()
97
- {
98
- if ($this->helper('wordpress')->getWpOption('page_comments', false)) {
99
- return $this->getChildHtml('pager');
100
- }
101
- }
102
-
103
- /**
104
- * Retrieve the allowed HTML tags as a string
105
- *
106
- * @return string
107
- */
108
- public function getAllowedHtmlTags()
109
- {
110
- if (!$this->hasAllowedHtmlTags()) {
111
- return '<a><abbr><acronym><b><blockquote><cite><code><del><em><i><q><strike><strong>';
112
- }
113
-
114
- return $this->_getData('allowed_html_tags');
115
- }
116
-
117
- /**
118
- * Determine whether to convert new lines to <br /> tags
119
- * To disable this feature, call self::setConvertNewLines(false)
120
- *
121
- * @return bool
122
- */
123
- public function canConvertNewLines()
124
- {
125
- return !$this->hasConvertNewLines() || (int)$this->getConvertNewLines() !== false;
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Form.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_View_Comment_Form extends Fishpig_Wordpress_Block_Post_Abstract
10
- {
11
- /**
12
- * Inject the comments js
13
- *
14
- * @return $this
15
- */
16
- protected function _prepareLayout()
17
- {
18
- if (($head = $this->getLayout()->getBlock('head')) !== false) {
19
- $head->addJs('fishpig/wordpress/comments.js');
20
- }
21
-
22
- return parent::_prepareLayout();
23
- }
24
-
25
- /**
26
- * Ensure a valid template is set
27
- *
28
- * @return $this
29
- */
30
- protected function _beforeToHtml()
31
- {
32
- if (!$this->getTemplate()) {
33
- $this->setTemplate('wordpress/post/view/comment/form.phtml');
34
- }
35
-
36
- return parent::_beforeToHtml();
37
- }
38
-
39
- /**
40
- * Retrieve the comment form action
41
- *
42
- * @return string
43
- */
44
- public function getCommentFormAction()
45
- {
46
- return Mage::helper('wordpress')->getBaseUrl('wp-comments-post.php');
47
- }
48
-
49
- /**
50
- * Determine whether the customer needs to login before commenting
51
- *
52
- * @return bool
53
- */
54
- public function customerMustLogin()
55
- {
56
- if ($this->helper('wordpress')->getWpOption('comment_registration')) {
57
- return !Mage::getSingleton('customer/session')->isLoggedIn();
58
- }
59
-
60
- return false;
61
- }
62
-
63
- /**
64
- * Retrieve the link used to log the user in
65
- * If redirect to dashboard after login is disabled, the user will be redirected back to the blog post
66
- *
67
- * @return string
68
- */
69
- public function getLoginLink()
70
- {
71
- return Mage::getUrl('customer/account/login', array(
72
- 'referer' => $this->helper('core')->urlEncode($this->getPost()->getPermalink() . '#respond'),
73
- ));
74
- }
75
-
76
- /**
77
- * Returns true if the user is logged in
78
- *
79
- * @return bool
80
- */
81
- public function isCustomerLoggedIn()
82
- {
83
- return Mage::getSingleton('customer/session')->isLoggedIn();
84
- }
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Pager.php DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_View_Comment_Pager extends Fishpig_Wordpress_Block_Post_List_Pager
10
- {
11
- /**
12
- * Gets the comments per page limit
13
- *
14
- * @return int
15
- */
16
- public function getLimit()
17
- {
18
- $this->_limit = $this->getRequest()->getParam('limit', Mage::helper('wordpress')->getWpOption('comments_per_page', 50));
19
-
20
- return $this->_limit;
21
- }
22
-
23
- /**
24
- * Returns the available limits for the pager
25
- * As Wordpress uses a fixed page size limit, this returns only 1 limit (the value set in WP admin)
26
- * This effectively hides the 'Show 4/Show 10' drop down
27
- *
28
- * @return array
29
- */
30
- public function getAvailableLimit()
31
- {
32
- return array($this->getPagerLimit() => $this->getPagerLimit());
33
- }
34
-
35
- /**
36
- * Retrieve the variable used to generate URLs
37
- *
38
- * @return string
39
- */
40
- public function getPageVarName()
41
- {
42
- return 'page';
43
- }
44
-
45
- /**
46
- * Convert the URL to correct URL for the comments pager
47
- *
48
- * @return string
49
- */
50
- public function getPagerUrl($params=array())
51
- {
52
- if (isset($params['page']) && $params['page'] != 1) {
53
- return rtrim($this->getPost()->getPermalink(), '/')
54
- . '/' . sprintf(trim($this->helper('wordpress/router')->getCommentPagerVarFormat(), '^$'), $params['page']) . '#comments';
55
- }
56
-
57
- return $this->getPost()->getPermalink() . '#comments';
58
- }
59
-
60
- /**
61
- * Retrieve the post object
62
- *
63
- * @return Fishpig_Wordpress_Model_Post
64
- */
65
- public function getPost()
66
- {
67
- return Mage::registry('wordpress_post');
68
- }
69
-
70
- /**
71
- * Retrieve the current page ID
72
- *
73
- * @return int
74
- */
75
- public function getCurrentPage()
76
- {
77
- if (!$this->hasCurrentPage()) {
78
- $results = array();
79
-
80
- if (preg_match("/comment-page-([0-9]{1,})$/", $this->helper('core/url')->getCurrentUrl(), $results)) {
81
- if (isset($results[1])) {
82
- $this->setCurrentPage($results[1]);
83
- }
84
- }
85
- else {
86
- $this->setCurrentPage(1);
87
- }
88
- }
89
-
90
- return $this->getData('current_page');
91
- }
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comment/Wrapper.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_View_Comment_Wrapper extends Fishpig_Wordpress_Block_Post_View_Comment_Abstract
10
- {
11
- /**
12
- * Setup the pager and comments form blocks
13
- *
14
- * @return $this
15
- */
16
- protected function _beforeToHtml()
17
- {
18
- if (!$this->getTemplate()) {
19
- $this->setTemplate('wordpress/post/view/comment/wrapper.phtml');
20
- }
21
-
22
- if ($this->getCommentCount() > 0 && ($commentsBlock = $this->getChild('comment_list')) !== false) {
23
- $commentsBlock->setComments($this->getComments());
24
- }
25
-
26
- if ($this->getCommentCount() > 0 && ($pagerBlock = $this->getChild('pager')) !== false) {
27
- $pagerBlock->setCollection($this->getComments());
28
- }
29
-
30
- if (($form = $this->getChild('form')) !== false) {
31
- $form->setPost($this->getPost());
32
- }
33
-
34
- parent::_beforeToHtml();
35
- }
36
-
37
- /**
38
- * Get the comments HTML
39
- *
40
- * @return string
41
- */
42
- public function getCommentsHtml()
43
- {
44
- return $this->getChildHtml('comment_list');
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Post/View/Comments.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Post_View_Comments extends Fishpig_Wordpress_Block_Post_View_Comment_Abstract
10
- {
11
- /**
12
- * Setup the pager and comments form blocks
13
- *
14
- */
15
- protected function _beforeToHtml()
16
- {
17
- if (!$this->getTemplate()) {
18
- $this->setTemplate('wordpress/post/view/comments.phtml');
19
- }
20
-
21
- if ($this->getCommentCount() > 0 && ($pagerBlock = $this->getChild('pager')) !== false) {
22
- $pagerBlock->setCollection($this->getComments());
23
- }
24
-
25
- if (($form = $this->getChild('form')) !== false) {
26
- $form->setPost($this->getPost());
27
- }
28
-
29
- parent::_beforeToHtml();
30
- }
31
-
32
- /**
33
- * Get the HTML of the child comments
34
- *
35
- * @param Fishpig_Wordpress_Model_Post_Comment $comment
36
- * @return string
37
- */
38
- public function getChildrenCommentsHtml(Fishpig_Wordpress_Model_Post_Comment $comment)
39
- {
40
- return $this->getLayout()
41
- ->createBlock('wordpress/post_view_comments')
42
- ->setTemplate($this->getTemplate())
43
- ->setParentId($comment->getId())
44
- ->setComments($comment->getChildrenComments())
45
- ->toHtml();
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Search/Result.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Search_Result extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Generates and returns the collection of posts
13
- *
14
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
15
- */
16
- protected function _getPostCollection()
17
- {
18
- if (is_null($this->_postCollection)) {
19
- $this->_postCollection = parent::_getPostCollection()
20
- ->addSearchStringFilter($this->_getParsedSearchString(), array('post_title', 'post_content'));
21
-
22
- if ($postTypes = $this->getRequest()->getParam('post_type')) {
23
- $this->_postCollection->addPostTypeFilter($postTypes);
24
- }
25
- else {
26
- $this->_postCollection->addPostTypeFilter(array('post', 'page'));
27
- }
28
- }
29
-
30
- return $this->_postCollection;
31
- }
32
-
33
- /**
34
- * Retrieve a parsed version of the search string
35
- * If search by single word, string will be split on each space
36
- *
37
- * @return array
38
- */
39
- protected function _getParsedSearchString()
40
- {
41
- $words = explode(' ', $this->getSearchTerm());
42
-
43
- if (count($words) > 15) {
44
- $words = array_slice($words, 0, $maxWords);
45
- }
46
-
47
- foreach($words as $it => $word) {
48
- if (strlen($word) < 3) {
49
- unset($words[$it]);
50
- }
51
- }
52
-
53
- return $words;
54
- }
55
-
56
- /**
57
- * Retrieve the current search term
58
- *
59
- * @param bool $escape = false
60
- * @return string
61
- */
62
- public function getSearchTerm($escape = false)
63
- {
64
- return urldecode($this->helper('wordpress/router')->getSearchTerm($escape, $this->getSearchVar()));
65
- }
66
-
67
- /**
68
- * Retrieve the search variable
69
- *
70
- * @return string
71
- */
72
- public function getSearchVar()
73
- {
74
- return $this->_getData('search_var')
75
- ? $this->_getData('search_var')
76
- : 's';
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Shortcode/Product.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Shortcode_Product extends Mage_Catalog_Block_Product_Abstract
10
- {
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Allow dynamic sidebar/column placement
13
- *
14
- * @var array
15
- */
16
- static $_lockedWidgetAreas = array();
17
-
18
- /**
19
- * Stores all templates for each widget block
20
- *
21
- * @var array
22
- */
23
- protected $_widgets = array();
24
-
25
- /**
26
- * Add a widget type
27
- *
28
- * @param string $name
29
- * @param string $block
30
- * @param string $template
31
- * @return Fishpig_Wordpress_Block_Sidebar
32
- */
33
- public function addWidgetType($name, $block, $template = null)
34
- {
35
- if (!isset($this->_widgets[$name])) {
36
- $this->_widgets[$name] = array(
37
- 'block' => strpos($block, '/') !== false ? $block : 'wordpress/' . $block,
38
- 'template' => $template
39
- );
40
- }
41
-
42
- return $this;
43
- }
44
-
45
- /**
46
- * Retrieve information about a widget type
47
- *
48
- * @param string $name
49
- * @return false|array
50
- */
51
- public function getWidgetType($name)
52
- {
53
- return isset($this->_widgets[$name]) ? $this->_widgets[$name] : false;
54
- }
55
-
56
- /**
57
- * Load all enabled widgets
58
- *
59
- * @return Fishpig_Wordpress_Block_Sidebar
60
- */
61
- protected function _beforeToHtml()
62
- {
63
- if (isset(self::$_lockedWidgetAreas[$this->getWidgetArea()])) {
64
- return $this;
65
- }
66
-
67
- self::$_lockedWidgetAreas[$this->getWidgetArea()] = true;
68
-
69
-
70
- if ($widgets = $this->getWidgetsArray()) {
71
- $this->_initAvailableWidgets();
72
-
73
- foreach($widgets as $widgetType) {
74
- $name = $this->_getWidgetName($widgetType);
75
- $widgetIndex = $this->_getWidgetIndex($widgetType);
76
-
77
- if ($widget = $this->getWidgetType($name)) {
78
- if ($block = $this->getLayout()->createBlock($widget['block'])) {
79
- if (isset($widget['template']) && !empty($widget['template'])) {
80
- $block->setTemplate($widget['template']);
81
- }
82
-
83
- $block->setWidgetType($name);
84
- $block->setWidgetIndex($widgetIndex);
85
-
86
- $this->setChild('wordpress_widget_' . $widgetType, $block);
87
- }
88
- }
89
- }
90
- }
91
-
92
- if (!$this->getTemplate()) {
93
- $this->setTemplate('wordpress/sidebar.phtml');
94
- }
95
-
96
- return parent::_beforeToHtml();
97
- }
98
-
99
- /**
100
- * Retrieve the widget name
101
- * Strip the trailing number and hyphen
102
- *
103
- * @param string $widget
104
- * @return string
105
- */
106
- protected function _getWidgetName($widget)
107
- {
108
- return rtrim(preg_replace("/[^a-z_-]/i", '', $widget), '-');
109
- }
110
-
111
- /**
112
- * Retrieve the widget name
113
- * Strip the trailing number and hyphen
114
- *
115
- * @param string $widget
116
- * @return string
117
- */
118
- protected function _getWidgetIndex($widget)
119
- {
120
- if (preg_match("/([0-9]{1,})/",$widget, $results)) {
121
- return $results[1];
122
- }
123
-
124
- return false;
125
- }
126
-
127
- /**
128
- * Retrieve the sidebar widgets as an array
129
- *
130
- * @return false|array
131
- */
132
- public function getWidgetsArray()
133
- {
134
- if ($this->getWidgetArea()) {
135
- $widgets = $this->helper('wordpress')->getWpOption('sidebars_widgets');
136
-
137
- if ($widgets) {
138
- $widgets = unserialize($widgets);
139
-
140
- $realWidgetArea = $this->getRealWidgetArea();
141
-
142
- if (isset($widgets[$realWidgetArea])) {
143
- return $widgets[$realWidgetArea];
144
- }
145
- }
146
- }
147
-
148
- return false;
149
- }
150
-
151
- /**
152
- * Get the real widget area by using the Custom Sidebars plugin
153
- *
154
- * @return string
155
- */
156
- public function getRealWidgetArea()
157
- {
158
- if (!Mage::helper('wordpress')->isPluginEnabled('custom-sidebars/customsidebars.php')) {
159
- return $this->getWidgetArea();
160
- }
161
-
162
- $settings = @unserialize(Mage::helper('wordpress')->getWpOption('cs_modifiable'));
163
-
164
- if (!$settings) {
165
- return $this->getWidgetArea();
166
- }
167
-
168
- $handles = $this->getLayout()->getUpdate()->getHandles();
169
-
170
- if (!isset($settings['modifiable']) || array_search($this->getWidgetArea(), $settings['modifiable']) === false) {
171
- return $this->getWidgetArea();
172
- }
173
-
174
- if ($post = Mage::registry('wordpress_post')) {
175
- # Check post specific
176
- if ($value = $post->getMetaValue('_cs_replacements')) {
177
- $value = @unserialize($value);
178
-
179
- if (isset($value[$this->getWidgetArea()])) {
180
- return $value[$this->getWidgetArea()];
181
- }
182
- }
183
-
184
- # Single post by type
185
- if ($widgetArea = $this->_getArrayValue($settings, 'post_type_single/' . $post->getPostType() . '/' . $this->getWidgetArea())) {
186
- return $widgetArea;
187
- }
188
-
189
- # Single post by category
190
- if ($categoryIdResults = $post->getResource()->getParentTermsByPostId($post->getId(), $taxonomy = 'category')) {
191
- $categoryIdResults = array_pop($categoryIdResults);
192
-
193
- if (isset($categoryIdResults['category_ids'])) {
194
- foreach(explode(',', $categoryIdResults['category_ids']) as $categoryId) {
195
- if ($widgetArea = $this->_getArrayValue($settings, 'category_single/' . $categoryId . '/' . $this->getWidgetArea())) {
196
- return $widgetArea;
197
- }
198
- }
199
- }
200
- }
201
- }
202
- else if ($postType = Mage::registry('wordpress_post_type')) {
203
- if (isset($settings['post_type_archive']) && isset($settings['post_type_archive'][$postType->getPostType()]) && isset($settings['post_type_archive'][$postType->getPostType()][$this->getWidgetArea()])) {
204
- return $settings['post_type_archive'][$postType->getPostType()][$this->getWidgetArea()];
205
- }
206
- }
207
- else if ($term = Mage::registry('wordpress_term')) {
208
- if ($widgetArea = $this->_getArrayValue($settings, $term->getTaxonomy() . '_archive/' . $term->getId() . '/' . $this->getWidgetArea())) {
209
- return $widgetArea;
210
- }
211
- }
212
- else if (in_array('wordpress_homepage', $handles)) {
213
- if ($widgetArea = $this->_getArrayValue($settings, 'blog/' . $this->getWidgetArea())) {
214
- return $widgetArea;
215
- }
216
- }
217
- else if ($author = Mage::registry('wordpress_author')) {
218
- if ($widgetArea = $this->_getArrayValue($settings, 'authors/' . $author->getId() . '/' . $this->getWidgetArea())) {
219
- return $widgetArea;
220
- }
221
- }
222
- else if (in_array('wordpress_search_index', $handles)) {
223
- if ($widgetArea = $this->_getArrayValue($settings, 'search/' . $this->getWidgetArea())) {
224
- return $widgetArea;
225
- }
226
- }
227
- else if (in_array('wordpress_archive_view', $handles)) {
228
- if ($widgetArea = $this->_getArrayValue($settings, 'date/' . $this->getWidgetArea())) {
229
- return $widgetArea;
230
- }
231
- }
232
- else if (in_array('wordpress_post_tag_view', $handles)) {
233
- if ($widgetArea = $this->_getArrayValue($settings, 'tags/' . $this->getWidgetArea())) {
234
- return $widgetArea;
235
- }
236
- }
237
-
238
- return $this->getWidgetArea();
239
- }
240
-
241
- /**
242
- * Retrieve a deep value from a multideimensional array
243
- *
244
- * @param array $arr
245
- * @param string $key
246
- * @return string|null
247
- */
248
- protected function _getArrayValue($arr, $key)
249
- {
250
- $keys = explode('/', trim($key, '/'));
251
-
252
- foreach($keys as $key) {
253
- if (!isset($arr[$key])) {
254
- return null;
255
- }
256
-
257
- $arr = $arr[$key];
258
- }
259
-
260
- return $arr;
261
- }
262
-
263
- /**
264
- * Initialize the widgets from the config.xml
265
- *
266
- * @return $this
267
- */
268
- protected function _initAvailableWidgets()
269
- {
270
- $availableWidgets = (array)Mage::app()->getConfig()->getNode()->wordpress->sidebar->widgets;
271
-
272
- foreach($availableWidgets as $name => $widget) {
273
- $widget = (array)$widget;
274
-
275
- $this->addWidgetType($name, $widget['block'], isset($widget['template']) ? $widget['template'] : null);
276
- }
277
-
278
- return $this;
279
- }
280
-
281
- /**
282
- * Determine whether or not to display the sidebar
283
- *
284
- * @return int
285
- */
286
- public function canDisplay()
287
- {
288
- return 1;
289
- }
290
-
291
- /**
292
- * Set the widget area.
293
- * This allows for support for Simple Page Sidebars
294
- *
295
- * @param string $widgetArea
296
- * @return $this
297
- */
298
- public function setWidgetArea($widgetArea)
299
- {
300
- if ($this->hasWidgetArea()) {
301
- return $this;
302
- }
303
-
304
- $this->setData('widget_area', $widgetArea);
305
-
306
- $widgetArea = null;
307
-
308
- # Deprecated. Use Custom Sidebars plugin instead
309
- if ($post = Mage::registry('wordpress_post')) {
310
- $widgetArea = $post->getMetaValue('_sidebar_name');
311
- }
312
- else if ($page = Mage::registry('wordpress_page')) {
313
- $widgetArea = $page->getMetaValue('_sidebar_name');
314
- }
315
-
316
- if (!$widgetArea) {
317
- return $this;
318
- }
319
-
320
- $widgetArea = 'page-sidebar-' . preg_replace('/([^a-z0-9_-]{1,})/', '', strtolower(trim($widgetArea)));
321
-
322
- return $this->setData('widget_area', $widgetArea);
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Abstract.php DELETED
@@ -1,225 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Sidebar_Widget_Abstract extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * Retrieve the default title for the block
13
- *
14
- * @return string
15
- */
16
- abstract public function getDefaultTitle();
17
-
18
- /**
19
- * Flag used to determine whether to fix option keys
20
- *
21
- * @var bool
22
- */
23
- protected $_fixOptionKeys = false;
24
-
25
- /**
26
- * Retrieve the default title
27
- *
28
- * @return string
29
- */
30
- public function getTitle()
31
- {
32
- if (($title = $this->_getData('title')) !== false) {
33
- return $title ? $title : $this->getDefaultTitle();
34
- }
35
-
36
- return false;
37
- }
38
-
39
- /**
40
- * Attempt to load the widget information from the WordPress options table
41
- *
42
- * @return Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
43
- */
44
- protected function _beforeToHtml()
45
- {
46
- if ($this->getWidgetType()) {
47
- $data = $this->helper('wordpress')->getWpOption('widget_' . $this->getWidgetType());
48
-
49
- if ($data) {
50
- $data = unserialize($data);
51
-
52
- if (isset($data[$this->getWidgetIndex()])) {
53
- foreach($data[$this->getWidgetIndex()] as $field => $value) {
54
-
55
- if ($this->_fixOptionKeys) {
56
- $field = preg_replace('/([A-Z]{1})([A-Z]{1,})/e', "'$1' . strtolower('$2');", $field);
57
- $field = preg_replace('/([A-Z]{1})/e', "'_' . strtolower('$1');", $field);
58
- }
59
-
60
- $this->setData($field, $value);
61
- }
62
- }
63
- }
64
- }
65
-
66
- return parent::_beforeToHtml();
67
- }
68
-
69
- /**
70
- * Set some default values
71
- *
72
- * @param array $defaults
73
- * @return $this
74
- */
75
- protected function _setDataDefaults(array $defaults)
76
- {
77
- foreach($defaults as $key => $value) {
78
- if (!$this->hasData($key)) {
79
- $this->setData($key, $value);
80
- }
81
- }
82
-
83
- return $this;
84
- }
85
-
86
- /**
87
- * Convert data values to something else
88
- *
89
- * @param array $values
90
- * @return $this
91
- */
92
- protected function _convertDataValues(array $values)
93
- {
94
- foreach($this->getData() as $key => $value) {
95
- foreach($values as $find => $replace) {
96
- if ($value === $find) {
97
- $this->setData($key, $replace);
98
- continue;
99
- }
100
- }
101
- }
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * Retrieve the current page URL
108
- *
109
- * @return string
110
- */
111
- public function _getPageUrl()
112
- {
113
- if (!$this->hasData('_page_url')) {
114
- $url = $this->helper('core/url')->getCurrentUrl();
115
-
116
- if (strpos($url, '?') !== false) {
117
- $url = substr($url, 0, strpos($url, '?'));
118
- }
119
-
120
- $this->setData('_page_url', $url);
121
- }
122
-
123
- return $this->_getData('_page_url');
124
- }
125
-
126
-
127
- /**
128
- * Retrieve the current page title
129
- *
130
- * @return string
131
- */
132
- protected function _getPageTitle()
133
- {
134
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
135
- return $headBlock->getTitle();
136
- }
137
-
138
- return $this->_getWpOption('name');
139
- }
140
-
141
- /**
142
- * Retrieve the meta description for the page
143
- *
144
- * @return string
145
- */
146
- protected function _getPageDescription()
147
- {
148
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
149
- return $headBlock->getDescription();
150
- }
151
- }
152
-
153
- /**
154
- * Retrieve an ID to be used for the list
155
- *
156
- * @return string
157
- */
158
- public function getListId()
159
- {
160
- if (!$this->hasListId()) {
161
- $hash = 'wp-' . md5(rand(1111, 9999) . $this->getTitle() . $this->getWidgetType());
162
-
163
- $this->setListId(substr($hash, 0, 6));
164
- }
165
-
166
- return $this->_getData('list_id');
167
- }
168
-
169
- /**
170
- * Save custom data to the cache
171
- *
172
- * @param string $data
173
- * @param string $cacheKey
174
- * @return $this
175
- */
176
- protected function _saveCustomDataToCache($data, $cacheKey)
177
- {
178
- $cacheKey .= $this->getCacheKey();
179
-
180
- Mage::app()->saveCache($data, $cacheKey, $this->getCacheTags(), $this->getCacheLifetime());
181
-
182
- return $this;
183
- }
184
-
185
- /**
186
- * Retrieve the custom data from the cache
187
- *
188
- * @param string $cacheKey
189
- * @return string
190
- */
191
- protected function _loadCustomDataFromCache($cacheKey)
192
- {
193
- $cacheData = Mage::app()->loadCache($cacheKey . $this->getCacheKey());
194
-
195
- if (trim($cacheData) !== '') {
196
- return $cacheData;
197
- }
198
-
199
- return false;
200
- }
201
-
202
- /**
203
- * Convert a SimpleXMLElement object to an array
204
- *
205
- * @param SimpleXMLElement $xml
206
- * @param array $out
207
- * @return array]
208
- */
209
- protected function _convertXmlToArray($xml, $out = array())
210
- {
211
- foreach((array)$xml as $index => $node) {
212
- if (is_object($node)) {
213
- $out[$index] = $this->_convertXmlToArray($node);
214
- }
215
- else if (is_array($node)) {
216
- $out[$index] = $this->_convertXmlToArray($node);
217
- }
218
- else {
219
- $out[$index] = $node;
220
- }
221
- }
222
-
223
- return $out;
224
- }
225
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Archives.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Archives extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Cache for archive collection
13
- *
14
- * @var null|Varien_Data_Collection
15
- */
16
- protected $_archiveCollection = null;
17
-
18
- /**
19
- * Returns a collection of valid archive dates
20
- *
21
- * @return Varien_Data_Collection
22
- */
23
- public function getArchives()
24
- {
25
- if (is_null($this->_archiveCollection)) {
26
- $table = Mage::helper('wordpress/app')->getTableName('posts');
27
- $sql = "SELECT COUNT(ID) AS post_count, CONCAT(SUBSTRING(post_date, 1, 4), '/', SUBSTRING(post_date, 6, 2)) as archive_date
28
- FROM `" . $table . "` AS `main_table` WHERE (`main_table`.`post_type`='post') AND (`main_table`.`post_status` ='publish')
29
- GROUP BY archive_date ORDER BY archive_date DESC";
30
-
31
- $dates = Mage::helper('wordpress/app')->getDbConnection()->fetchAll($sql);
32
- $collection = new Varien_Data_Collection();
33
-
34
- foreach($dates as $date) {
35
- $obj = Mage::getModel('wordpress/archive')->load($date['archive_date']);
36
- $obj->setPostCount($date['post_count']);
37
- $collection->addItem($obj);
38
- }
39
-
40
- $this->_archiveCollection = $collection;
41
- }
42
-
43
- return $this->_archiveCollection;
44
- }
45
-
46
- /**
47
- * Split a date by spaces and translate
48
- *
49
- * @param string $date
50
- * @param string $splitter = ' '
51
- * @return string
52
- */
53
- public function translateDate($date, $splitter = ' ')
54
- {
55
- $dates = explode($splitter, $date);
56
-
57
- foreach($dates as $it => $part) {
58
- $dates[$it] = $this->__($part);
59
- }
60
-
61
- return implode($splitter, $dates);
62
- }
63
-
64
- /**
65
- * Determine whether the archive is the current archive
66
- *
67
- * @param Fishpig_Wordpress_Model_Archive $archive
68
- * @return bool
69
- */
70
- public function isCurrentArchive($archive)
71
- {
72
- if ($this->getCurrentArchive()) {
73
- return $archive->getId() == $this->getCurrentArchive()->getId();
74
- }
75
-
76
-
77
- return false;
78
- }
79
-
80
- /**
81
- * Retrieve the current archive
82
- *
83
- * @return Fishpig_Wordpress_Model_Archive
84
- */
85
- public function getCurrentArchive()
86
- {
87
- if (!$this->hasCurrentArchive()) {
88
- $this->setCurrentArchive(Mage::registry('wordpress_archive'));
89
- }
90
-
91
- return $this->getData('current_archive');
92
- }
93
-
94
- /**
95
- * Retrieve the default title
96
- *
97
- * @return string
98
- */
99
- public function getDefaultTitle()
100
- {
101
- return $this->__('Archives');
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Calendar.php DELETED
@@ -1,174 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Calendar extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve the default title
13
- *
14
- * @return null
15
- */
16
- public function getDefaultTitle()
17
- {
18
- return $this->_getData('default_title');
19
- }
20
-
21
- /**
22
- * Retrieve an array of date items separated into rows
23
- *
24
- * @return array
25
- */
26
- public function getDateItems()
27
- {
28
- if (!$this->hasDateItems()) {
29
- $this->setDateItems(
30
- $this->_getPostDateDataAsArray()
31
- );
32
- }
33
-
34
- return $this->_getData('date_items');
35
- }
36
-
37
- /**
38
- * Get the post date data as an array
39
- *
40
- * @return array
41
- */
42
- protected function _getPostDateDataAsArray()
43
- {
44
- $posts = Mage::getResourceModel('wordpress/post_collection')
45
- ->addPostDateFilter($this->getYear() . '-' . $this->getMonth() . '-%')
46
- ->addIsViewableFilter();
47
-
48
- $posts->getSelect()
49
- ->distinct()
50
- ->setPart('columns', array())
51
- ->columns(array('posts_on_day' => 'SUBSTR(main_table.post_date, 9, 2)'))
52
- ->where('main_table.post_type=?', 'post');
53
-
54
- $days = Mage::helper('wordpress/app')->getDbConnection()->fetchCol($posts->getSelect());
55
-
56
- $itemsByDay = array_combine(range(1, $this->getDaysInMonth()), range(1, $this->getDaysInMonth()));
57
-
58
- foreach($days as $day) {
59
- $itemsByDay[ltrim($day, '0')] = sprintf('<a href="%s">%s</a>', Mage::helper('wordpress')->getUrl($this->getYear() . '/' . $this->getMonth() . '/' . $day), $day);
60
- }
61
-
62
- $itemsByDay = array_values($itemsByDay);
63
-
64
- // Pad start of array
65
- $firstDayOfMonth = date('N', strtotime($this->getYear() . '-' . $this->getMonth() . '-01'));
66
- $itemsByDay = array_pad($itemsByDay, -(count($itemsByDay)+($firstDayOfMonth-1)) , null);
67
-
68
- // Pad end of array
69
- $lastDayOfMonth = date('t', strtotime($this->getYear() . '-' . $this->getMonth() . '-01'));
70
- $endOfMonthPadding = 7 - date('N', strtotime($this->getYear() . '-' . $this->getMonth() . '-' . $lastDayOfMonth));
71
- $itemsByDay = array_pad($itemsByDay, count($itemsByDay)+$endOfMonthPadding , null);
72
-
73
- $items = array();
74
-
75
- while(count($itemsByDay) > 0) {
76
- if (count($itemsByDay) >= 7) {
77
- $items[] = array_splice($itemsByDay, 0, 7, null);
78
- }
79
- else {
80
- $items[] = $itemsByDay;
81
- $itemsByDay = array();
82
- }
83
- }
84
-
85
- return $items;
86
- }
87
-
88
- /**
89
- * Set the posts collection
90
- *
91
- */
92
- protected function _beforeToHtml()
93
- {
94
- parent::_beforeToHtml();
95
-
96
- $this->_initDate();
97
- $this->_initPreviousNextLinks();
98
-
99
- if (!$this->getTemplate()) {
100
- $this->setTemplate('wordpress/sidebar/widget/calendar.phtml');
101
- }
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * Initialise the date block's date
108
- * If no archive, use current date
109
- *
110
- * @return $this
111
- */
112
- protected function _initDate()
113
- {
114
- if (($archive =Mage::registry('wordpress_archive')) !== null) {
115
- $this->setYear($archive->getDatePart('Y'));
116
- $this->setMonth($archive->getDatePart('m'));
117
- $this->setDaysInMonth($archive->getDatePart('t'));
118
-
119
- $this->setDefaultTitle($archive->getDatePart('F, Y'));
120
-
121
- return $this;
122
- }
123
-
124
- $this->setYear(date('Y'));
125
- $this->setMonth(date('m'));
126
- $this->setDaysInMonth(date('t'));
127
-
128
- $this->setDefaultTitle(Mage::helper('wordpress')->formatDate(date('Y-m-d 00:00:00', time()), 'F Y'));
129
-
130
- return $this;
131
- }
132
-
133
- /**
134
- * Setup the previous and next links (if available)
135
- *
136
- * @return $this
137
- */
138
- protected function _initPreviousNextLinks()
139
- {
140
- $posts = Mage::getResourceModel('wordpress/post_collection')
141
- ->addIsViewableFilter()
142
- ->setOrderByPostDate('desc')
143
- ->addFieldToFilter('post_date', array('lteq' => $this->getYear() . '-' . $this->getMonth() . '-01 00:00:00'))
144
- ->setPageSize(1)
145
- ->setCurPage(1)
146
- ->load();
147
-
148
- if (count($posts)) {
149
- $previous = $posts->getFirstItem();
150
-
151
- $this->setPreviousUrl(Mage::helper('wordpress')->getUrl($previous->getPostDate('Y') . '/' . $previous->getPostDate('m') . '/'));
152
- $this->setPreviousText($previous->getPostDate('M'));
153
- }
154
-
155
- $dateString = date('Y-m-d', strtotime('+1 month', strtotime($this->getYear() . '-' . $this->getMonth() . '-01')));
156
-
157
- $posts = Mage::getResourceModel('wordpress/post_collection')
158
- ->addIsViewableFilter()
159
- ->setOrderByPostDate('asc')
160
- ->addFieldToFilter('post_date', array('gteq' => $dateString))
161
- ->setPageSize(1)
162
- ->setCurPage(1)
163
- ->load();
164
-
165
- if (count($posts)) {
166
- $next = $posts->getFirstItem();
167
-
168
- $this->setNextUrl(Mage::helper('wordpress')->getUrl($next->getPostDate('Y') . '/' . $next->getPostDate('m') . '/'));
169
- $this->setNextText($next->getPostDate('M'));
170
- }
171
-
172
- return $this;
173
- }
174
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Categories.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Categories extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Returns the current category collection
13
- *
14
- * @return Fishpig_Wordpress_Model_Resource_Term_Collection
15
- */
16
- public function getCategories()
17
- {
18
- $collection = Mage::getResourceModel('wordpress/term_collection')
19
- ->addTaxonomyFilter($this->getTaxonomy())
20
- ->addParentIdFilter($this->getParentId())
21
- ->addHasObjectsFilter();
22
-
23
- $collection->getSelect()
24
- ->reset('order')
25
- ->order('name ASC');
26
-
27
- return $collection;
28
- }
29
-
30
- public function getTaxonomy()
31
- {
32
- return $this->_getData('taxonomy')
33
- ? $this->_getData('taxonomy')
34
- : 'category';
35
- }
36
-
37
- /**
38
- * Returns the parent ID used to display categories
39
- * If parent_id is not set, 0 will be returned and root categories displayed
40
- *
41
- * @return int
42
- */
43
- public function getParentId()
44
- {
45
- return number_format($this->getData('parent_id'), 0, '', '');
46
- }
47
-
48
- /**
49
- * Determine whether the category is the current category
50
- *
51
- * @param Fishpig_Wordpress_Model_Category $category
52
- * @return bool
53
- */
54
- public function isCurrentCategory($category)
55
- {
56
- if ($this->getCurrentCategory()) {
57
- return $category->getId() == $this->getCurrentCategory()->getId();
58
- }
59
-
60
- return false;
61
- }
62
-
63
- /**
64
- * Retrieve the current category
65
- *
66
- * @return Fishpig_Wordpress_Model_Category
67
- */
68
- public function getCurrentCategory()
69
- {
70
- if (!$this->hasCurrentCategory()) {
71
- $this->setCurrentCategory(Mage::registry('wordpress_term'));
72
- }
73
-
74
- return $this->getData('current_category');
75
- }
76
-
77
- /**
78
- * Retrieve the default title
79
- *
80
- * @return string
81
- */
82
- public function getDefaultTitle()
83
- {
84
- return $this->__('Categories');
85
- }
86
-
87
- /**
88
- * Set the posts collection
89
- *
90
- */
91
- protected function _beforeToHtml()
92
- {
93
- if (!$this->getTemplate()) {
94
- $this->setTemplate('wordpress/sidebar/widget/categories.phtml');
95
- }
96
-
97
- return parent::_beforeToHtml();
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Comments.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Comments extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve the recent comments collection
13
- *
14
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Comment_Collection
15
- */
16
- public function getComments()
17
- {
18
- if (!$this->hasComments()) {
19
- $comments = Mage::getResourceModel('wordpress/post_comment_collection')
20
- ->addCommentApprovedFilter()
21
- ->addOrderByDate('desc');
22
-
23
- $comments->getSelect()->limit($this->getNumber() ? $this->getNumber() : 5 );
24
-
25
- $this->setComments($comments);
26
- }
27
-
28
- return $this->getData('comments');
29
- }
30
-
31
- /**
32
- * Retrieve the default title
33
- *
34
- * @return string
35
- */
36
- public function getDefaultTitle()
37
- {
38
- return $this->__('Recent Comments');
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Image.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Image extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Set the posts collection
13
- *
14
- */
15
- protected function _beforeToHtml()
16
- {
17
- parent::_beforeToHtml();
18
-
19
- if (!$this->getTemplate()) {
20
- $this->setTemplate('wordpress/sidebar/widget/image.phtml');
21
- }
22
-
23
- return $this;
24
- }
25
-
26
- public function getImage()
27
- {
28
- $this->setImage(false);
29
-
30
- if ($this->getAttachmentId()) {
31
- $image = Mage::getModel('wordpress/image')->load($this->getAttachmentId());
32
-
33
- if ($image->getId()) {
34
- $this->setImage($image);
35
- }
36
- }
37
-
38
- return $this->_getData('image');
39
- }
40
-
41
- public function getImageUrl()
42
- {
43
- if ($image = $this->getImage()) {
44
- if ($imageUrl = $image->getImageByType($this->getSize())) {
45
- return $imageUrl;
46
- }
47
-
48
- return $image->getFullSizeImage();
49
- }
50
-
51
- return false;
52
- }
53
-
54
- public function getLink()
55
- {
56
- return ($link = $this->_getData('link'))
57
- ? $link
58
- : '#';
59
- }
60
-
61
- public function getDefaultTitle()
62
- {
63
- return null;
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Links.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Links extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve the default title
13
- *
14
- * @return string
15
- */
16
- public function getDefaultTitle()
17
- {
18
- return $this->__('Links');
19
- }
20
-
21
- /**
22
- * Retrieve a collection of links
23
- *
24
- * @return Fishpig_Wordpress_Model_Mysql4_Link_Collection
25
- */
26
- public function getLinks()
27
- {
28
- if (!$this->hasLinks()) {
29
- if ($this->getLinkCategory()) {
30
- $links = $this->getLinkCategory()->getLinks();
31
- }
32
- else {
33
- $links = Mage::getResourceModel('wordpress/link_collection');
34
- }
35
-
36
- $this->setLinks($links);
37
- }
38
-
39
- return $this->_getData('links');
40
-
41
- }
42
-
43
- /**
44
- * Retrieve the link category
45
- *
46
- * @return Fishpig_Wordpress_Model_Link_Category
47
- */
48
- public function getLinkCategory()
49
- {
50
- if (!$this->hasLinkCategory() && $this->_getData('category')) {
51
- $this->setLinkCategory(false);
52
-
53
- $category = Mage::getModel('wordpress/link_category')->load($this->_getData('category'));
54
-
55
- if ($category->getId()) {
56
- $this->setLinkCategory($category);
57
- }
58
- }
59
-
60
- return $this->_getData('link_category');
61
- }
62
-
63
- /**
64
- * Determine whether to display the link description
65
- *
66
- * @return bool
67
- */
68
- public function displayLinkDescription()
69
- {
70
- return $this->_getData('description') == 1;
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Menu.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Menu extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Generate the Menu HTML
13
- *
14
- * @return $this
15
- */
16
- protected function _beforeToHtml()
17
- {
18
- parent::_beforeToHtml();
19
-
20
- $menuBlock = $this->getLayout()->createBlock('wordpress/menu')
21
- ->setMenuId($this->getNavMenu())
22
- ->includeWrapper(true);
23
-
24
- $this->setMenuBlock($menuBlock)
25
- ->setMenuHtml($menuBlock->toHtml())
26
- ->setTitle($menuBlock->getTitle());
27
-
28
- return $this;
29
- }
30
-
31
- /**
32
- * Retrieve the default title
33
- *
34
- * @return string
35
- */
36
- public function getDefaultTitle()
37
- {
38
- return '';
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Meta.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Meta extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve the default title
13
- *
14
- * @return string
15
- */
16
- public function getDefaultTitle()
17
- {
18
- return $this->__('Meta');
19
- }
20
-
21
- /**
22
- * Determine whether the current customer is logged in
23
- *
24
- * @return bool
25
- */
26
- public function customerIsLoggedIn()
27
- {
28
- return Mage::getSingleton('customer/session')->isLoggedIn();
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Pages.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Pages extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Returns the currently loaded page model
13
- *
14
- * @return Fishpig_Wordpress_Model_Page
15
- */
16
- public function getPost()
17
- {
18
- if (!$this->hasPost()) {
19
- $this->setPost(false);
20
-
21
- if ($post = Mage::registry('wordpress_post')) {
22
- if ($post->getPostType() === 'page') {
23
- $this->setPost($post);
24
- }
25
- }
26
- }
27
-
28
- return $this->_getData('post');
29
- }
30
-
31
- /**
32
- * Retrieve a collection of pages
33
- *
34
- * @return Fishpig_Wordpress_Model_Mysql4_Page_Collection
35
- */
36
- public function getPages()
37
- {
38
- return $this->getPosts();
39
- }
40
-
41
- public function getPosts()
42
- {
43
- $posts = Mage::getResourceModel('wordpress/post_collection')
44
- ->addPostTypeFilter('page');
45
-
46
- if ($this->hasParentId()) {
47
- $posts->addPostParentIdFilter($this->getParentId());
48
- }
49
- else if ($this->getPost() && $this->getPost()->hasChildren()) {
50
- $posts->addPostParentIdFilter($this->getPost()->getId());
51
- }
52
- else {
53
- $posts->addPostParentIdFilter(0);
54
- }
55
-
56
- return $posts->addIsViewableFilter()->load();
57
- }
58
-
59
- /**
60
- * Retrieve the block title
61
- *
62
- * @return string
63
- */
64
- public function getTitle()
65
- {
66
- if ($this->getPost() && $this->getPost()->hasChildren()) {
67
- return $this->getPost()->getPostTitle();
68
- }
69
-
70
- return parent::getTitle();
71
- }
72
-
73
- /**
74
- * Retrieve the default title
75
- *
76
- * @return string
77
- */
78
- public function getDefaultTitle()
79
- {
80
- return $this->__('Pages');
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Posts.php DELETED
@@ -1,247 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Posts extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- implements Mage_Widget_Block_Interface
11
- {
12
- /**
13
- * Cache for post collection
14
- *
15
- * @var Fishpig_Wordpress_Model_Resource_Post_Collection
16
- */
17
- protected $_collection = null;
18
-
19
- /**
20
- * Set the posts collection
21
- *
22
- */
23
- protected function _beforeToHtml()
24
- {
25
- parent::_beforeToHtml();
26
-
27
- $this->setPosts($this->_getPostCollection());
28
-
29
- if (!$this->getTemplate()) {
30
- $this->setTemplate('wordpress/sidebar/widget/posts.phtml');
31
- }
32
-
33
- return $this;
34
- }
35
-
36
- /**
37
- * Control the number of posts displayed
38
- *
39
- * @param int $count
40
- * @return $this
41
- */
42
- public function setPostCount($count)
43
- {
44
- return $this->setNumber($count);
45
- }
46
-
47
- /**
48
- * Retrieve the number of posts to display
49
- * If the pager is enabled, this is posts per page
50
- *
51
- * @return int
52
- */
53
- public function getNumber()
54
- {
55
- return $this->_getData('number') ? $this->_getData('number') : 5;
56
- }
57
-
58
- /**
59
- * Adds on cateogry/author ID filters
60
- *
61
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
62
- */
63
- protected function _getPostCollection()
64
- {
65
- if (is_null($this->_collection)) {
66
- $collection = Mage::getResourceModel('wordpress/post_collection')
67
- ->setOrderByPostDate()
68
- ->addIsViewableFilter()
69
- ->setPageSize($this->getNumber())
70
- ->setCurPage(1);
71
-
72
- if ($categoryId = $this->getCategoryId()) {
73
- if (strpos($categoryId, ',') !== false) {
74
- $categoryId = explode(',', trim($categoryId, ','));
75
- }
76
-
77
- $collection->addCategoryIdFilter($categoryId);
78
- }
79
-
80
- if ($authorId = $this->getAuthorId()) {
81
- $collection->addFieldToFilter('post_author', $authorId);
82
- }
83
-
84
- if ($tag = $this->getTag()) {
85
- $collection->addTermFilter($tag, 'post_tag', 'name');
86
- }
87
-
88
- if ($postTypes = $this->getPostType()) {
89
- $collection->addPostTypeFilter(explode(',', $postTypes));
90
- }
91
- else {
92
- $collection->addPostTypeFilter('post');
93
- }
94
-
95
- $this->_collection = $collection;
96
- }
97
-
98
- return $this->_collection;
99
- }
100
-
101
- /**
102
- * Retrieve the default title
103
- *
104
- * @return string
105
- */
106
- public function getDefaultTitle()
107
- {
108
- if ($this->getCategory()) {
109
- return $this->getCategory()->getName();
110
- }
111
-
112
- return $this->__('Recent Posts');
113
- }
114
-
115
- /**
116
- * Retrieve the category model used to filter the posts
117
- *
118
- * @return Fishpig_Wordpress_Model_Post_Category|false
119
- */
120
- public function getCategory()
121
- {
122
- if (!$this->hasCategory()) {
123
- $this->setCategory(false);
124
- if ($this->getCategoryId()) {
125
- $category = Mage::getModel('wordpress/term')->setTaxonomy('category')->load($this->getCategoryId());
126
-
127
- if ($category->getId()) {
128
- $this->setCategory($category)->setCategoryId($category->getId());
129
- }
130
- }
131
- }
132
-
133
- return $this->_getData('category');
134
- }
135
-
136
- /**
137
- * Retrieve the category ID
138
- *
139
- * return int|null
140
- */
141
- public function getCategoryId()
142
- {
143
- if ($categoryId = $this->_getData('category_id')) {
144
- return $categoryId;
145
- }
146
-
147
- return $this->_getData('cat');
148
- }
149
-
150
- /**
151
- * Retrieve the ID used for the list
152
- * This is necessary so multiple instances can be used
153
- *
154
- * @return string
155
- */
156
- public function getListId()
157
- {
158
- if (!$this->hasListId()) {
159
- $hash = 'wp-' . md5(rand(1111, 9999) . $this->getCategoryId() . $this->getAuthorId() . $this->getTitle());
160
-
161
- $this->setListId(substr($hash, 0, 6));
162
- }
163
-
164
- return $this->_getData('list_id');
165
- }
166
-
167
- /**
168
- * Added to support 'Category Posts Widget' WP plugin
169
- *
170
- */
171
- public function canDisplayCommentCount()
172
- {
173
- return $this->_getData('comment_num') == 'on';
174
- }
175
-
176
- /**
177
- * Determine whether we can display the date
178
- *
179
- * @return bool
180
- */
181
- public function canDisplayDate()
182
- {
183
- return $this->_getData('date') == 'on';
184
- }
185
-
186
- /**
187
- * Determine whether we can display the excerpt
188
- *
189
- * @return bool
190
- */
191
- public function canDisplayExcerpt()
192
- {
193
- return $this->getData('excerpt') == 'on';
194
- }
195
-
196
- /**
197
- * Determine whether we can display the image
198
- *
199
- * @return bool
200
- */
201
- public function canDisplayImage()
202
- {
203
- return $this->getData('thumb') === 'on';
204
- }
205
-
206
- /**
207
- * Determine whether we can display the title link
208
- *
209
- * @return bool
210
- */
211
- public function canDisplayTitleLink()
212
- {
213
- return $this->getData('title_link') == 'on';
214
- }
215
-
216
- /**
217
- * Retrieve the excerpt length
218
- *
219
- * @return null|int
220
- */
221
- public function getExcerptLength()
222
- {
223
- if ($this->canDisplayExcerpt()) {
224
- return $this->_getData('excerpt_length');
225
- }
226
-
227
- return null;
228
- }
229
-
230
- /**
231
- * Retrieve a string indicating the number of comments
232
- *
233
- * @param Fishpig_Wordpress_Model_Post $post
234
- * @return string
235
- */
236
- public function getCommentCountString(Fishpig_Wordpress_Model_Post $post)
237
- {
238
- if ($post->getCommentCount() == 0) {
239
- return $this->__('No Comments');
240
- }
241
- else if ($post->getCommentCount() > 1) {
242
- return $this->__('%s Comments', $post->getCommentCount());
243
- }
244
-
245
- return $this->__('1 Comment');
246
- }
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Rss.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Rss extends Fishpig_Wordpress_Block_Sidebar_Widget_Rss_Abstract
10
- {
11
- /**
12
- * Retrieve the default title
13
- *
14
- * @return string
15
- */
16
- public function getDefaultTitle()
17
- {
18
- if ($this->getFeed()) {
19
- return $this->getFeed()->getTitle();
20
- }
21
-
22
- return $this->__('RSS Feed');
23
- }
24
-
25
- public function getFeedUrl()
26
- {
27
- if (!$this->hasFeedUrl()) {
28
- $this->setFeedUrl(false);
29
-
30
- if (($url = trim($this->_getData('url'))) !== '') {
31
- $this->setFeedUrl($url);
32
- }
33
- }
34
-
35
- return $this->_getData('feed_url');
36
- }
37
-
38
- public function getMaxFeedItems()
39
- {
40
- return intval($this->_getData('items'));
41
- }
42
-
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Rss/Abstract.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Block_Sidebar_Widget_Rss_Abstract extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Must be declared in child class
13
- * Returns URL of feed or false
14
- *
15
- * @return false|string
16
- */
17
- abstract public function getFeedUrl();
18
-
19
- /**
20
- * Retrieve the RSS feed from the URL
21
- *
22
- * @return array
23
- */
24
- protected function _getRssFeed($url)
25
- {
26
- $cacheKey = md5(serialize($this->getData()) . $this->getMaxFeedItems() . $url);
27
-
28
- if (($data = $this->_loadCustomDataFromCache($cacheKey)) !== false) {
29
- return unserialize($data);
30
- }
31
-
32
- try {
33
- if ($feed = file_get_contents($url)) {
34
- $xml = new SimpleXmlElement($feed);
35
-
36
- $feed = new Varien_Object($this->_convertXmlToArray($xml->channel));
37
-
38
- $this->_saveCustomDataToCache(serialize($feed), $cacheKey);
39
-
40
- return $feed;
41
- }
42
- }
43
- catch (Exception $e) {
44
- $this->helper('wordpress')->log($e);
45
- }
46
-
47
- return false;
48
- }
49
-
50
- /**
51
- * Retrieve the max number of feed items
52
- *
53
- * @return int
54
- */
55
- public function getMaxFeedItems()
56
- {
57
- return 5;
58
- }
59
-
60
- /**
61
- * Prepare a feed item
62
- *
63
- * @param array $item
64
- * @return Varien_Object
65
- */
66
- protected function _prepareFeedItem(array $item)
67
- {
68
- return new Varien_Object($item);
69
- }
70
-
71
- /**
72
- * Load the RSS feed and items before the block is rendered
73
- *
74
- */
75
- protected function _beforeToHtml()
76
- {
77
- parent::_beforeToHtml();
78
-
79
- $this->setFeedReady(false);
80
-
81
- if ($this->getFeedUrl() !== false) {
82
- if (($feed = $this->_getRssFeed($this->getFeedUrl())) !== false) {
83
- $this->setFeedTitle($feed->getTitle());
84
- $this->setFeedLink($feed->getLink());
85
- $this->setFeedDescription($feed->getDescription());
86
-
87
- $buffer = $feed->getItem();
88
-
89
- if (count($buffer) > 0) {
90
- if (!isset($buffer[0]) && isset($buffer['title'])) {
91
- $buffer = array($buffer);
92
- }
93
-
94
- $items = array();
95
-
96
- foreach($buffer as $item) {
97
- if (($item = $this->_prepareFeedItem($item)) !== false) {
98
- $items[] = $item;
99
- $this->setFeedReady(true);
100
- }
101
- }
102
-
103
- if (count($items) > $this->getMaxFeedItems()) {
104
- $items = array_splice($items, 0, $this->getMaxFeedItems());
105
- }
106
-
107
- $this->setFeedItems($items);
108
- }
109
- }
110
- }
111
-
112
- return $this;
113
- }
114
- /**
115
- * Convert a SimpleXMLElement object to an array
116
- *
117
- * @param SimpleXMLElement $xml
118
- * @param array $out
119
- * @return array]
120
- */
121
- protected function _convertXmlToArray($xml, $out = array())
122
- {
123
- foreach((array)$xml as $index => $node) {
124
- if (is_object($node)) {
125
- $out[$index] = $this->_convertXmlToArray($node);
126
- }
127
- else if (is_array($node)) {
128
- $out[$index] = $this->_convertXmlToArray($node);
129
- }
130
- else {
131
- $out[$index] = $node;
132
- }
133
- }
134
-
135
- return $out;
136
- }
137
-
138
- /**
139
- * Retrieve the RSS items
140
- *
141
- * @deprecated 2.4.40
142
- * @return false|array
143
- */
144
- public function getRssItems()
145
- {
146
- if (($items = $this->getFeedItems()) !== false) {
147
- return $items;
148
- }
149
-
150
- return array();
151
- }
152
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Search.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Search extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve the action URL for the search form
13
- *
14
- * @return string
15
- */
16
- public function getFormActionUrl()
17
- {
18
- return $this->helper('wordpress')->getUrl(
19
- $this->helper('wordpress/router')->getSearchRoute()
20
- ) . '/';
21
- }
22
-
23
- /**
24
- * Retrieve the default title
25
- *
26
- * @return string
27
- */
28
- public function getDefaultTitle()
29
- {
30
- return $this->__('Search');
31
- }
32
-
33
- /**
34
- * Retrieve the search term used
35
- *
36
- * @return string
37
- */
38
- public function getSearchTerm()
39
- {
40
- return $this->helper('wordpress/router')->getSearchTerm();
41
- }
42
-
43
- /**
44
- * Ensure template is set
45
- *
46
- * @return string
47
- */
48
- protected function _beforeToHtml()
49
- {
50
- if (!$this->getTemplate()) {
51
- $this->setTemplate('wordpress/sidebar/widget/search.phtml');
52
- }
53
-
54
- return parent::_beforeToHtml();
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Tagcloud.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Tagcloud extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Retrieve a collection of tags
13
- *
14
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Tag_Collection
15
- */
16
- public function getTags()
17
- {
18
- if ($this->hasTags()) {
19
- return $this->_getData('tags');
20
- }
21
-
22
- $this->setTags(false);
23
-
24
- $tags = Mage::getResourceModel('wordpress/term_collection')
25
- ->addCloudFilter($this->getTaxonomy())
26
- ->setOrderByName()
27
- ->load();
28
-
29
- if (count($tags) > 0) {
30
- $max = 0;
31
- $hasPosts = false;
32
-
33
- foreach($tags as $tag) {
34
- $max = $tag->getCount() > $max ? $tag->getCount() : $max;
35
-
36
- if ($tag->getCount() > 0) {
37
- $hasPosts = true;
38
- }
39
- }
40
-
41
- if ($hasPosts) {
42
- $this->setMaximumPopularity($max);
43
- $this->setTags($tags);
44
- }
45
- }
46
-
47
- return $this->getData('tags');
48
- }
49
-
50
- /**
51
- * Retrieve a font size for a tag
52
- *
53
- * @param Varien_Object $tag
54
- * @return int
55
- */
56
- public function getFontSize(Varien_Object $tag)
57
- {
58
- if ($this->getMaximumPopularity() > 0) {
59
- $percentage = ($tag->getCount() * 100) / $this->getMaximumPopularity();
60
-
61
- foreach($this->getFontSizes() as $percentageLimit => $default) {
62
- if ($percentage <= $percentageLimit) {
63
- return $default;
64
- }
65
- }
66
- }
67
-
68
- return 150;
69
- }
70
-
71
- /**
72
- * Retrieve the default title
73
- *
74
- * @return string
75
- */
76
- public function getDefaultTitle()
77
- {
78
- return $this->__('Tag Cloud');
79
- }
80
-
81
- /**
82
- * Retrieve an array of font sizes
83
- *
84
- * @return array
85
- */
86
- public function getFontSizes()
87
- {
88
- if (!$this->hasFontSizes()) {
89
- return array(
90
- 25 => 90,
91
- 50 => 100,
92
- 75 => 120,
93
- 90 => 140,
94
- 100 => 150
95
- );
96
- }
97
-
98
- return $this->_getData('font_sizes');
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Taxonomy.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Taxonomy extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
- {
11
- /**
12
- * Returns the current category collection
13
- *
14
- * @return Fishpig_Wordpress_Model_Resource_Term_Collection
15
- */
16
- public function getTerms()
17
- {
18
- $collection = Mage::getResourceModel('wordpress/term_collection')
19
- ->addTaxonomyFilter($this->getTaxonomy());
20
-
21
- $collection->getSelect()
22
- ->reset('order')
23
- ->order('name ASC');
24
-
25
- $collection->addParentIdFilter($this->getParentId())
26
- ->addHasObjectsFilter();
27
-
28
-
29
- return $collection;
30
- }
31
-
32
- /**
33
- * Returns the parent ID used to display categories
34
- * If parent_id is not set, 0 will be returned and root categories displayed
35
- *
36
- * @return int
37
- */
38
- public function getParentId()
39
- {
40
- return number_format($this->getData('parent_id'), 0, '', '');
41
- }
42
-
43
- /**
44
- * Determine whether the category is the current category
45
- *
46
- * @param Fishpig_Wordpress_Model_Category $category
47
- * @return bool
48
- */
49
- public function isCurrentTerm($term)
50
- {
51
- if ($this->getCurrentTerm()) {
52
- if ((int)$term->getId() === (int)$this->getCurrentTerm()->getId()) {
53
- return true;
54
- }
55
-
56
- return in_array($term->getId(), $this->getActiveIds());
57
- }
58
-
59
- return false;
60
- }
61
-
62
- /**
63
- * Get an array of active IDs
64
- *
65
- * @return array
66
- */
67
- public function getActiveIds()
68
- {
69
- if (!$this->hasActiveIds() && ($current = $this->getCurrentTerm())) {
70
- $activeIds = array($current->getId());
71
-
72
- while($current->getParentTerm() !== false) {
73
- $current = $current->getParentTerm();
74
- $activeIds[] = $current->getId();
75
- }
76
-
77
- $this->setActiveIds($activeIds);
78
- }
79
-
80
- return $this->_getData('active_ids') ? $this->_getData('active_ids') : array();
81
- }
82
-
83
- /**
84
- * Retrieve the current category
85
- *
86
- * @return Fishpig_Wordpress_Model_Category
87
- */
88
- public function getCurrentTerm()
89
- {
90
- return Mage::registry('wordpress_term');
91
- }
92
-
93
- /**
94
- * Retrieve the default title
95
- *
96
- * @return string
97
- */
98
- public function getDefaultTitle()
99
- {
100
- return null;
101
- }
102
-
103
- /**
104
- * Set the posts collection
105
- *
106
- */
107
- protected function _beforeToHtml()
108
- {
109
- if (!$this->getTemplate()) {
110
- $this->setTemplate('wordpress/sidebar/widget/taxonomy.phtml');
111
- }
112
-
113
- return parent::_beforeToHtml();
114
- }
115
-
116
- /**
117
- * Draw a child item
118
- *
119
- * @param Fishpig_Wordpress_Model_Term $term
120
- * @param int $level = 0
121
- * @return string
122
- */
123
- public function drawChildItem(Fishpig_Wordpress_Model_Term $term, $level = 0)
124
- {
125
- $originalLevel = $this->getLevel();
126
- $this->setLevel($level);
127
-
128
- if ($this->getRendererTemplate()) {
129
- $this->setTemplate($this->getRendererTemplate());
130
- }
131
- else {
132
- $this->setTemplate('wordpress/sidebar/widget/taxonomy/renderer.phtml');
133
- }
134
-
135
- $html = $this->setTerm($term)->toHtml();
136
-
137
- $this->setLevel($originalLevel);
138
-
139
- return $html;
140
- }
141
-
142
- /**
143
- * Determines whether to show the post count
144
- *
145
- * @return bool
146
- */
147
- public function canShowCount()
148
- {
149
- return false;
150
- }
151
-
152
- /**
153
- * Determines whether the taxonomy is hierarchical
154
- *
155
- * @return bool
156
- */
157
- public function isHierarchical()
158
- {
159
- return true;
160
- }
161
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Text.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- class Fishpig_Wordpress_Block_Sidebar_Widget_Text extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
4
- {
5
- /**
6
- * Retrieve the default title
7
- *
8
- * @return string
9
- */
10
- public function getDefaultTitle()
11
- {
12
- return null;
13
- }
14
-
15
- /**
16
- * Convert {{block tags to HTML
17
- *
18
- * @return string
19
- */
20
- protected function _toHtml()
21
- {
22
- if ($html = parent::_toHtml()) {
23
- return Mage::helper('cms')->getBlockTemplateProcessor()->filter($html);
24
- }
25
-
26
- return '';
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Yarpp.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Sidebar_Widget_Yarpp extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- /**
12
- * This block is deprecated and will no longer work
13
- *
14
- * @return $this
15
- */
16
- protected function _beforeToHtml()
17
- {
18
- $this->setTemplate(null);
19
-
20
- return parent::_beforeToHtml();
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/System/Config/Form/Field/Post/Type.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_CrossLink
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_System_Config_Form_Field_Post_Type extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
10
- {
11
- /**
12
- * Prepare to render
13
- */
14
- protected function _prepareToRender()
15
- {
16
- $this->addColumn('custom_type', array(
17
- 'label' => $this->__('Custom Post Type'),
18
- ));
19
-
20
- $this->_addAfter = false;
21
- $this->_addButtonLabel = $this->__('Add New Custom Post Type');
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Template.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Template extends Fishpig_Wordpress_Block_Abstract
10
- {
11
- }
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block app/code/community/Fishpig/Wordpress/Block/Term/View.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Block_Term_View extends Fishpig_Wordpress_Block_Post_List_Wrapper_Abstract
10
- {
11
- /**
12
- * Returns the current Wordpress category
13
- * This is just a wrapper for getCurrentCategory()
14
- *
15
- * @return Fishpig_Wordpress_Model_Post_Categpry
16
- */
17
- public function getTerm()
18
- {
19
- if (!$this->hasTerm()) {
20
- $this->setTerm(Mage::registry('wordpress_term'));
21
- }
22
-
23
- return $this->_getData('term');
24
- }
25
-
26
- /**
27
- * Generates and returns the collection of posts
28
- *
29
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
30
- */
31
- protected function _getPostCollection()
32
- {
33
- if ($this->getTerm()) {
34
- return $this->getTerm()->getPostCollection();
35
- }
36
-
37
- return false;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Block/Sidebar/Widget/Instagram.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Fishpig
4
+ * @package Fishpig_Wordpress
5
+ * @license http://fishpig.co.uk/license.txt
6
+ * @author Ben Tideswell <help@fishpig.co.uk>
7
+ */
8
+
9
+ class Fishpig_Wordpress_Block_Sidebar_Widget_Instagram extends Fishpig_Wordpress_Block_Sidebar_Widget_Abstract
10
+ {
11
+ /**
12
+ * Retrieve the default title
13
+ *
14
+ * @return string
15
+ */
16
+ public function getDefaultTitle()
17
+ {
18
+ return $this->__('Instagram');
19
+ }
20
+
21
+ /**
22
+ *
23
+ **/
24
+ protected function _beforeToHtml()
25
+ {
26
+ if (!$this->getUsername()) {
27
+ echo __LINE__;
28
+ return false;
29
+ }
30
+
31
+ try {
32
+ $this->_getImageData();
33
+ }
34
+ catch(Exception $e) {
35
+ exit($e);
36
+ Mage::helper('wordpress')->log($e->getMessage());
37
+ }
38
+ }
39
+
40
+ /**
41
+ *
42
+ **/
43
+ public function getPostUrl($image)
44
+ {
45
+ return 'https://www.instagram.com/p/' . $image->getCode() . '/?taken-by=' . urlencode($this->getInstagramUsername());
46
+ }
47
+
48
+ /**
49
+ *
50
+ **/
51
+ protected function _getImageData()
52
+ {
53
+ $cacheFile = $this->_getCacheFile();
54
+
55
+ $url = 'https://www.instagram.com/' . $this->getUsername() . '/';
56
+
57
+ if (!is_file($cacheFile)) {
58
+ if ($data = file_get_contents($url)) {
59
+ // We have data via file_get_contents
60
+ }
61
+ else {
62
+ throw new Exception('CURL not implemented yet in Instagram widget.');
63
+ }
64
+
65
+ if (strpos($data, 'window._sharedData') === false) {
66
+ throw new Exception('Unable to parse response.');
67
+ }
68
+
69
+ $buffer = substr($data, 0, strpos($data, 'window._sharedData'));
70
+ $data = substr($data, strrpos($buffer, '<script'));
71
+ $data = substr($data, 0, strpos($data, '</script>'));
72
+ $data = preg_replace('/<script[^>]{1,}>/', '', $data);
73
+ $data = rtrim(trim(str_replace('window._sharedData =', '', $data)), ';');
74
+
75
+
76
+ $data = json_decode($data, true);
77
+
78
+ if (!$data) {
79
+ throw new Exception('Unable to parse JSON object.');
80
+ }
81
+
82
+ file_put_contents($cacheFile, json_encode($data));
83
+ }
84
+ else {
85
+ $data = json_decode(file_get_contents($cacheFile), true);
86
+ }
87
+
88
+ $images = array_values($data['entry_data']['ProfilePage'][0]['user']['media']['nodes']);
89
+
90
+ foreach($images as $key => $value) {
91
+ $images[$key] = new Varien_Object($value);
92
+ }
93
+
94
+
95
+ if ((int)$this->getMaxImages() > 0 && (int)$this->getMaxImages() < count($images)) {
96
+ $images = array_slice($images, 0, (int)$this->getMaxImages());
97
+ }
98
+
99
+ $this->setImages($images);
100
+
101
+ return parent::_beforeToHtml();
102
+ }
103
+
104
+ /**
105
+ *
106
+ **/
107
+ protected function _getCacheFile()
108
+ {
109
+ return Mage::getBaseDir('var') . DS . 'cache' . DS . 'instagram-' . date('Ymd') . '-' . $this->_getCacheDateKey() . '-' . md5($this->getInstagramUsername()) . '.cache';
110
+ }
111
+
112
+ /**
113
+ *
114
+ **/
115
+ protected function _getCacheDateKey()
116
+ {
117
+ $hour = date('G');
118
+
119
+ return $hour < $this->getRefreshByHour() ? 1 : (int)($hour / $this->getRefreshByHour()) + 1;
120
+ }
121
+
122
+ /**
123
+ *
124
+ **/
125
+ public function getRefreshByHour()
126
+ {
127
+ $hours = (int)$this->_getData('refresh_by_hour');
128
+
129
+ return $hours > 0 ? $hours : 0;
130
+ }
131
+ }
app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller/Abstract.php DELETED
@@ -1,476 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Controller_Abstract extends Mage_Core_Controller_Front_Action
10
- {
11
- /**
12
- * Blocks used to generate RSS feed items
13
- *
14
- * @var string
15
- */
16
- protected $_feedBlock = false;
17
-
18
- /**
19
- * Storage for breadcrumbs
20
- * These are added to the breadcrumbs block before rendering the page
21
- *
22
- * @var array
23
- */
24
- protected $_crumbs = array();
25
-
26
- /**
27
- * Used to do things en-masse
28
- * eg. include canonical URL
29
- *
30
- * If null, means no entity required
31
- * If false, means entity required but not set
32
- *
33
- * @return null|false|Mage_Core_Model_Abstract
34
- */
35
- public function getEntityObject()
36
- {
37
- return null;
38
- }
39
-
40
- /**
41
- * Ensure that the a database connection exists
42
- * If not, do load the route
43
- *
44
- * @return $this
45
- */
46
- public function preDispatch()
47
- {
48
- if (Mage::registry('wordpress_controller')) {
49
- Mage::unregister('wordpress_controller');
50
- }
51
-
52
- Mage::register('wordpress_controller', $this);
53
-
54
- parent::preDispatch();
55
-
56
- try {
57
- if (!$this->_canRunUsingConfig()) {
58
- $this->_forceForwardViaException('noRoute');
59
- return;
60
- }
61
-
62
- if ($this->getRequest()->getParam('feed_type')) {
63
- $this->getRequest()->setParam('feed', $this->getRequest()->getParam('feed_type')); // Legacy fix
64
-
65
- if (strpos(strtolower($this->getRequest()->getActionName()), 'feed') === false) {
66
- $this->_forceForwardViaException('feed');
67
- return;
68
- }
69
- }
70
- }
71
- catch (Mage_Core_Controller_Varien_Exception $e) {
72
- throw $e;
73
- }
74
- catch (Exception $e) {
75
- Mage::helper('wordpress')->log($e->getMessage());
76
-
77
- $this->_forceForwardViaException('noRoute');
78
- return;
79
- }
80
-
81
- // Check for redirects and forwards
82
- $transport = new Varien_Object();
83
-
84
- Mage::dispatchEvent(
85
- 'wordpress_' . strtolower(substr(get_class($this), strlen('Fishpig_Wordpress_'), -strlen('Controller'))) . '_controller_pre_dispatch_after',
86
- array(
87
- 'transport' => $transport,
88
- 'action' => $this,
89
- )
90
- );
91
-
92
- if ($transport->getForward()) {
93
- return $this->_forward(
94
- $transport->getForward()->getAction(),
95
- $transport->getForward()->getController(),
96
- $transport->getForward()->getModule()
97
- );
98
- }
99
-
100
- return $this;
101
- }
102
-
103
- /**
104
- * Determine whether the extension can run using the current config settings for this scope
105
- * This will attempt to connect to the DB
106
- *
107
- * @return bool
108
- */
109
- protected function _canRunUsingConfig()
110
- {
111
- if (!$this->isEnabledForStore()) {
112
- return false;
113
- }
114
-
115
- if (Mage::helper('wordpress/app')->getDbConnection() === false) {
116
- return false;
117
- }
118
-
119
- if (($object = $this->getEntityObject()) === false) {
120
- return false;
121
- }
122
-
123
- Mage::dispatchEvent($this->getFullActionName() . '_init_after', array('object' => $object, $this->getRequest()->getControllerName() => $object, 'action' => $this));
124
-
125
- return true;
126
- }
127
-
128
- /**
129
- * Before rendering layout, apply root template (if set)
130
- * and add various META items
131
- *
132
- * @param string $output = ''
133
- * @return $this
134
- */
135
- public function renderLayout($output='')
136
- {
137
- Mage::dispatchEvent('wordpress_render_layout_before', array('object' => $this->getEntityObject(), 'action' => $this));
138
-
139
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
140
- if ($entity = $this->getEntityObject()) {
141
- $headBlock->addItem('link_rel', ($entity->getCanonicalUrl() ? $entity->getCanonicalUrl() : $entity->getUrl()), 'rel="canonical"');
142
- }
143
-
144
- $headBlock->addItem('link_rel',
145
- Mage::helper('wordpress')->getUrl('feed/'),
146
- 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Feed"'
147
- );
148
-
149
- $headBlock->addItem('link_rel',
150
- Mage::helper('wordpress')->getUrl('comments/feed/'),
151
- 'rel="alternate" type="application/rss+xml" title="' . Mage::helper('wordpress')->getWpOption('blogname') . ' &raquo; Comments Feed"'
152
- );
153
- }
154
-
155
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
156
- if (Mage::helper('wordpress')->getWpOption('blog_public') !== '1') {
157
- $headBlock->setRobots('noindex,nofollow');
158
- }
159
- }
160
-
161
- $crumbCount = count($this->_crumbs);
162
-
163
- if ($crumbCount > 0 && ($block = $this->getLayout()->getBlock('breadcrumbs')) !== false) {
164
- foreach($this->_crumbs as $crumbName => $crumb) {
165
- if (--$crumbCount === 0 && isset($crumb[0]['link'])) {
166
- unset($crumb[0]['link']);
167
- }
168
-
169
- if ($crumb[0]['title']) {
170
- $block->addCrumb($crumbName, $crumb[0], $crumb[1]);
171
- }
172
- }
173
- }
174
-
175
- $this->_renderTitles();
176
-
177
- Mage::helper('wordpress/social')->addCodeToHead();
178
-
179
- return parent::renderLayout($output);
180
- }
181
-
182
- /**
183
- * Loads layout and performs initialising tasls
184
- *
185
- */
186
- protected function _initLayout()
187
- {
188
- if (!$this->_isLayoutLoaded) {
189
- $this->loadLayout();
190
- }
191
-
192
- $this->_title()->_title(Mage::helper('wordpress')->getWpOption('blogname'));
193
-
194
- $this->addCrumb('home', array('link' => Mage::getUrl(), 'label' => $this->__('Home')));
195
-
196
- if (!$this->isFrontPage()) {
197
- $toplinkUrl = Mage::helper('wordpress')->getTopLinkUrl();
198
-
199
- if ($toplinkUrl !== Mage::getUrl()) {
200
- $this->addCrumb('blog', array('link' => $toplinkUrl, 'label' => $this->__(Mage::helper('wordpress')->getTopLinkLabel())));
201
- }
202
- }
203
- else {
204
- $this->addCrumb('blog', array('label' => $this->__(Mage::helper('wordpress')->getTopLinkLabel())));
205
- }
206
-
207
- if ($rootBlock = $this->getLayout()->getBlock('root')) {
208
- $rootBlock->addBodyClass('is-blog');
209
- }
210
-
211
- Mage::dispatchEvent('wordpress_init_layout_after', array('object' => $this->getEntityObject(), 'controller' => $this));
212
- Mage::dispatchEvent($this->getFullActionName() . '_init_layout_after', array('object' => $this->getEntityObject(), 'controller' => $this));
213
-
214
- return $this;
215
- }
216
-
217
- /**
218
- * Adds a crumb to the breadcrumb trail
219
- *
220
- * @param string $crumbName
221
- * @param array $crumbInfo
222
- * @param string $after
223
- */
224
- public function addCrumb($crumbName, array $crumbInfo, $after = false)
225
- {
226
- if (!isset($crumbInfo['title'])) {
227
- $crumbInfo['title'] = $crumbInfo['label'];
228
- }
229
-
230
- $this->_crumbs[$crumbName] = array($crumbInfo, $after);
231
-
232
- return $this;
233
- }
234
-
235
- /**
236
- * Remove a breadcrumb by it's name
237
- *
238
- * @param string $crumbName
239
- * @return $this
240
- */
241
- public function removeCrumb($crumbName)
242
- {
243
- if (isset($this->_crumbs[$crumbName])) {
244
- unset($this->_crumbs[$crumbName]);
245
- }
246
-
247
- return $this;
248
- }
249
-
250
- /**
251
- * Retrieve a breadcrumb
252
- *
253
- * @param string $crumbName
254
- * @return array
255
- */
256
- public function getCrumb($crumbName)
257
- {
258
- return isset($this->_crumbs[$crumbName]) ? $this->_crumbs[$crumbName] : false;
259
- }
260
-
261
- /**
262
- * Get the breadcrumbs array
263
- *
264
- * @return array
265
- */
266
- public function getCrumbs()
267
- {
268
- return $this->_crumbs;
269
- }
270
-
271
- /**
272
- * Adds custom layout handles
273
- *
274
- * @param array $handles = array()
275
- */
276
- protected function _addCustomLayoutHandles(array $handles = array())
277
- {
278
- $update = $this->getLayout()->getUpdate();
279
-
280
- array_unshift($handles, 'wordpress_default');
281
-
282
- $storeHandlePrefix = 'STORE_' . Mage::app()->getStore()->getCode() . '_';
283
- $allHandles = array();
284
-
285
- foreach($handles as $it => $handle) {
286
- $allHandles[] = $handle;
287
- $allHandles[] = $storeHandlePrefix . $handle;
288
- }
289
-
290
- array_unshift($allHandles, 'default');
291
-
292
- foreach($allHandles as $handle) {
293
- $update->addHandle($handle);
294
- }
295
-
296
- $this->addActionLayoutHandles();
297
-
298
- $handles = $update->getHandles();
299
-
300
- $update->addHandle($storeHandlePrefix . array_pop($handles));
301
-
302
- $this->loadLayoutUpdates();
303
- $this->generateLayoutXml();
304
- $this->generateLayoutBlocks();
305
-
306
- $this->_isLayoutLoaded = true;
307
-
308
- return $this;
309
- }
310
-
311
- /**
312
- * Force the extension to remove any currently set titles
313
- * This is likely to be called by SEO plugins (AllInOneSEO and Yoast SEO)
314
- * so that they can rewrite the page titles
315
- *
316
- * @return $this
317
- */
318
- public function ignoreAutomaticTitles()
319
- {
320
- $this->_titles = array();
321
- $this->_removeDefaultTitle = true;
322
-
323
- return $this;
324
- }
325
-
326
- /**
327
- * Retrieve the router helper object
328
- *
329
- * @return Fishpig_Wordpress_Helper_Router
330
- */
331
- public function getRouterHelper()
332
- {
333
- return Mage::helper('wordpress/router');
334
- }
335
-
336
- /**
337
- * Determine whether the extension has been enabled for the current store
338
- *
339
- * @return bool
340
- */
341
- public function isEnabledForStore()
342
- {
343
- return (!Mage::getStoreConfigFlag('advanced/modules_disable_output/Fishpig_Wordpress')
344
- && Mage::getStoreConfigFlag('wordpress/module/enabled'));
345
- }
346
-
347
- /**
348
- * Determine whether the current page is the blog homepage
349
- *
350
- * @return bool
351
- */
352
- public function isFrontPage()
353
- {
354
- return $this->getFullActionName() === 'wordpress_index_index';
355
- }
356
-
357
- /**
358
- * Force Magento ro redirect to a different route
359
- * This will happen without changing the current URL
360
- *
361
- * @param string $action
362
- * @param string $controller = ''
363
- * @param string $module = ''
364
- * @param array $params = array
365
- * @return void
366
- */
367
- protected function _forceForwardViaException($action, $controller = '', $module = '', $params = array())
368
- {
369
- if ($action === 'noRoute') {
370
- $controller = 'index';
371
- $module = 'cms';
372
- }
373
- else {
374
- if ($controller === '') {
375
- $controller = $this->getRequest()->getControllerName();
376
- }
377
-
378
- if ($module === '') {
379
- $module = $this->getRequest()->getModuleName();
380
- }
381
- }
382
-
383
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
384
-
385
- $e = new Mage_Core_Controller_Varien_Exception();
386
-
387
- throw $e->prepareForward($action, $controller, $module, $params);
388
- }
389
-
390
- /**
391
- * Forward a request to WordPress
392
- *
393
- * @param string $uri = ''
394
- * @return $this
395
- */
396
- protected function _forwardToWordPress($uri = '')
397
- {
398
- return $this->_redirectUrl(
399
- rtrim(Mage::helper('wordpress')->getWpOption('siteurl'), '/') . '/' . ltrim($uri, '/')
400
- );
401
- }
402
-
403
- /**
404
- * Render the RSS Feed
405
- *
406
- * @return void
407
- */
408
- public function feedAction()
409
- {
410
- if (($block = $this->_feedBlock) !== false) {
411
- if (strpos($block, '/') === false) {
412
- $block = 'wordpress/' . $block;
413
- }
414
-
415
- $this->getResponse()
416
- ->setHeader('Content-Type', 'text/xml; charset=UTF-8')
417
- ->setBody(
418
- $this->getLayout()->createBlock('wordpress/feed_post')->setSourceBlock($block)->setFeedType(
419
- $this->getRequest()->getParam('feed', 'rss2')
420
- )->toHtml()
421
- );
422
- }
423
- else {
424
- $this->_forward('noRoute');
425
- }
426
- }
427
-
428
- /**
429
- * Display the comments feed
430
- *
431
- * @return void
432
- */
433
- public function commentsFeedAction()
434
- {
435
- $this->getResponse()
436
- ->setHeader('Content-Type', 'text/xml; charset=UTF-8')
437
- ->setBody(
438
- $this->getLayout()->createBlock('wordpress/feed_post_comment')
439
- ->setSource(Mage::registry('wordpress_post'))
440
- ->setFeedType($this->getRequest()->getParam('feed', 'rss2'))
441
- ->toHtml()
442
- );
443
- }
444
-
445
- /**
446
- * Allows for legacy methods to be catered for
447
- *
448
- * @param string $method
449
- * @param array $args
450
- * @return mixed
451
- */
452
- public function __call($method, $args)
453
- {
454
- $transport = new Varien_Object(array());
455
-
456
- Mage::dispatchEvent('wordpress_controller_method_invalid', array('method' => $method, 'args' => $args, 'object' => $this, 'transport' => $transport));
457
-
458
- if (!$transport->hasReturnValue()) {
459
- throw new Varien_Exception("Invalid method ".get_class($this)."::".$method."(".print_r($args,1).")");
460
- }
461
-
462
- return $transport->getReturnValue();
463
- }
464
-
465
- /**
466
- * If this method is called, you need to update your Magento WordPress Integration add-on extensions
467
- *
468
- * @return $this
469
- **/
470
- public function includejQuery()
471
- {
472
- Mage::helper('wordpress')->log("You need to update your Magento WordPress Integration add-on extensions.");
473
-
474
- return $this;
475
- }
476
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller app/code/community/Fishpig/Wordpress/Controller/Router.php DELETED
@@ -1,408 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract
10
- {
11
- /**
12
- * Callback methods used to generate possible routes
13
- *
14
- * @var array
15
- */
16
- protected $_routeCallbacks = array();
17
-
18
- /**
19
- * Stores the static routes used by WordPress
20
- *
21
- * @var array
22
- */
23
- protected $_staticRoutes = array();
24
-
25
- /**
26
- * Create an instance of the router and add it to the queue
27
- *
28
- * @param Varien_Event_Observer $observer
29
- * @return bool
30
- */
31
- public function initControllerObserver(Varien_Event_Observer $observer)
32
- {
33
- try {
34
- # Mage::helper('wordpress/app')->init();
35
-
36
- if ($this->isEnabled()) {
37
- $routerClass = get_class($this);
38
-
39
- $observer->getEvent()
40
- ->getFront()
41
- ->addRouter('wordpress', new $routerClass);
42
- }
43
-
44
- return true;
45
- }
46
- catch (Exception $e) {
47
- Mage::helper('wordpress')->log($e);
48
- }
49
-
50
- return false;
51
- }
52
-
53
- /**
54
- * Remove the AW_Blog route to stop conflicts
55
- *
56
- * @param Varien_Event_Observer $observer
57
- * @return bool
58
- */
59
- public function initControllerBeforeObserver(Varien_Event_Observer $observer)
60
- {
61
- return $this;
62
- /*
63
- if (Mage::getDesign()->getArea() === 'frontend') {
64
- $node = Mage::getConfig()->getNode('global/events/controller_front_init_routers/observers');
65
-
66
- if (isset($node->blog)) {
67
- unset($node->blog);
68
-
69
- Mage::getConfig()->setNode('modules/AW_Blog/active', 'false', true);
70
- Mage::getConfig()->setNode('frontend/routers/blog', null, true);
71
- }
72
- }
73
- */
74
-
75
- return false;
76
- }
77
-
78
- /**
79
- * Attempt to match the current URI to this module
80
- * If match found, set module, controller, action and dispatch
81
- *
82
- * @param Zend_Controller_Request_Http $request
83
- * @return bool
84
- */
85
- public function match(Zend_Controller_Request_Http $request)
86
- {
87
- try {
88
- Mage::helper('wordpress/app')->init();
89
-
90
- if (!Mage::helper('wordpress/app')->getDbConnection()) {
91
- return false;
92
- }
93
-
94
- if (!Mage::helper('wordpress')->isFullyIntegrated() || Mage::app()->getStore()->getCode() === 'admin') {
95
- return false;
96
- }
97
-
98
- if (($uri = Mage::helper('wordpress/router')->getBlogUri()) === null) {
99
- return false;
100
- }
101
-
102
- Mage::dispatchEvent('wordpress_match_routes_before', array('router' => $this, 'uri' => $uri));
103
-
104
- # Call this again to check for changes
105
- if (($uri = Mage::helper('wordpress/router')->getBlogUri()) === null) {
106
- return false;
107
- }
108
-
109
- if (!$uri) {
110
- $this->addRouteCallback(array($this, '_getHomepageRoutes'));
111
- }
112
-
113
- $this->addRouteCallback(array($this, '_getSimpleRoutes'));
114
- $this->addRouteCallback(array($this, '_getPostRoutes'));
115
- $this->addRouteCallback(array($this, '_getTaxonomyRoutes'));
116
-
117
- if (($route = $this->_matchRoute($uri)) !== false) {
118
- return $this->setRoutePath($route['path'], $route['params']);
119
- }
120
-
121
- Mage::dispatchEvent('wordpress_match_routes_after', array('router' => $this, 'uri' => $uri));
122
- }
123
- catch (Exception $e) {
124
- Mage::helper('wordpress')->log($e->getMessage());
125
- }
126
-
127
- return !is_null(Mage::app()->getRequest()->getModuleName())
128
- && !is_null(Mage::app()->getRequest()->getControllerName())
129
- && !is_null(Mage::app()->getRequest()->getActionName());
130
- }
131
-
132
- /**
133
- * Get route data for different homepage URLs
134
- *
135
- * @param string $uri = ''
136
- * @return $this
137
- */
138
- protected function _getHomepageRoutes($uri = '')
139
- {
140
- if ($postId = Mage::app()->getRequest()->getParam('p')) {
141
- return $this->addRoute('', '*/post/view', array('p' => $postId, 'id' => $postId));
142
- }
143
-
144
- if (($pageId = $this->_getHomepagePageId()) !== false) {
145
- return $this->addRoute('', '*/post/view', array('id' => $pageId, 'post_type' => 'page', 'home' => 1));
146
- }
147
-
148
- $this->addRoute('', '*/index/index');
149
-
150
- return $this;
151
- }
152
-
153
- /**
154
- * Generate the basic simple routes that power WP
155
- *
156
- * @param string $uri = ''
157
- * @return false|$this
158
- */
159
- protected function _getSimpleRoutes($uri = '')
160
- {
161
- if (strpos($uri, 'ajax/') === 0) {
162
- $this->_getAjaxRoutes($uri);
163
- }
164
-
165
- $this->addRoute(array('/^author\/([^\/]{1,})/' => array('author')), '*/author/view');
166
- $this->addRoute(array('/^([1-2]{1}[0-9]{3})\/([0-1]{1}[0-9]{1})$/' => array('year', 'month')), '*/archive/view');
167
- $this->addRoute(array('/^([1-2]{1}[0-9]{3})\/([0-1]{1}[0-9]{1})$/' => array('year', 'month')), '*/archive/view');
168
- $this->addRoute(array('/^([1-2]{1}[0-9]{3})\/([0-1]{1}[0-9]{1})\/([0-3]{1}[0-9]{1})$/' => array('year', 'month', 'day')), '*/archive/view');
169
- $this->addRoute(array('/^search\/(.*)$/' => array('s')), '*/search/index');
170
- $this->addRoute('search', '*/search/index', array('redirect_broken_url' => 1)); # Fix broken search URLs
171
- $this->addRoute('/^index.php/i', '*/index/forward');
172
- $this->addRoute('/^wp-content\/(.*)/i', '*/index/forwardFile');
173
- $this->addRoute('/^wp-includes\/(.*)/i', '*/index/forwardFile');
174
- $this->addRoute('/^wp-cron.php.*/', '*/index/forwardFile');
175
- $this->addRoute('/^wp-admin[\/]{0,1}$/', '*/index/wpAdmin');
176
- $this->addRoute('/^wp-pass.php.*/', '*/index/applyPostPassword');
177
- $this->addRoute('robots.txt', '*/index/robots');
178
- $this->addRoute('comments', '*/index/commentsFeed');
179
- $this->addRoute(array('/^newbloguser\/(.*)$/' => array('code')), '*/index/forwardNewBlogUser');
180
-
181
- return $this;
182
- }
183
-
184
- /**
185
- * Retrieve routes for the AJAX methods
186
- * These can be used to get another store's blogs blocks
187
- *
188
- * @param string $uri = ''
189
- * @return $this
190
- */
191
- protected function _getAjaxRoutes($uri = '')
192
- {
193
- $this->addRoute(array('/^ajax\/handle\/([^\/]{1,})[\/]{0,}$/' => array('handle')), '*/ajax/handle');
194
- $this->addRoute(array('/^ajax\/block\/([^\/]{1,})[\/]{0,}$/' => array('block')), '*/ajax/block');
195
-
196
- return $this;
197
- }
198
-
199
- /**
200
- * Generate the post routes
201
- *
202
- * @param string $uri = ''
203
- * @return false|$this
204
- */
205
- protected function _getPostRoutes($uri = '')
206
- {
207
- if (($routes = Mage::getResourceSingleton('wordpress/post')->getPermalinksByUri($uri)) === false) {
208
- return false;
209
- }
210
-
211
- foreach($routes as $routeId => $route) {
212
-
213
- $this->addRoute(rtrim($route, '/'), '*/post/view', array('id' => $routeId));
214
- $this->addRoute(rtrim($route, '/') . '/all', '*/post/view', array('id' => $routeId));
215
- }
216
-
217
- return $this;
218
- }
219
-
220
- /**
221
- * Get the custom taxonomy URI's
222
- * First check whether a valid taxonomy exists in $uri
223
- *
224
- * @param string $uri = ''
225
- * @return $this
226
- */
227
- protected function _getTaxonomyRoutes($uri = '')
228
- {
229
- foreach(Mage::helper('wordpress/app')->getTaxonomies() as $taxonomy) {
230
- if (($routes = $taxonomy->getUris($uri)) !== false) {
231
- foreach($routes as $routeId => $route) {
232
- $this->addRoute($route, '*/term/view', array('id' => $routeId, 'taxonomy' => $taxonomy->getTaxonomyType()));
233
- $this->addRoute(rtrim($route, '/') . '/feed', '*/term/feed', array('id' => $routeId, 'taxonomy' => $taxonomy->getTaxonomyType()));
234
-
235
- if ($taxonomy->getExtraRoutes()) {
236
- foreach($taxonomy->getExtraRoutes() as $pattern => $newRoute) {
237
- $this->addRoute(str_replace('*', $route, $pattern), $newRoute, array('id' => $routeId, 'taxonomy' => $taxonomy->getTaxonomyType()));
238
- }
239
- }
240
- }
241
- }
242
- }
243
-
244
- return $this;
245
- }
246
-
247
- /**
248
- * If a page is set as a custom homepage, get it's ID
249
- *
250
- * @return false|int
251
- */
252
- protected function _getHomepagePageId()
253
- {
254
- return Mage::helper('wordpress/router')->getHomepagePageId();
255
- }
256
-
257
- /**
258
- * Determine whether to add routes
259
- *
260
- * @return bool
261
- */
262
- public function isEnabled()
263
- {
264
- return (int)Mage::app()->getStore()->getId() !== 0;
265
- }
266
-
267
- /**
268
- * Set the path and parameters ready for dispatch
269
- *
270
- * @param array $path
271
- * @param array $params = array
272
- * @return $this
273
- */
274
- public function setRoutePath($path, array $params = array())
275
- {
276
- if (is_string($path)) {
277
- // Legacy
278
- $path = explode('/', $path);
279
-
280
- $path = array(
281
- 'module' => $path[0] === '*' ? 'wordpress' : $path[0],
282
- 'controller' => $path[1],
283
- 'action' => $path[2],
284
-
285
- );
286
- }
287
-
288
- $request = Mage::app()->getRequest();
289
-
290
- $request->setModuleName($path['module'])
291
- ->setRouteName($path['module'])
292
- ->setControllerName($path['controller'])
293
- ->setActionName($path['action']);
294
-
295
- foreach($params as $key => $value) {
296
- $request->setParam($key, $value);
297
- }
298
-
299
- $helper = Mage::helper('wordpress/router');
300
-
301
- $request->setAlias(
302
- Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
303
- ltrim($helper->getBlogRoute() . '/' . $helper->getBlogUri(), '/')
304
- );
305
-
306
- return true;
307
- }
308
-
309
- /**
310
- * Execute callbacks and match generated routes against $uri
311
- *
312
- * @param string $uri = ''
313
- * @return false|array
314
- */
315
- protected function _matchRoute($uri = '')
316
- {
317
- $encodedUri = strtolower(str_replace('----slash----', '/', urlencode(str_replace('/', '----slash----', $uri))));
318
-
319
- foreach($this->_routeCallbacks as $callback) {
320
- $this->_staticRoutes = array();
321
-
322
- if (call_user_func($callback, $uri, $this) !== false) {
323
- foreach($this->_staticRoutes as $route => $data) {
324
- $match = false;
325
-
326
- if (substr($route, 0, 1) !== '/') {
327
- $match = $route === $encodedUri || $route === $uri;
328
- }
329
- else {
330
- if (preg_match($route, $uri, $matches)) {
331
- $match = true;
332
-
333
- if (isset($data['pattern_keys']) && is_array($data['pattern_keys'])) {
334
- array_shift($matches);
335
-
336
- if (!isset($data['params'])) {
337
- $data['params'] = array();
338
- }
339
-
340
- foreach($matches as $match) {
341
- if (($pkey = array_shift($data['pattern_keys'])) !== null) {
342
- $data['params'][$pkey] = $match;
343
- }
344
- }
345
- }
346
- }
347
- }
348
-
349
- if ($match) {
350
- if (isset($data['params']['__redirect_to'])) {
351
- header('Location: ' . $data['params']['__redirect_to']);
352
- exit;
353
- }
354
-
355
- return $data;
356
- }
357
- }
358
- }
359
- }
360
-
361
- return false;
362
- }
363
-
364
- /**
365
- * Add a callback method to generate new routes
366
- *
367
- * @param array
368
- */
369
- public function addRouteCallback(array $callback)
370
- {
371
- $this->_routeCallbacks[] = $callback;
372
-
373
- return $this;
374
- }
375
-
376
- /**
377
- * Add a generated route and it's details
378
- *
379
- * @param array|string $pattern
380
- * @param string $path
381
- * @param array|null $params = array()
382
- * @return $this
383
- */
384
- public function addRoute($pattern, $path, $params = array())
385
- {
386
- if (is_array($pattern)) {
387
- $keys = $pattern[key($pattern)];
388
- $pattern = key($pattern);
389
- }
390
- else {
391
- $keys = array();
392
- }
393
-
394
- $path = array_combine(array('module', 'controller', 'action'), explode('/', $path));
395
-
396
- if ($path['module'] === '*') {
397
- $path['module'] = 'wordpress';
398
- }
399
-
400
- $this->_staticRoutes[$pattern] = array(
401
- 'path' => $path,
402
- 'params' => $params,
403
- 'pattern_keys' => $keys,
404
- );
405
-
406
- return $this;
407
- }
408
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Exception.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Exception extends Mage_Core_Exception
10
- {
11
- /**
12
- * Status flags
13
- *
14
- * const int
15
- */
16
- const STATUS_SUCCESS = 1;
17
- const STATUS_WARNING = 2;
18
- const STATUS_ERROR = 3;
19
-
20
- /**
21
- * Retrieve the message
22
- *
23
- * @return string
24
- */
25
- public function message()
26
- {
27
- return $this->message;
28
- }
29
-
30
- /**
31
- * Create a new instance of this object
32
- *
33
- * @param string $title
34
- * @param string $longMessage
35
- * @param int $status = 3
36
- * @return $this
37
- */
38
- static public function factory($title, $longMessage, $status = 3)
39
- {
40
- $e = new Fishpig_Wordpress_Exception($title, $status);
41
-
42
- return $e->addMessage(Mage::getModel('core/message')->error($longMessage));
43
- }
44
-
45
- /**
46
- * Create a new instance of this object (success)
47
- *
48
- * @param string $title
49
- * @param string $longMessage
50
- * @return $this
51
- */
52
- static public function success($title, $longMessage = '')
53
- {
54
- return self::factory($title, $longMessage, self::STATUS_SUCCESS);
55
- }
56
-
57
- /**
58
- * Create a new instance of this object (warning)
59
- *
60
- * @param string $title
61
- * @param string $longMessage
62
- * @return $this
63
- */
64
- static public function warning($title, $longMessage = '')
65
- {
66
- return self::factory($title, $longMessage, self::STATUS_WARNING);
67
- }
68
-
69
- /**
70
- * Create a new instance of this object (error)
71
- *
72
- * @param string $title
73
- * @param string $longMessage
74
- * @return $this
75
- */
76
- static public function error($title, $longMessage = '')
77
- {
78
- return self::factory($title, $longMessage, self::STATUS_ERROR);
79
- }
80
-
81
- /**
82
- * Retrieve the long message
83
- *
84
- * @return string
85
- */
86
- public function getLongMessage()
87
- {
88
- $longMessage = '';
89
-
90
- foreach($this->getMessages() as $message) {
91
- $longMessage .= $message->getCode();
92
- }
93
-
94
- return $longMessage;
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Exception.php app/code/community/Fishpig/Wordpress/Exception.php app/code/community/Fishpig/Wordpress/Exception.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Exception extends Mage_Core_Exception
10
- {
11
- /**
12
- * Status flags
13
- *
14
- * const int
15
- */
16
- const STATUS_SUCCESS = 1;
17
- const STATUS_WARNING = 2;
18
- const STATUS_ERROR = 3;
19
-
20
- /**
21
- * Retrieve the message
22
- *
23
- * @return string
24
- */
25
- public function message()
26
- {
27
- return $this->message;
28
- }
29
-
30
- /**
31
- * Create a new instance of this object
32
- *
33
- * @param string $title
34
- * @param string $longMessage
35
- * @param int $status = 3
36
- * @return $this
37
- */
38
- static public function factory($title, $longMessage, $status = 3)
39
- {
40
- $e = new Fishpig_Wordpress_Exception($title, $status);
41
-
42
- return $e->addMessage(Mage::getModel('core/message')->error($longMessage));
43
- }
44
-
45
- /**
46
- * Create a new instance of this object (success)
47
- *
48
- * @param string $title
49
- * @param string $longMessage
50
- * @return $this
51
- */
52
- static public function success($title, $longMessage = '')
53
- {
54
- return self::factory($title, $longMessage, self::STATUS_SUCCESS);
55
- }
56
-
57
- /**
58
- * Create a new instance of this object (warning)
59
- *
60
- * @param string $title
61
- * @param string $longMessage
62
- * @return $this
63
- */
64
- static public function warning($title, $longMessage = '')
65
- {
66
- return self::factory($title, $longMessage, self::STATUS_WARNING);
67
- }
68
-
69
- /**
70
- * Create a new instance of this object (error)
71
- *
72
- * @param string $title
73
- * @param string $longMessage
74
- * @return $this
75
- */
76
- static public function error($title, $longMessage = '')
77
- {
78
- return self::factory($title, $longMessage, self::STATUS_ERROR);
79
- }
80
-
81
- /**
82
- * Retrieve the long message
83
- *
84
- * @return string
85
- */
86
- public function getLongMessage()
87
- {
88
- $longMessage = '';
89
-
90
- foreach($this->getMessages() as $message) {
91
- $longMessage .= $message->getCode();
92
- }
93
-
94
- return $longMessage;
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Abstract.php DELETED
@@ -1,256 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Abstract extends Mage_Core_Helper_Abstract
10
- {
11
- /**
12
- * Internal cache variable
13
- *
14
- * @var array
15
- */
16
- static protected $_cache = array();
17
-
18
- /**
19
- * Returns the URL used to access your Wordpress frontend
20
- *
21
- * @param string|null $extra = null
22
- * @param array $params = array
23
- * @return string
24
- */
25
- public function getUrl($extra = null, array $params = array())
26
- {
27
- if (count($params) > 0) {
28
- $extra = trim($extra, '/') . '/';
29
-
30
- foreach($params as $key => $value) {
31
- $extra .= $key . '/' . $value . '/';
32
- }
33
- }
34
-
35
- if ($this->isFullyIntegrated()) {
36
- $params = array(
37
- '_direct' => ltrim($this->getBlogRoute() . '/' . ltrim($extra, '/'), '/'),
38
- '_secure' => false,
39
- '_nosid' => true,
40
- '_store' => Mage::app()->getStore()->getId(),
41
- );
42
-
43
- if (Mage::app()->getStore()->getCode() == 'admin') {
44
- if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
45
- $params['_store'] = $storeCode;
46
- }
47
- else {
48
- $params['_store'] = $this->getDefaultStore(Mage::app()->getRequest()->getParam('website', null))->getId();
49
- }
50
- }
51
-
52
- $url = $this->_getUrl('', $params);
53
- }
54
- else {
55
- $url = $this->getWpOption('home') . '/' . ltrim($extra, '/');
56
- }
57
-
58
- return htmlspecialchars($url);
59
- }
60
-
61
- /**
62
- * Returns the blog route selected in the Magento config
63
- *
64
- * @return string|null
65
- */
66
- public function getBlogRoute()
67
- {
68
- if ($this->isFullyIntegrated()) {
69
- if (!$this->_isCached('blog_route')) {
70
- $transport = new Varien_Object(array('blog_route' => trim(strtolower(Mage::getStoreConfig('wordpress/integration/route', Mage::helper('wordpress/app')->getStore()->getId())), '/')));
71
-
72
- Mage::dispatchEvent('wordpress_get_blog_route', array('transport' => $transport));
73
-
74
- $this->_cache('blog_route', $transport->getBlogRoute());
75
- }
76
-
77
- return $this->_cached('blog_route');
78
- }
79
-
80
- return null;
81
- }
82
-
83
- /**
84
- * Determine whether the extension is fully integrated
85
- * If false, semi-integration is being used
86
- *
87
- * @return bool
88
- */
89
- public function isFullyIntegrated()
90
- {
91
- return Mage::getStoreConfigFlag('wordpress/integration/full', Mage::helper('wordpress/app')->getStore()->getId());
92
- }
93
-
94
- public function getCustomizerData()
95
- {
96
- if (Mage::app()->getRequest()->getPost('wp_customize') === 'on') {
97
- if ($data = Mage::app()->getRequest()->getPost('customized')) {
98
- if ($data = json_decode(stripslashes($data), true)) {
99
- return $data;
100
- }
101
- }
102
- }
103
-
104
- return false;
105
- }
106
-
107
- /**
108
- * Gets a Wordpress option based on it's option name
109
- *
110
- * @param string $optionName
111
- * @param mixed $default = null
112
- * @return string
113
- */
114
- public function getWpOption($key, $default = null)
115
- {
116
- if ($data = $this->getCustomizerData()) {
117
- if (isset($data[$key])) {
118
- return $data[$key];
119
- }
120
- }
121
-
122
- $db = $this instanceof Fishpig_Wordpress_Helper_App
123
- ? $this->getDbConnection()
124
- : Mage::helper('wordpress/app')->getDbConnection();
125
-
126
- if (!$db) {
127
- return false;
128
- }
129
-
130
- $cacheKey = 'wp_option_' . $key;
131
-
132
- if ($this->_isCached($cacheKey)) {
133
- return $this->_cached($cacheKey);
134
- }
135
-
136
- $this->_cache($cacheKey, $default);
137
-
138
- try {
139
- $select = $db->select()
140
- ->from(Mage::getSingleton('core/resource')->getTableName('wordpress/option'), 'option_value')
141
- ->where('option_name = ?', $key)
142
- ->limit(1);
143
-
144
- if ($value = $db->fetchOne($select)) {
145
- $this->_cache($cacheKey, $value);
146
-
147
- return $value;
148
- }
149
-
150
- return $default;
151
- }
152
- catch (Exception $e) {
153
- $this->log($e->getMessage());
154
- }
155
-
156
- return false;
157
- }
158
-
159
- /**
160
- * Logs an error to the Wordpress error log
161
- *
162
- */
163
- public function log($message, $serious = true)
164
- {
165
- if (is_object($message) && $message instanceof Exception) {
166
- $message = $message->__toString();
167
- }
168
-
169
- if ($message = trim($message)) {
170
- return Mage::log($message, null, 'wordpress.log', true);
171
- }
172
- }
173
-
174
- /**
175
- * Retrieve the default store model
176
- *
177
- * @return Mage_Core_Model_Store
178
- */
179
- public function getDefaultStore($websiteCode = null)
180
- {
181
- if (!is_null($websiteCode)) {
182
- $website = Mage::app()->getWebsite($websiteCode);
183
- }
184
- else {
185
- $allWebsites = Mage::app()->getWebsites(false);
186
- $website = array_shift($allWebsites);
187
- }
188
-
189
- return $website->getDefaultStore();
190
- }
191
-
192
- /**
193
- * Store a value in the cache
194
- *
195
- * @param string $key
196
- * @param mixed $value
197
- * @return $this;
198
- */
199
- protected function _cache($key, $value)
200
- {
201
- self::$_cache[$key] = $value;
202
-
203
- return $this;
204
- }
205
-
206
- /**
207
- * Determine whether there is a value in the cache for the key
208
- *
209
- * @param string $key
210
- * @return bool
211
- */
212
- protected function _isCached($key)
213
- {
214
- return isset(self::$_cache[$key]);
215
- }
216
-
217
- /**
218
- * Retrieve a value from the cache
219
- *
220
- * @param string $key
221
- * @param mixed $default = null
222
- * @return mixed
223
- */
224
- protected function _cached($key, $default = null)
225
- {
226
- if ($this->_isCached($key)) {
227
- return self::$_cache[$key];
228
- }
229
-
230
- return $default;
231
- }
232
-
233
- /**
234
- * Retrieve a plugin option
235
- *
236
- * @param string $plugin
237
- * @param string $key = null
238
- * @return mixed
239
- */
240
- public function getPluginOption($plugin, $key = null)
241
- {
242
- $options = $this->getWpOption($plugin);
243
-
244
- if (($data = @unserialize($options)) !== false) {
245
- if (is_null($key)) {
246
- return $data;
247
- }
248
-
249
- return isset($data[$key])
250
- ? $data[$key]
251
- : null;
252
- }
253
-
254
- return $options;
255
- }
256
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/App.php DELETED
@@ -1,538 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_App extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * App errors that occur while integrating
13
- *
14
- * @var array
15
- */
16
- protected $_errors = array();
17
-
18
- /**
19
- * DB connection with WordPress
20
- *
21
- * @var
22
- */
23
- static protected $_db = array();
24
-
25
- /**
26
- * Array of post type data
27
- *
28
- * @var array
29
- */
30
- static protected $_postTypes = array();
31
-
32
- /**
33
- * Array of taxonomy data
34
- *
35
- * @var array
36
- */
37
- static protected $_taxonomies = array();
38
-
39
- /**
40
- * Holds the current store
41
- * Determines correct store if Admin
42
- *
43
- * @var Mage_Core_Model_Store
44
- */
45
- static protected $_store = null;
46
-
47
- /**
48
- * Blog ID. This is taken from Fishpig_Wordpress_Addon_Multisite
49
- *
50
- * @var int
51
- */
52
- static protected $_blogId = 1;
53
-
54
- /**
55
- * Content taken from WordPress to be injected into Magento
56
- *
57
- * @var array
58
- */
59
- protected $_contentHolder = array();
60
-
61
- public function __construct()
62
- {
63
- /**
64
- * Setup the real store
65
- */
66
- $this->getStore();
67
-
68
- /**
69
- * Set the blog ID
70
- * This is taken from Fishpig_Wordpress_Addon_Multisite
71
- */
72
- if ($blogId = (int)Mage::getStoreConfig('wordpress/mu/blog_id', $this->getStore()->getId())) {
73
- self::$_blogId = $blogId;
74
- }
75
-
76
- /**
77
- * Initialise the DB
78
- */
79
- $this->_initDb();
80
- }
81
-
82
- /**
83
- * Initialise the post type and taxonomy data
84
- *
85
- * @return $this
86
- */
87
- public function init()
88
- {
89
- $this->_initPostTypes();
90
- $this->_initTaxonomies();
91
-
92
- return $this;
93
- }
94
-
95
- /**
96
- * Initialise the DB
97
- *
98
- * @return $this
99
- */
100
- protected function _initDb()
101
- {
102
- if (isset(self::$_db[$this->_getStoreId()]) && !is_null(self::$_db[$this->_getStoreId()])) {
103
- return $this;
104
- }
105
-
106
- self::$_db[$this->_getStoreId()] = false;
107
-
108
- /**
109
- * Before connecting to the database
110
- * Map the WordPress table names with the table prefix
111
- */
112
- $wordpressEntities = (array)Mage::app()->getConfig()->getNode()->wordpress->database->before_connect->tables;
113
- $tablePrefix = $this->getTablePrefix();
114
-
115
- foreach($wordpressEntities as $entity => $table) {
116
- Mage::getSingleton('core/resource')->setMappedTableName((string)$table->table, $tablePrefix . $table->table);
117
- }
118
-
119
- if ($this->getBlogId() > 1) {
120
- $networkTablePrefix = $this->getTablePrefix() . $this->getBlogId() . '_';
121
-
122
- $entities = (array)Mage::app()->getConfig()->getNode()->wordpress->database->before_connect->tables_mu;
123
-
124
- foreach($entities as $entity => $table) {
125
- Mage::getSingleton('core/resource')->setMappedTableName((string)$table->table, $networkTablePrefix . $table->table);
126
- }
127
- }
128
-
129
- if (!Mage::getStoreConfigFlag('wordpress/database/is_shared', $this->getStore()->getId())) {
130
- // If database not shared, connect to WP database
131
- $configs = array('model' => 'mysql4', 'active' => '1', 'host' => '', 'username' => '', 'password' => '', 'dbname' => '', 'charset' => 'utf8');
132
-
133
- foreach($configs as $key => $defaultValue) {
134
- if ($value = Mage::getStoreConfig('wordpress/database/' . $key, $this->getStore()->getId())) {
135
- $configs[$key] = $value;
136
- }
137
- }
138
-
139
- foreach(array('username', 'password', 'dbname') as $field) {
140
- if (isset($configs[$field])) {
141
- $configs[$field] = Mage::helper('core')->decrypt($configs[$field]);
142
- }
143
- }
144
-
145
- if (!isset($configs['host']) || !$configs['host']) {
146
- return $this->addError('Database host not defined.');
147
- }
148
-
149
- try {
150
- $connection = Mage::getSingleton('core/resource')->createConnection('wordpress', 'pdo_mysql', $configs);
151
-
152
- if (!is_object($connection)) {
153
- return $this;
154
- }
155
-
156
- $connection->getConnection();
157
-
158
- if (!$connection->isConnected()) {
159
- return $this->addError('Unable to connect to WordPress database.');
160
- }
161
- }
162
- catch (Exception $e) {
163
- return $this->addError($e->getMessage());
164
- }
165
-
166
- $db = $connection;
167
- }
168
- else {
169
- $db = Mage::getSingleton('core/resource')->getConnection('core_read');
170
- }
171
-
172
- try {
173
- $db->fetchOne(
174
- $db->select()->from(Mage::getSingleton('core/resource')->getTableName('wordpress/post'), 'ID')->limit(1)
175
- );
176
- }
177
- catch (Exception $e) {
178
- return $this->addError($e->getMessage())
179
- ->addError(sprintf('Unable to query WordPress database. Is the table prefix (%s) correct?', $tablePrefix));
180
- }
181
-
182
- $db->query('SET NAMES UTF8');
183
-
184
- $wordpressEntities = (array)Mage::app()->getConfig()->getNode()->wordpress->database->after_connect->tables;
185
-
186
- foreach($wordpressEntities as $entity => $table) {
187
- Mage::getSingleton('core/resource')->setMappedTableName((string)$table->table, $tablePrefix . $table->table);
188
- }
189
-
190
- self::$_db[$this->_getStoreId()] = $db;
191
-
192
- return $this;
193
- }
194
-
195
- /**
196
- * Initialise the post type data
197
- *
198
- * @return $this
199
- */
200
- protected function _initPostTypes()
201
- {
202
- if (isset(self::$_postTypes[$this->_getStoreId()]) && !is_null(self::$_postTypes[$this->_getStoreId()])) {
203
- return $this;
204
- }
205
-
206
- self::$_postTypes[$this->_getStoreId()] = false;
207
-
208
- $transportObject = new Varien_Object(array('post_types' => false));
209
-
210
- Mage::dispatchEvent('wordpress_app_init_post_types', array('transport' => $transportObject, 'helper' => $this));
211
-
212
- if ($transportObject->getPostTypes()) {
213
- self::$_postTypes[$this->_getStoreId()] = $transportObject->getPostTypes();
214
- }
215
- else {
216
- self::$_postTypes[$this->_getStoreId()] = array(
217
- 'post' => Mage::getModel('wordpress/post_type')->setData(array(
218
- 'post_type' => 'post',
219
- 'rewrite' => array('slug' => $this->getWpOption('permalink_structure')),
220
- 'taxonomies' => array('category', 'post_tag'),
221
- '_builtin' => true,
222
- )),
223
- 'page' => Mage::getModel('wordpress/post_type')->setData(array(
224
- 'post_type' => 'page',
225
- 'rewrite' => array('slug' => '%postname%/'),
226
- 'hierarchical' => true,
227
- 'taxonomies' => array(),
228
- '_builtin' => true,
229
- ))
230
- );
231
- }
232
-
233
- $transportObject = new Varien_Object(array('post_types' => self::$_postTypes[$this->_getStoreId()]));
234
-
235
- Mage::dispatchEvent('wordpress_app_init_post_types_after', array('transport' => $transportObject, 'helper' => $this));
236
-
237
- self::$_postTypes[$this->_getStoreId()] = $transportObject->getPostTypes();
238
-
239
- return $this;
240
- }
241
-
242
- /**
243
- * Get the DB connection
244
- *
245
- * @return
246
- */
247
- public function getDbConnection()
248
- {
249
- $this->_initDb();
250
-
251
- return self::$_db[$this->_getStoreId()];
252
- }
253
-
254
- /**
255
- * Get the post type array
256
- *
257
- * @return array
258
- */
259
- public function getPostTypes()
260
- {
261
- $this->init();
262
-
263
- return self::$_postTypes[$this->_getStoreId()];
264
- }
265
-
266
- /**
267
- * Get a single post type
268
- *
269
- * @param string $type
270
- * @return Fishpig_Wordpress_Model_Post_Type|false
271
- */
272
- public function getPostType($type)
273
- {
274
- $this->init();
275
-
276
- return isset(self::$_postTypes[$this->_getStoreId()][$type])
277
- ? self::$_postTypes[$this->_getStoreId()][$type]
278
- : false;
279
- }
280
-
281
- /**
282
- * Get the taxonomy array
283
- *
284
- * @return array
285
- */
286
- public function getTaxonomies()
287
- {
288
- $this->init();
289
-
290
- return self::$_taxonomies[$this->_getStoreId()];
291
- }
292
-
293
- /**
294
- * Get a taxonomy
295
- *
296
- * @param string $taxonomy
297
- * @return Fishpig_Wordpress_Model_Term_Taxonomy|false
298
- */
299
- public function getTaxonomy($taxonomy)
300
- {
301
- $this->init();
302
-
303
- return isset(self::$_taxonomies[$this->_getStoreId()][$taxonomy])
304
- ? self::$_taxonomies[$this->_getStoreId()][$taxonomy]
305
- : false;
306
- }
307
-
308
- /**
309
- * Initialise the taxonomy data
310
- *
311
- * @return $this
312
- */
313
- protected function _initTaxonomies()
314
- {
315
- if (isset(self::$_taxonomies[$this->_getStoreId()]) && !is_null(self::$_taxonomies[$this->_getStoreId()])) {
316
- return $this;
317
- }
318
-
319
- self::$_taxonomies[$this->_getStoreId()] = false;
320
-
321
- $transportObject = new Varien_Object(array('taxonomies' => false));
322
-
323
- Mage::dispatchEvent('wordpress_app_init_taxonomies', array('transport' => $transportObject));
324
-
325
- if ($transportObject->getTaxonomies()) {
326
- self::$_taxonomies[$this->_getStoreId()] = $transportObject->getTaxonomies();
327
- }
328
- else {
329
- $blogPrefix = Mage::helper('wordpress')->isWordPressMU()
330
- && Mage::helper('wp_addon_multisite')->canRun()
331
- && Mage::helper('wp_addon_multisite')->isDefaultBlog();
332
-
333
- $bases = array(
334
- 'category' => Mage::helper('wordpress')->getWpOption('category_base'),
335
- 'post_tag' => Mage::helper('wordpress')->getWpOption('tag_base'),
336
- );
337
-
338
- foreach($bases as $baseType => $base) {
339
- if ($blogPrefix && $base && strpos($base, '/blog') === 0) {
340
- $bases[$baseType] = substr($base, strlen('/blog'));
341
- }
342
- }
343
-
344
- self::$_taxonomies[$this->_getStoreId()] = array(
345
- 'category' => Mage::getModel('wordpress/term_taxonomy')->setData(array(
346
- 'type' => 'category',
347
- 'taxonomy_type' => 'category',
348
- 'labels' => array(
349
- 'name' => 'Categories',
350
- 'singular_name' => 'Category',
351
- ),
352
- 'public' => true,
353
- 'hierarchical' => true,
354
- 'rewrite' => array(
355
- 'hierarchical' => true,
356
- 'slug' => $bases['category'],
357
- ),
358
- '_builtin' => true,
359
- )),
360
- 'post_tag' => Mage::getModel('wordpress/term_taxonomy')->setData(array(
361
- 'type' => 'post_tag',
362
- 'taxonomy_type' => 'post_tag',
363
- 'labels' => array(
364
- 'name' => 'Tags',
365
- 'singular_name' => 'Tag',
366
- ),
367
- 'public' => true,
368
- 'hierarchical' => false,
369
- 'rewrite' => array(
370
- 'slug' => $bases['post_tag'],
371
- ),
372
- '_builtin' => true,
373
- ))
374
- );
375
- }
376
-
377
- if (isset(self::$_taxonomies[$this->_getStoreId()]['category'])) {
378
- $helper = Mage::helper('wordpress');
379
-
380
- $canRemoveCategoryPrefix = $helper->isPluginEnabled('wp-no-category-base/no-category-base.php')
381
- || $helper->isPluginEnabled('wp-remove-category-base/wp-remove-category-base.php')
382
- || $helper->isPluginEnabled('remove-category-url/remove-category-url.php')
383
- || Mage::helper('wp_addon_wordpressseo')->canRemoveCategoryBase();
384
-
385
- if ($canRemoveCategoryPrefix) {
386
- self::$_taxonomies[$this->_getStoreId()]['category']->setSlug('');
387
- }
388
- }
389
-
390
- $transportObject = new Varien_Object(array('taxonomies' => self::$_taxonomies[$this->_getStoreId()]));
391
-
392
- Mage::dispatchEvent('wordpress_app_init_taxonomies_after', array('transport' => $transportObject, 'helper' => $this));
393
-
394
- self::$_taxonomies[$this->_getStoreId()] = $transportObject->getTaxonomies();
395
-
396
- return $this;
397
- }
398
-
399
- /*
400
- * Returns the table prefix used by Wordpress
401
- *
402
- * @return string
403
- */
404
- public function getTablePrefix()
405
- {
406
- return Mage::getStoreConfig('wordpress/database/table_prefix', $this->getStore()->getId());
407
- }
408
-
409
- /**
410
- * Get the blog ID
411
- *
412
- * @return int
413
- */
414
- public function getBlogId()
415
- {
416
- return self::$_blogId;
417
- }
418
-
419
- /**
420
- * Add an error message to the inernal errors array
421
- *
422
- * @param string $msg
423
- * @return $this
424
- */
425
- public function addError($msg)
426
- {
427
- $this->_errors[] = $msg;
428
-
429
- return $this;
430
- }
431
-
432
- /**
433
- * Get a table name
434
- *
435
- * @param string $entity
436
- * @return string
437
- */
438
- public function getTableName($entity)
439
- {
440
- return Mage::getSingleton('core/resource')->getTableName($entity);
441
- }
442
-
443
- /**
444
- * Get the current store
445
- *
446
- * @return Mage_Core_Model_Store
447
- */
448
- public function getStore()
449
- {
450
- if (isset(self::$_store[$this->_getStoreId()]) && self::$_store[$this->_getStoreId()] === false) {
451
- return Mage::app()->getStore();
452
- }
453
-
454
- self::$_store[$this->_getStoreId()] = Mage::app()->getStore();
455
-
456
- if (Mage::app()->getStore()->getCode() === 'admin') {
457
- $storeValue = Mage::app()->getRequest()->getParam('store', false);
458
-
459
- $store = Mage::getModel('core/store')->load($storeValue, (int)$storeValue > 0 ? null : 'code');
460
-
461
- if ($store->getId()) {
462
- self::$_store[$this->_getStoreId()] = $store;
463
- }
464
- else {
465
- self::$_store[$this->_getStoreId()] = $this->getDefaultStore(Mage::app()->getRequest()->getParam('website', null));
466
- }
467
-
468
- if (!self::$_store[$this->_getStoreId()]) {
469
- self::$_store[$this->_getStoreId()] = Mage::app()->getStore();
470
- }
471
- }
472
-
473
- return self::$_store[$this->_getStoreId()];
474
- }
475
-
476
- /**
477
- * Add content from WP to the Magento footer
478
- *
479
- * @param string $content
480
- * @return $this
481
- */
482
- public function addWordPressContentToFooter($content)
483
- {
484
- if (!is_array($content)) {
485
- if ($content === false || $content === '') {
486
- return $this;
487
- }
488
- }
489
- else {
490
- $content = implode("\n", $content);
491
- }
492
-
493
- $key = md5(trim($content));
494
-
495
- if (!isset($this->_contentHolder[$key])) {
496
- $this->_contentHolder[$key] = $content;
497
- }
498
-
499
- return $this;
500
- }
501
-
502
- /**
503
- * Get the WordPress content
504
- *
505
- * @return bool|string
506
- **/
507
- public function getWordPressContent()
508
- {
509
- if (count($this->_contentHolder) === 0) {
510
- return false;
511
- }
512
-
513
- $content = $this->_contentHolder;
514
- $head = $this->getLayout()->getBlock('head');
515
- $jsTemplate = '<script type="text/javascript" src="%s"></script>';
516
-
517
- if (!$head || strpos(implode(',', array_keys($head->getItems())), 'jquery') === false) {
518
- if (!$head || strpos(implode(',', array_keys($headBlock->getItems())), 'underscore') === false) {
519
- array_shift($content, sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/underscore.min.js?ver=1.6.0')));
520
- }
521
-
522
- array_shift($content, sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1')));
523
- array_shift($content, sprintf($jsTemplate, $helper->getBaseUrl('wp-includes/js/jquery/jquery.js?ver=1.11.3')));
524
- }
525
-
526
- return implode("\n", $content);
527
- }
528
-
529
- /**
530
- * Get the currently set store ID
531
- *
532
- * @return int
533
- **/
534
- protected function _getStoreId()
535
- {
536
- return (int)Mage::app()->getStore()->getId();
537
- }
538
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Associations.php DELETED
@@ -1,549 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Associations extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- public function isConnected()
12
- {
13
- return Mage::helper('wordpress/app')->getDbConnection() !== false;
14
- }
15
-
16
- /**
17
- * Retrieve a collection of post's associated with the given product
18
- *
19
- * @param Mage_Catalog_Model_Product $product
20
- * @return false|Fishpig_Wordpress_Model_Resource_Post_Collection
21
- */
22
- public function getAssociatedPostsByProduct(Mage_Catalog_Model_Product $product)
23
- {
24
- if (!$this->isConnected() || !($product instanceof Mage_Catalog_Model_Product)) {
25
- return false;
26
- }
27
-
28
- $associations = array_keys($this->getAssociations('product/post', $product->getId()));
29
- $categoryAssociations = array_keys($this->getAssociations('product/category', $product->getId()));
30
- $associations = array_merge($associations, $this->_convertWpCategoryIds($categoryAssociations));
31
-
32
- foreach($product->getCategoryIds() as $categoryId) {
33
- $associations = array_merge($associations, array_keys($this->getAssociations('category/post', $categoryId)));
34
- $categoryAssociations = array_keys($this->getAssociations('category/category', $categoryId));
35
- $associations = array_merge($associations, $this->_convertWpCategoryIds($categoryAssociations));
36
- }
37
-
38
- if (count($associations) > 0) {
39
- return Mage::getResourceModel('wordpress/post_collection')
40
- ->addFieldToFilter('ID', array('IN' => $associations))
41
- ->addIsViewableFilter();
42
- }
43
-
44
- return false;
45
- }
46
-
47
- /**
48
- * Retrieve a collection of post's associated with the given product
49
- *
50
- * @param Mage_Cms_Model_Page $page
51
- * @return false|Fishpig_Wordpress_Model_Resource_Post_Collection
52
- */
53
- public function getAssociatedPostsByCmsPage(Mage_Cms_Model_Page $page)
54
- {
55
- if (!$this->isConnected() || !($page instanceof Mage_Cms_Model_Page)) {
56
- return false;
57
- }
58
-
59
- $associations = array_keys($this->getAssociations('cms_page/post', $page->getId(), 0));
60
- $categoryAssociations = array_keys($this->getAssociations('cms_page/category', $page->getId(), 0));
61
- $associations = array_merge($associations, $this->_convertWpCategoryIds($categoryAssociations));
62
-
63
- if (count($associations) > 0) {
64
- return Mage::getResourceModel('wordpress/post_collection')
65
- ->addFieldToFilter('ID', array('IN' => $associations))
66
- ->addIsViewableFilter();
67
- }
68
-
69
- return false;
70
- }
71
-
72
- /**
73
- * Retrieve a collection of products assocaited with the post
74
- *
75
- * @param Fishpig_Wordpress_Model_Post $post
76
- * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
77
- */
78
- public function getAssociatedProductsByPost(Fishpig_Wordpress_Model_Post $post)
79
- {
80
- if (!$this->isConnected() || !($post instanceof Fishpig_Wordpress_Model_Post)) {
81
- return false;
82
- }
83
-
84
- $associations = array_keys($this->getReverseAssociations('product/post', $post->getId()));
85
-
86
- foreach($post->getParentCategories() as $category) {
87
- $associations = array_merge($associations, array_keys($this->getReverseAssociations('product/category', $category->getId())));
88
- }
89
-
90
- $associations = array_unique($associations);
91
-
92
- if (count($associations) > 0) {
93
- $collection = Mage::getResourceModel('catalog/product_collection');
94
-
95
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
96
-
97
- if (!Mage::getStoreConfigFlag('cataloginventory/options/show_out_of_stock')) {
98
- Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
99
- }
100
-
101
- $collection->addAttributeToFilter('status', 1);
102
- $collection->addAttributeToFilter('entity_id', array('in' => $associations));
103
-
104
-
105
- return $collection;
106
- }
107
-
108
- return false;
109
- }
110
-
111
- /**
112
- * Retrieve an array of associated ID's and their position value
113
- *
114
- * @param string $type
115
- * @param int $objectId
116
- * @param int|null $storeId = null
117
- * @return array|false
118
- */
119
- public function getAssociations($type, $objectId, $storeId = null)
120
- {
121
- return $this->_getAssociations($type, $objectId, $storeId, 'object_id', 'wordpress_object_id');
122
- }
123
-
124
- /**
125
- * Retrieve an array of associated ID's and their position value
126
- * This receives a post ID and returns the associated Magento product ID's
127
- *
128
- * @param string $type
129
- * @param int $objectId
130
- * @param int|null $storeId = null
131
- * @return array
132
- */
133
- public function getReverseAssociations($type, $objectId, $storeId = null)
134
- {
135
- return $this->_getAssociations($type, $objectId, $storeId, 'wordpress_object_id', 'object_id');
136
- }
137
-
138
- /**
139
- * Retrieve an array of associated ID's and their position value
140
- *
141
- * @param string $type
142
- * @param int $objectId
143
- * @param int|null $storeId = null
144
- * @return array
145
- */
146
- protected function _getAssociations($type, $objectId, $storeId = null, $filter, $return)
147
- {
148
- try {
149
- if (($typeId = $this->getTypeId($type)) !== false) {
150
- if (is_null($storeId)) {
151
- $storeId = Mage::app()->getStore()->getId();
152
- }
153
-
154
- $select = $this->_getReadAdapter()
155
- ->select()
156
- ->from($this->_getTable('wordpress/association'), array($return, 'position'))
157
- ->where('type_id=?', $typeId)
158
- ->where($filter . '=?', $objectId)
159
- ->where('store_id=?', $storeId)
160
- ->order('position ASC');
161
-
162
- if (($results = $this->_getReadAdapter()->fetchAll($select)) !== false) {
163
- $associations = array();
164
-
165
- foreach($results as $result) {
166
- $associations[$result[$return]] = $result['position'];
167
- }
168
-
169
- return $associations;
170
- }
171
- }
172
- }
173
- catch (Exception $e) {
174
- $this->log($e);
175
- }
176
-
177
- return array();
178
- }
179
-
180
- /**
181
- * Delete all associations for a type/object_id/store combination
182
- *
183
- * @param string $type
184
- * @param int $objectId
185
- * @param int|null $storeId = null
186
- * @return $this
187
- */
188
- public function deleteAssociations($type, $objectId, $storeId = null)
189
- {
190
- if (($typeId = $this->getTypeId($type)) !== false) {
191
- if (is_null($storeId)) {
192
- $storeId = Mage::app()->getStore()->getId();
193
- }
194
-
195
- $write = $this->_getWriteAdapter();
196
- $table = $this->_getTable('wordpress/association');
197
-
198
- $cond = implode(' AND ', array(
199
- $write->quoteInto('object_id=?', $objectId),
200
- $write->quoteInto('type_id=?', $typeId),
201
- $write->quoteInto('store_id=?', $storeId),
202
- ));
203
-
204
- $write->delete($table, $cond, $storeId);
205
- $write->commit();
206
- }
207
-
208
- return $this;
209
- }
210
-
211
- /**
212
- * Create associations
213
- *
214
- * @param string $type
215
- * @param int $objectId
216
- * @param array $associations
217
- * @param int|null $storeId = null
218
- * @return $this
219
- */
220
- public function createAssociations($type, $objectId, array $associations, $storeId = null)
221
- {
222
- if (count($associations) === 0) {
223
- return $this;
224
- }
225
-
226
- if (($typeId = $this->getTypeId($type)) !== false) {
227
- if (is_null($storeId)) {
228
- $storeId = Mage::app()->getStore()->getId();
229
- }
230
-
231
- $write = $this->_getWriteAdapter();
232
- $table = $this->_getTable('wordpress/association');
233
-
234
- foreach($associations as $wpObjectId => $data) {
235
- if (is_array($data)) {
236
- $position = array_shift($data);
237
- }
238
- else {
239
- $position = 0;
240
- $wpObjectId = $data;
241
- }
242
-
243
- $write->insert($table, array(
244
- 'type_id' => $typeId,
245
- 'object_id' => $objectId,
246
- 'wordpress_object_id' => $wpObjectId,
247
- 'position' => $position,
248
- 'store_id' => $storeId,
249
- ));
250
-
251
- $write->commit();
252
- }
253
- }
254
-
255
- return $this;
256
- }
257
-
258
- /**
259
- * Process an observer triggered to save associations
260
- * This only works for certain models
261
- *
262
- * @param Varien_Event_Observer $observer
263
- * @return bool
264
- */
265
- public function processObserver(Varien_Event_Observer $observer)
266
- {
267
- $storeIds = $this->getAssociationStoreIds();
268
-
269
- if (($product = $observer->getEvent()->getProduct()) !== null) {
270
- $objectId = $product->getId();
271
- }
272
- else if (($category = $observer->getEvent()->getCategory()) !== null) {
273
- $objectId = $category->getId();
274
- }
275
- else if ($observer->getEvent()->getObject() instanceof Mage_Cms_Model_Page) {
276
- $objectId = $observer->getEvent()->getObject()->getId();
277
- $storeIds = array(0);
278
- }
279
- else {
280
- return false;
281
- }
282
-
283
- $post = Mage::app()->getRequest()->getPost('wp');
284
-
285
- if (!isset($post['assoc'])) {
286
- return false;
287
- }
288
-
289
- $assocData = $post['assoc'];
290
-
291
- foreach($assocData as $object => $data) {
292
- foreach($data as $wpObject => $associations) {
293
- $associations = Mage::helper('adminhtml/js')->decodeGridSerializedInput($associations);
294
- $type = $object . '/' . $wpObject;
295
-
296
- foreach($storeIds as $storeId) {
297
- $this->deleteAssociations($type, $objectId, $storeId)
298
- ->createAssociations($type, $objectId, $associations, $storeId);
299
- }
300
- }
301
- }
302
- }
303
-
304
- /**
305
- * Retrieve a type_id associated with the given type
306
- *
307
- * @param string $type
308
- * @return int|false
309
- */
310
- public function getTypeId($type)
311
- {
312
- if (strpos($type, '/') !== false) {
313
- $types = explode('/', $type);
314
-
315
- $select = $this->_getReadAdapter()
316
- ->select()
317
- ->from($this->_getTable('wordpress/association_type'), 'type_id')
318
- ->where('object=?', $types[0])
319
- ->where('wordpress_object=?', $types[1])
320
- ->limit(1);
321
-
322
- return $this->_getReadAdapter()->fetchOne($select);
323
- }
324
-
325
- return false;
326
- }
327
-
328
- /**
329
- * Add the position value for the association between each item and the $type and $objectId
330
- * combination
331
- *
332
- * @param $collection
333
- * @param string $type
334
- * @param int $objectId
335
- * @return $this
336
- */
337
- public function addRelatedPositionToSelect($collection, $type, $objectId, $storeId = null)
338
- {
339
- if (($typeId = Mage::helper('wordpress/associations')->getTypeId($type)) !== false) {
340
- if (is_null($storeId)) {
341
- $storeId = array((int)Mage::app()->getStore()->getId(), 0);
342
- }
343
- else if (!is_array($storeId)) {
344
- $storeId = array($storeId, 0);
345
- }
346
-
347
- $field = strpos($type, '/category') !== false ? 'term_id' : 'ID';
348
-
349
- $cond = implode(' AND ', array(
350
- '`assoc`.`wordpress_object_id` = `main_table`.`' . $field . '`',
351
- '`assoc`.`object_id` = ' . (int)$objectId,
352
- '`assoc`.`type_id` = ' . (int)$typeId,
353
- Mage::getSingleton('core/resource')->getConnection('core_read')->quoteInto('`assoc`.`store_id` IN (?)', $storeId),
354
- ));
355
-
356
- $dbname = $this->_getTable('wordpress/association');
357
-
358
- if (!Mage::getStoreConfigFlag('wordpress/database/is_shared')) {
359
- $dbname = (string)Mage::getConfig()->getNode('global/resources/default_setup/connection/dbname') . '.' . $dbname;
360
- }
361
-
362
- $collection->getSelect()
363
- ->distinct()
364
- ->joinLeft(
365
- array('assoc' => $dbname),
366
- $cond,
367
- array('associated_position' => 'IF(ISNULL(position), 4444, position)', 'is_associated' => 'IF(ISNULL(assoc.position), 0, 1)')
368
- );
369
-
370
- $collection->getSelect()->order('assoc.store_id DESC');
371
- }
372
-
373
- return $this;
374
- }
375
-
376
- /**
377
- * Retrieve the current store ID
378
- * If no store ID is set or site is multistore, return default store ID
379
- *
380
- * @return int
381
- */
382
- public function getAssociationStoreIds()
383
- {
384
- $singleStore = Mage::app()->isSingleStoreMode() && Mage::helper('wordpress')->forceSingleStore();
385
-
386
- if (!$singleStore && ($storeId = (int)Mage::app()->getRequest()->getParam('store'))) {
387
- return array($storeId);
388
- }
389
-
390
- $select = $this->_getReadAdapter()
391
- ->select()
392
- ->from($this->_getTable('core/store'), 'store_id')
393
- ->where('store_id>?', 0);
394
-
395
- return $this->_getReadAdapter()->fetchCol($select);
396
- }
397
-
398
- /**
399
- * Retrieve a single store ID
400
- *
401
- * @return int
402
- */
403
- public function getSingleStoreId()
404
- {
405
- $storeIds = $this->getAssociationStoreIds();
406
-
407
- if (is_array($storeIds)) {
408
- return (int)array_shift($storeIds);
409
- }
410
-
411
- return (int)$storeIds;
412
- }
413
-
414
- /**
415
- * Convert an array of WordPress category ID's to
416
- * an array of post ID's
417
- *
418
- * @param array $categoryIds
419
- * @return array
420
- */
421
- protected function _convertWpCategoryIds(array $categoryIds)
422
- {
423
- if (count($categoryIds) === 0) {
424
- return array();
425
- }
426
-
427
- $select = $this->_getReadAdapter()
428
- ->select()
429
- ->from(array('term' => $this->_getTable('wordpress/term')), '')
430
- ->where('term.term_id IN (?)', $categoryIds);
431
-
432
- $select->join(
433
- array('tax' => $this->_getTable('wordpress/term_taxonomy')),
434
- "`tax`.`term_id` = `term`.`term_id` AND `tax`.`taxonomy`= 'category'",
435
- ''
436
- );
437
-
438
- $select->join(
439
- array('rel' => $this->_getTable('wordpress/term_relationship')),
440
- "`rel`.`term_taxonomy_id` = `tax`.`term_taxonomy_id`",
441
- 'object_id'
442
- );
443
-
444
- return Mage::helper('wordpress/app')->getDbConnection()->fetchCol($select);
445
- }
446
-
447
- /**
448
- * Retrieve the read DB adapter
449
- *
450
- * @return
451
- */
452
- protected function _getReadAdapter()
453
- {
454
- return Mage::getSingleton('core/resource')->getConnection('core_read');
455
- }
456
-
457
- /**
458
- * Retrieve the write DB adapter
459
- *
460
- * @return
461
- */
462
- protected function _getWriteAdapter()
463
- {
464
- return Mage::getSingleton('core/resource')->getConnection('core_write');
465
- }
466
-
467
- /**
468
- * Retrieve a table name by entity
469
- *
470
- * @param string $entity
471
- * @return string
472
- */
473
- protected function _getTable($entity)
474
- {
475
- return Mage::getSingleton('core/resource')->getTableName($entity);
476
- }
477
-
478
- /**
479
- * Ensure association tables are installed
480
- *
481
- * @return $this
482
- */
483
- public function checkForTables()
484
- {
485
- $resource = Mage::getSingleton('core/resource');
486
- $write = $resource->getConnection('core_write');
487
- $read = $resource->getConnection('core_read');
488
-
489
- $associationTypeTable = $resource->getTableName('wordpress/association_type');
490
- $associationTable = $resource->getTableName('wordpress/association');
491
-
492
- $tables = array(
493
- $associationTypeTable => "CREATE TABLE IF NOT EXISTS %s (
494
- `type_id` int(11) unsigned NOT NULL auto_increment,
495
- `object` varchar(16) NOT NULL default '',
496
- `wordpress_object` varchar(16) NOT NULL default '',
497
- PRIMARY KEY(type_id)
498
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;",
499
- $associationTable => "CREATE TABLE IF NOT EXISTS %s (
500
- `assoc_id` int(11) unsigned NOT NULL auto_increment,
501
- `type_id` int(3) unsigned NOT NULL default 0,
502
- `object_id` int(11) unsigned NOT NULL default 0,
503
- `wordpress_object_id` int(11) unsigned NOT NULL default 0,
504
- `position` int(4) unsigned NOT NULL default 4444,
505
- `store_id` smallint(5) unsigned NOT NULL default 0,
506
- PRIMARY KEY (`assoc_id`),
507
- CONSTRAINT `FK_WP_ASSOC_TYPE_ID_WP_ASSOC_TYPE` FOREIGN KEY (`type_id`) REFERENCES `{$associationTypeTable}` (`type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
508
- KEY `FK_WP_ASSOC_TYPE_ID_WP_ASSOC_TYPE` (`type_id`),
509
- KEY `FK_STORE_ID_WP_ASSOC` (`store_id`),
510
- CONSTRAINT `FK_STORE_ID_WP_ASSOC` FOREIGN KEY (`store_id`) REFERENCES `{$resource->getTableName('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
511
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
512
- ");
513
-
514
- $missingTables = false;
515
-
516
- foreach($tables as $table => $createSql) {
517
- try {
518
- $read->fetchOne($read->select()->from($table)->limit(1));
519
- }
520
- catch (Exception $e) {
521
- $missingTables = true;
522
- $write->query(sprintf($createSql, $table));
523
- }
524
- }
525
-
526
- if ($missingTables) {
527
- $types = array(
528
- 1 => array('product', 'post'),
529
- 2 => array('product', 'category'),
530
- 3 => array('category', 'post'),
531
- 4 => array('category', 'category'),
532
- 5 => array('cms_page', 'post'),
533
- 6 => array('cms_page', 'category'),
534
- );
535
-
536
- $select = $read->select()
537
- ->from($associationTypeTable, 'type_id')
538
- ->limit(1);
539
-
540
- if (!$read->fetchOne($select)) {
541
- foreach($types as $typeId => $data) {
542
- $write->query(sprintf("INSERT INTO %s VALUES (%d, '%s', '%s');\n", $associationTypeTable, $typeId, $data[0], $data[1]));
543
- }
544
- }
545
- }
546
-
547
- return $this;
548
- }
549
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Catalog/Product.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Catalog_Product extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Returns a collection of Wordpress posts that have been
13
- * associated with the given product
14
- *
15
- * @param Mage_Catalog_Model_Product $product
16
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
17
- */
18
- public function getAssociatedPosts($product)
19
- {
20
- if ($product instanceof Mage_Catalog_Model_Product) {
21
- $postIds = $this->getAssociatedPostIds($product);
22
- $categoryIds = $this->getAssociatedCategoryIds($product);
23
-
24
- if (count($postIds) > 0 || count($categoryIds) > 0) {
25
- $collection = Mage::getResourceModel('wordpress/post_collection')->addIsViewableFilter();
26
- $collection->getSelect()->distinct();
27
- $collection->addCategoryAndPostIdFilter($postIds, $categoryIds);
28
- $collection->setOrderByPostDate();
29
-
30
- return $collection;
31
- }
32
- }
33
-
34
- return false;
35
- }
36
-
37
- /**
38
- * Retrieve an array of post_ids that are associated with the product
39
- *
40
- * @param Mage_Catalog_Model_Product $product
41
- * @return array
42
- */
43
- public function getAssociatedPostIds(Mage_Catalog_Model_Product $product)
44
- {
45
- $postIds = $this->_getAssociatedWpEntityIds($product->getId(), 'post', 'post');
46
-
47
- if ($categoryIds = $product->getCategoryIds()) {
48
- foreach($categoryIds as $categoryId) {
49
- $postIds = array_merge($postIds, $this->_getAssociatedWpEntityIds($categoryId, 'post', 'post', 'category_id', 'category'));
50
- }
51
- }
52
-
53
- return array_unique($postIds);
54
- }
55
-
56
- /**
57
- * Retrieve an array of category_ids that are associated with the product
58
- *
59
- * @param Mage_Catalog_Model_Product $product
60
- * @return array
61
- */
62
- public function getAssociatedCategoryIds(Mage_Catalog_Model_Product $product)
63
- {
64
- $wpCategoryIds = $this->_getAssociatedWpEntityIds($product->getId(), 'category', 'category');
65
-
66
- if ($categoryIds = $product->getCategoryIds()) {
67
- foreach($categoryIds as $categoryId) {
68
- $wpCategoryIds = array_merge($wpCategoryIds, $this->_getAssociatedWpEntityIds($categoryId, 'wp_category', 'category', 'category_id', 'category'));
69
- }
70
- }
71
-
72
- return array_unique($wpCategoryIds);
73
- }
74
-
75
- /**
76
- * Retrieve an array of category_ids/post_ids that are associated with the product
77
- *
78
- * @return array
79
- */
80
- protected function _getAssociatedWpEntityIds($id, $field, $table, $fieldToMatch = 'product_id', $magentoEntity = 'product')
81
- {
82
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
83
- $select = $read->select()
84
- ->distinct(true)
85
- ->from(Mage::getSingleton('core/resource')->getTableName('wordpress_' . $magentoEntity . '_' . $table), "{$field}_id")
86
- ->where("{$fieldToMatch} = ?", $id)
87
- ->where('store_id=?', Mage::app()->getStore()->getId());
88
-
89
- return $read->fetchCol($select);
90
- }
91
-
92
- /**
93
- * Retrieve a collection of products assocaited with the post
94
- *
95
- * @param Fishpig_Wordpress_Model_Post $post
96
- * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
97
- */
98
- public function getAssociatedProducts($post)
99
- {
100
- if ($post instanceof Fishpig_Wordpress_Model_Post) {
101
- $productIds = $this->_getAssociatedWpEntityIds($post->getId(), 'product', 'post', 'post_id');
102
-
103
- try {
104
- foreach($post->getParentCategories() as $category) {
105
- $productIds = array_merge($productIds, $this->_getAssociatedWpEntityIds($category->getId(), 'product', 'category', 'category_id'));
106
- }
107
- }
108
- catch (Exception $e) {
109
- $this->log($e->getMessage());
110
- }
111
-
112
- if (count($productIds) > 0) {
113
- $collection = Mage::getResourceModel('catalog/product_collection');
114
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
115
- $collection->addAttributeToFilter('status', 1);
116
- $collection->addAttributeToFilter('entity_id', array('in' => $productIds));
117
-
118
- return $collection;
119
- }
120
- }
121
-
122
- return false;
123
- }
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Data.php DELETED
@@ -1,408 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Data extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Retrieve the top link URL
13
- *
14
- * @return false|string
15
- */
16
- public function getTopLinkUrl()
17
- {
18
- try {
19
- if ($this->isEnabled()) {
20
- if ($this->isFullyIntegrated()) {
21
- if ($this->_isCached('toplink_url')) {
22
- return $this->_cached('toplink_url');
23
- }
24
-
25
- $transport = new Varien_Object(array('toplink_url' => $this->getUrl()));
26
-
27
- Mage::dispatchEvent('wordpress_get_toplink_url', array('transport' => $transport));
28
-
29
- $this->_cache('toplink_url', $transport->getToplinkUrl());
30
-
31
- return $transport->getToplinkUrl();
32
- }
33
-
34
- return $this->getWpOption('home');
35
- }
36
- }
37
- catch (Exception $e) {
38
- $this->log('Magento & WordPress are not correctly integrated (see entry below).');
39
- $this->log($e->getMessage());
40
- }
41
-
42
- return false;
43
- }
44
-
45
- /**
46
- * Retrieve the position for the top link
47
- *
48
- * @return false|int
49
- */
50
- public function getTopLinkPosition()
51
- {
52
- if ($this->isEnabled()) {
53
- return (int)Mage::getStoreConfig('wordpress/toplink/position');
54
- }
55
-
56
- return false;
57
- }
58
-
59
- /**
60
- * Returns the label for the top link
61
- * This is also used for the breadcrumb
62
- *
63
- * @return false|string
64
- */
65
- public function getTopLinkLabel()
66
- {
67
- if ($this->isEnabled()) {
68
- if ($this->_isCached('toplink_label')) {
69
- return $this->_cached('toplink_label');
70
- }
71
-
72
- $transport = new Varien_Object(array('toplink_label' => Mage::getStoreConfig('wordpress/toplink/label')));
73
-
74
- Mage::dispatchEvent('wordpress_get_toplink_label', array('transport' => $transport));
75
-
76
- $this->_cache('toplink_label', $transport->getToplinkLabel());
77
-
78
- return $transport->getToplinkLabel();
79
- }
80
-
81
- return false;
82
- }
83
-
84
- /**
85
- * Returns the pretty version of the blog route
86
- * This is deprecated. Instead, use self::getTopLinkLabel
87
- *
88
- * @return false|string
89
- */
90
- public function getPrettyBlogRoute()
91
- {
92
- return $this->getTopLinkLabel();
93
- }
94
-
95
- /**
96
- * Returns the URL Wordpress is installed on
97
- *
98
- * @param string $extra
99
- * @return string
100
- */
101
- public function getBaseUrl($extra = '')
102
- {
103
- return rtrim($this->getWpOption('siteurl'), '/') . '/' . $extra;
104
- }
105
-
106
- /**
107
- * Get Wordpress Admin URL
108
- *
109
- */
110
- public function getAdminUrl($extra = null)
111
- {
112
- return $this->getBaseUrl('wp-admin/' . $extra);
113
- }
114
-
115
- /**
116
- * Returns the given string prefixed with the Wordpress table prefix
117
- *
118
- * @return string
119
- */
120
- public function getTableName($table)
121
- {
122
- return Mage::getSingleton('core/resource')->getTableName($table);
123
- }
124
-
125
- /**
126
- * Determine whether the module is enabled
127
- * This can be changed by going to System > Configuration > Advanced
128
- *
129
- * @return bool
130
- */
131
- public function isEnabled()
132
- {
133
- return Mage::getStoreConfigFlag('wordpress/module/enabled', Mage::helper('wordpress/app')->getStore()->getId())
134
- && !Mage::getStoreConfig('advanced/modules_disable_output/Fishpig_Wordpress', Mage::helper('wordpress/app')->getStore()->getId());
135
- }
136
-
137
- /**
138
- * Formats a Wordpress date string
139
- *
140
- */
141
- public function formatDate($date, $format = null, $f = false)
142
- {
143
- if ($format == null) {
144
- $format = $this->getDefaultDateFormat();
145
- }
146
-
147
- /**
148
- * This allows you to translate month names rather than whole date strings
149
- * eg. "March","Mars"
150
- *
151
- */
152
- $len = strlen($format);
153
- $out = '';
154
-
155
- for( $i = 0; $i < $len; $i++) {
156
- $out .= $this->__(Mage::getModel('core/date')->date($format[$i], strtotime($date)));
157
- }
158
-
159
- return $out;
160
- }
161
-
162
- /**
163
- * Formats a Wordpress date string
164
- *
165
- */
166
- public function formatTime($time, $format = null)
167
- {
168
- if ($format == null) {
169
- $format = $this->getDefaultTimeFormat();
170
- }
171
-
172
- return $this->formatDate($time, $format);
173
- }
174
-
175
- /**
176
- * Split a date by spaces and translate
177
- *
178
- * @param string $date
179
- * @param string $splitter = ' '
180
- * @return string
181
- */
182
- public function translateDate($date, $splitter = ' ')
183
- {
184
- $dates = explode($splitter, $date);
185
-
186
- foreach($dates as $it => $part) {
187
- $dates[$it] = $this->__($part);
188
- }
189
-
190
- return implode($splitter, $dates);
191
- }
192
-
193
- /**
194
- * Return the default date formatting
195
- *
196
- */
197
- public function getDefaultDateFormat()
198
- {
199
- return $this->getWpOption('date_format', 'F jS, Y');
200
- }
201
-
202
- /**
203
- * Return the default time formatting
204
- *
205
- */
206
- public function getDefaultTimeFormat()
207
- {
208
- return $this->getWpOption('time_format', 'g:ia');
209
- }
210
-
211
- /**
212
- * Determine whether a WordPress plugin is enabled in the WP admin
213
- *
214
- * @param string $name
215
- * @param bool $format
216
- * @return bool
217
- */
218
- public function isPluginEnabled($name)
219
- {
220
- return Mage::helper('wordpress/plugin')->isEnabled($name);
221
- }
222
-
223
- /**
224
- * Determine whether to force single store
225
- *
226
- * @return bool
227
- */
228
- public function forceSingleStore()
229
- {
230
- return Mage::getStoreConfigFlag('wordpress/integration/force_single_store', Mage::helper('wordpress/app')->getStore()->getId());
231
- }
232
-
233
- /**
234
- * Determine whether Fishpig_WordpressMu can run
235
- *
236
- * @return bool
237
- */
238
- public function isWordPressMU()
239
- {
240
- if (!$this->_isCached('is_wpmu')) {
241
- $this->_cache('is_wpmu', false);
242
-
243
- if ($this->isWordPressMUInstalled()) {
244
- $this->_cache('is_wpmu', Mage::helper('wp_addon_multisite')->canRun());
245
- }
246
- }
247
-
248
- return $this->_cached('is_wpmu');
249
- }
250
-
251
- /**
252
- * Determine whether Fishpig_WordpressMu is installed
253
- *
254
- * @return bool
255
- */
256
- public function isWordPressMUInstalled()
257
- {
258
- if (!$this->_isCached('is_wpmu_installed')) {
259
- $config = Mage::getConfig();
260
-
261
- $isInstalled = (string)$config->getNode('modules/Fishpig_Wordpress_Addon_Multisite/active') === 'true'
262
- || (string)$config->getNode('modules/Fishpig_WordpressMu/active') === 'true';
263
-
264
- $this->_cache('is_wpmu_installed', $isInstalled);
265
- }
266
-
267
- return $this->_cached('is_wpmu_installed');
268
- }
269
-
270
- /**
271
- * Retrieve the upload URL
272
- *
273
- * @return string
274
- */
275
- public function getFileUploadUrl()
276
- {
277
- $url = $this->getWpOption('fileupload_url');
278
-
279
- if (!$url) {
280
- foreach(array('upload_url_path', 'upload_path') as $config) {
281
- if ($value = $this->getWpOption($config)) {
282
- if (strpos($value, 'http') === false) {
283
- if (substr($value, 0, 1) !== '/') {
284
- $url = $this->getBaseUrl($value);
285
- }
286
- }
287
- else {
288
- $url = $value;
289
- }
290
-
291
- break;
292
- }
293
- }
294
-
295
- if (!$url) {
296
- if ($this->isWordPressMU() && !Mage::helper('wpmultisite')->isDefaultBlog() && Mage::helper('wpmultisite')->getBlogId()) {
297
- $url = $this->getBaseUrl('wp-content/uploads/sites/' . Mage::helper('wpmultisite')->getBlogId() . '/');
298
- }
299
- else {
300
- $url = $this->getBaseUrl('wp-content/uploads/');
301
- }
302
- }
303
- }
304
-
305
- return rtrim($url, '/') . '/';
306
- }
307
-
308
- /**
309
- * Retrieve the local path to file cache path
310
- *
311
- * @return string
312
- */
313
- public function getFileCachePath()
314
- {
315
- return Mage::getBaseDir('var') . DS . 'wordpress' . DS;
316
- }
317
-
318
- /**
319
- * Retrieve the path for the WordPress installation
320
- * Return false if path is invalid
321
- *
322
- * @return false|string
323
- */
324
- public function getWordPressPath()
325
- {
326
- $path = $this->getRawWordPressPath();
327
-
328
- return is_dir($path) && is_file($path . 'wp-config.php')
329
- ? $path
330
- : false;
331
- }
332
-
333
- /**
334
- * Retrieve the path for the WordPress installation
335
- * Do not check, just return
336
- *
337
- * @return string
338
- */
339
- public function getRawWordPressPath()
340
- {
341
- $path = rtrim(Mage::getStoreConfig('wordpress/integration/path', Mage::helper('wordpress/app')->getStore()->getId()), DS);
342
-
343
- if ($path === '') {
344
- return false;
345
- }
346
-
347
- if (substr($path, 0, 1) !== DS) {
348
- return Mage::getBaseDir() . DS . $path . DS;
349
- }
350
-
351
- return rtrim($path, DS) . DS;
352
- }
353
-
354
- /**
355
- * Determine whether an addon is installed
356
- *
357
- * @param string $addon
358
- * @return bool
359
- */
360
- public function isAddonInstalled($addon)
361
- {
362
- if (strpos($addon, '_') === false) {
363
- $addon = 'Fishpig_Wordpress_Addon_' . $addon;
364
- }
365
-
366
- return (string)Mage::getConfig()->getNode('modules/' . $addon . '/active') === 'true';
367
- }
368
-
369
- /**
370
- * Provides backwards compatibility for older Magento versions running Legacy
371
- *
372
- * @param string $data
373
- * @param array $allowedTags = null
374
- * @return string
375
- */
376
- public function escapeHtml($data, $allowedTags = null)
377
- {
378
- return Mage::helper('core')->htmlEscape($data, $allowedTags);
379
- }
380
-
381
- /**
382
- * Determine wether the Legacy add-on is installed
383
- *
384
- * @return bool
385
- */
386
- public function isLegacy()
387
- {
388
- if ($this->_isCached('is_legacy')) {
389
- return $this->_cached('is_legacy');
390
- }
391
-
392
- $isLegacy = is_file(Mage::getBaseDir() . DS . 'app' . DS . 'etc' . DS . 'modules' . DS . 'Fishpig_Wordpress_Addon_Legacy.xml');
393
-
394
- $this->_cache('is_legacy', $isLegacy);
395
-
396
- return $isLegacy;
397
- }
398
-
399
- /**
400
- * Determine whether the request is an API request
401
- *
402
- * @return bool
403
- **/
404
- public function isApiRequest()
405
- {
406
- return strpos(trim(Mage::app()->getRequest()->getPathInfo(), '/'), 'api/') === 0;
407
- }
408
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Database.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Database extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Retrieve the read adapter
13
- *
14
- * @return Fishpig_Wordpress_Helper_App
15
- */
16
- public function connect()
17
- {
18
- return Mage::helper('wordpress/app')->init();
19
- }
20
-
21
- /**
22
- * Retrieve the read adapter
23
- *
24
- * @return false|Varien_Db_Adapter_Pdo_Mysql
25
- */
26
- public function getReadAdapter()
27
- {
28
- return Mage::helper('wordpress/app')->getDbConnection();
29
- }
30
-
31
- /**
32
- * Retrieve the write adapter
33
- *
34
- * @return false|Varien_Db_Adapter_Pdo_Mysql
35
- */
36
- public function getWriteAdapter()
37
- {
38
- return Mage::helper('wordpress/app')->getDbConnection();
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Filter.php DELETED
@@ -1,260 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Filter extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Process a string. Render shortcodes where possible
13
- *
14
- * @param string $string
15
- * @return string
16
- **/
17
- public function process($string)
18
- {
19
- return $this->applyFilters($string, Mage::getModel('wordpress/post'));
20
- }
21
-
22
- /**
23
- * Applies a set of filters to the given string
24
- *
25
- * @param string $content
26
- * @param Fishpig_Wordpress_Model_Post $object
27
- * @param string $context
28
- * @return string
29
- */
30
- public function applyFilters($content, $object, $context = null)
31
- {
32
- if (Mage::getStoreConfigFlag('wordpress/misc/autop')) {
33
- $content = $this->addParagraphsToString($content);
34
- }
35
-
36
- $contentObj = new Varien_Object(array(
37
- 'content' => trim(preg_replace('/(&nbsp;)$/', '', trim($content)))
38
- ));
39
-
40
- Mage::dispatchEvent('wordpress_string_filter_before', array('content' => $contentObj, 'object' => $object, 'context' => $context, 'helper' => $this));
41
-
42
- $content = $contentObj->getContent();
43
-
44
- $this->_applyShortcodes($content, $object, $context);
45
- $this->_addMagentoFilters($content);
46
-
47
- $contentObj = new Varien_Object(array('content' => $content));
48
-
49
- Mage::dispatchEvent('wordpress_string_filter_after', array('content' => $contentObj, 'object' => $object, 'context' => $context, 'helper' => $this));
50
-
51
- $content = $contentObj->getContent();
52
-
53
- return $content;
54
- }
55
-
56
- /**
57
- * Apply shortcodes to the content
58
- *
59
- * @param string &$content
60
- * @param Fishpig_Wordpress_Model_Post $post
61
- */
62
- protected function _applyShortcodes(&$content, $object, $context)
63
- {
64
- Mage::helper('wordpress/shortcode_gist')->apply($content, $object);
65
- Mage::helper('wordpress/shortcode_scribd')->apply($content, $object);
66
- Mage::helper('wordpress/shortcode_dailymotion')->apply($content, $object);
67
- Mage::helper('wordpress/shortcode_vimeo')->apply($content, $object);
68
- Mage::helper('wordpress/shortcode_instagram')->apply($content, $object);
69
- Mage::helper('wordpress/shortcode_youtube')->apply($content, $object);
70
- Mage::helper('wordpress/shortcode_product')->apply($content, $object);
71
- Mage::helper('wordpress/shortcode_caption')->apply($content, $object);
72
- Mage::helper('wordpress/shortcode_gallery')->apply($content, $object);
73
- Mage::helper('wordpress/shortcode_spotify')->apply($content, $object);
74
- Mage::helper('wordpress/shortcode_code')->apply($content, $object);
75
- Mage::helper('wordpress/shortcode_associatedProducts')->apply($content, $object);
76
-
77
- $contentObj = new Varien_Object(array('content' => $content));
78
-
79
- Mage::dispatchEvent('wordpress_shortcode_apply', array('content' => $contentObj, 'object' => $object, 'context' => $context, 'helper' => $this));
80
-
81
- $content = $contentObj->getContent();
82
- }
83
-
84
- /**
85
- * Apply the Magento filters that are applied to static blocks
86
- * This allows for {{store url=""}} & {{block type="..."}} strings
87
- *
88
- * @param string &$content
89
- * @param array $params = array()
90
- */
91
- protected function _addMagentoFilters(&$content)
92
- {
93
- if (strpos($content, '{{') !== false) {
94
- $content = Mage::helper('cms')->getBlockTemplateProcessor()->filter($content);
95
- }
96
- }
97
-
98
- /**
99
- * Add paragraph tags to the content
100
- *
101
- * @param string $content
102
- */
103
- public function addParagraphsToString($content)
104
- {
105
- $content = $this->_addParagraphsToString($content);
106
-
107
- $content = preg_replace('/<p>(\[|<div)/', '$1', $content);
108
- $content = preg_replace('/\]<\/p>/', ']', $content);
109
- $content = preg_replace('/(<\/div>)<\/p>/', '$1', $content);
110
-
111
- return $content;
112
- }
113
-
114
- /**
115
- * Actually do the HTML conversion
116
- *
117
- * @param string $content
118
- */
119
- protected function _addParagraphsToString($content)
120
- {
121
- if (function_exists('wpautop')) {
122
- return wpautop($content);
123
- }
124
-
125
- if ($this->_retrieveAutoP()) {
126
- return fp_wpautop($content);
127
- }
128
-
129
- $protectedTags = array(
130
- 'script',
131
- 'style',
132
- 'pre',
133
- 'textarea',
134
- );
135
-
136
- $safe = array();
137
-
138
- foreach($protectedTags as $tag) {
139
- if (strpos($content, '<' . $tag) !== false) {
140
- if (preg_match_all('/(<' . $tag . '.*<\/' . $tag . '>)/siU', $content, $matches)) {
141
- foreach($matches[1] as $match) {
142
- $safe[] = $match;
143
- $content = str_replace($match, '<!--KEY' . (count($safe)-1) . '-->', $content);
144
- }
145
- }
146
- }
147
- }
148
-
149
- $pee = str_replace("\n", ' ', $content) . "\n";
150
-
151
- $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
152
- // Space things out a little
153
- $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|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
154
- $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
155
- $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
156
- $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
157
- if ( strpos($pee, '<object') !== false ) {
158
- $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed
159
- $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
160
- }
161
- $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
162
-
163
- // make paragraphs, including one at the end
164
- $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
165
- $pee = '';
166
-
167
- foreach ( $pees as $tinkle ) {
168
- if (trim(strip_tags(trim($tinkle))) !== '') {
169
- $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
170
- }
171
- else {
172
- $pee .= $tinkle . "\n";
173
- }
174
- }
175
-
176
- $pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
177
- $pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
178
- $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
179
- $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
180
- $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
181
- $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
182
- $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
183
- $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
184
-
185
- $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
186
- $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
187
- $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
188
-
189
- foreach(array('script', 'style') as $tag) {
190
- $pee = str_replace(array('<p><' . $tag, '</' . $tag . '></p>'), array('<' . $tag, '</' . $tag . '>'), $pee);
191
- }
192
-
193
- $pee = str_replace(array('<p>[', ']</p>'), array('[', ']'), $pee);
194
-
195
- $content = $pee;
196
-
197
- foreach($safe as $key => $value) {
198
- $content = str_replace('<!--KEY' . $key . '-->', $value, $content);
199
- }
200
-
201
- return $content;
202
- }
203
-
204
- /**
205
- * Retrieve the autop function and evaluate
206
- *
207
- * @return bool
208
- **/
209
- protected function _retrieveAutoP()
210
- {
211
- if (function_exists('fp_wpautop')) {
212
- return true;
213
- }
214
-
215
- $formattingFile = Mage::getModuleDir('', 'Fishpig_Wordpress') . DS . 'formatting.php';
216
- # $formattingFile = Mage::helper('wordpress')->getWordPressPath() . 'wp-includes' . DS . 'formatting.php';
217
-
218
- if (!is_file($formattingFile)) {
219
- return false;
220
- }
221
-
222
- $code = preg_replace('/\/\*\*.*\*\//Us', '', file_get_contents($formattingFile));
223
-
224
- $functions = array(
225
- 'wpautop' => '',
226
- 'wp_replace_in_html_tags' => '',
227
- '_autop_newline_preservation_helper' => '',
228
- 'wp_html_split' => '',
229
- 'get_html_split_regex' => '',
230
- );
231
-
232
- foreach($functions as $function => $ignore) {
233
- if (preg_match('/(function ' . $function . '\(.*)function/sU', $code, $matches)) {
234
- $functions[$function] = $matches[1];
235
- }
236
- else {
237
- return false;
238
- }
239
- }
240
-
241
- $code = preg_replace('/(' . implode('|', array_keys($functions)) . ')/', 'fp_$1', implode("\n\n", $functions));
242
-
243
- @eval($code);
244
-
245
- return function_exists('fp_wpautop');
246
- }
247
-
248
-
249
- /**
250
- * Preserve new lines
251
- * Used as callback in _addParagraphsToString
252
- *
253
- * @param array $matches
254
- * @return string
255
- */
256
- public function _preserveNewLines($matches)
257
- {
258
- return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
259
- }
260
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Plugin extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Install a plugin
13
- *
14
- * @param string $target
15
- * @param string $source
16
- * @param bool $enable
17
- * @return bool
18
- */
19
- public function install($target, $source, $enable = false)
20
- {
21
- if (!is_file($source)) {
22
- return false;
23
- }
24
-
25
- $sourceData = @file_get_contents($source);
26
-
27
- if (!$sourceData) {
28
- return false;
29
- }
30
-
31
- @mkdir(dirname($target));
32
-
33
- if ((is_file($target) && is_writable($target)) || (!is_file($target) && is_writable(dirname($target)))) {
34
- @file_put_contents($target, $sourceData);
35
-
36
- if (is_file($target)) {
37
- return $enable
38
- ? $this->enable(substr($target, strpos($target, 'wp-content/plugins/')+strlen('wp-content/plugins/')))
39
- : true;
40
- }
41
- }
42
-
43
- return false;
44
- }
45
-
46
- /**
47
- * Enable a plugin
48
- *
49
- * @param string $plugin
50
- * @return bool
51
- */
52
- public function enable($plugin)
53
- {
54
- if ($this->isEnabled($plugin)) {
55
- return true;
56
- }
57
-
58
- if ($db = Mage::helper('wordpress/app')->getDbConnection()) {
59
- if ($plugins = $this->getWpOption('active_plugins')) {
60
- $db->update(
61
- Mage::getSingleton('core/resource')->getTableName('wordpress/option'),
62
- array('option_value' => serialize(array_merge(unserialize($plugins), array($plugin)))),
63
- $db->quoteInto('option_name=?', 'active_plugins')
64
- );
65
- }
66
- else {
67
- $db->insert(
68
- Mage::getSingleton('core/resource')->getTableName('wordpress/option'),
69
- array(
70
- 'option_name' => 'active_plugins',
71
- 'option_value' => serialize(array($plugin))
72
- )
73
- );
74
- }
75
-
76
- return true;
77
- }
78
-
79
- return false;
80
- }
81
-
82
- /**
83
- * Determine whether a WordPress plugin is enabled in the WP admin
84
- *
85
- * @param string $name
86
- * @param bool $format
87
- * @return bool
88
- */
89
- public function isEnabled($name)
90
- {
91
- $helper = Mage::helper('wordpress');
92
-
93
- $plugins = array();
94
-
95
- if ($plugins = $helper->getWpOption('active_plugins')) {
96
- $plugins = unserialize($plugins);
97
- }
98
-
99
- if ($helper->isWordPressMU() && Mage::helper('wpmultisite')->canRun()) {
100
- if ($networkPlugins = Mage::helper('wpmultisite')->getWpSiteOption('active_sitewide_plugins')) {
101
- $plugins += (array)unserialize($networkPlugins);
102
- }
103
- }
104
-
105
- if ($plugins) {
106
- foreach($plugins as $a => $b) {
107
- if (strpos($a . '-' . $b, $name) !== false) {
108
- return true;
109
- }
110
- }
111
- }
112
-
113
- return false;
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin/Abstract.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Helper_Plugin_Abstract extends Varien_Object
10
- {
11
- /**
12
- * Store for the plugins options
13
- *
14
- */
15
- protected $_options = null;
16
-
17
- /**
18
- * Prefix for options field in options table
19
- *
20
- * @var string|null
21
- */
22
- protected $_optionsFieldPrefix = null;
23
-
24
- /**
25
- * Postfix for options field in options table
26
- *
27
- * @var string|null
28
- */
29
- protected $_optionsFieldPostfix = '_options';
30
-
31
- /**
32
- * Prefix for options value keys
33
- *
34
- * @var string
35
- */
36
- protected $_optionsValuePrefix = '';
37
-
38
- /**
39
- * Flag determine whther to fix option keys
40
- *
41
- * @var bool
42
- */
43
- protected $_fixOptionKeys = true;
44
-
45
- /**
46
- * Automatically load the plugin options
47
- *
48
- */
49
- protected function _construct()
50
- {
51
- if (!is_null($this->_optionsFieldPrefix)) {
52
- $options = Mage::helper('wordpress')->getWpOption($this->_optionsFieldPrefix . $this->_optionsFieldPostfix);
53
-
54
- if ($options) {
55
- $options = unserialize($options);
56
-
57
- foreach($options as $key => $value) {
58
- if ($this->_fixOptionKeys === true) {
59
- $key = trim(str_replace($this->_optionsValuePrefix, '', $key), '-_ ');
60
- $key = @preg_replace('/([A-Z]{1})([A-Z]{1,})/e', "$1 . strtolower($2);", $key);
61
- $key = @preg_replace('/([A-Z]{1})/e', "'_' . strtolower($1);", $key);
62
- }
63
-
64
- if (is_array($value) || trim($value) !== '') {
65
- $this->setData($key, $value);
66
- }
67
- }
68
- }
69
- }
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Plugin/Seo/Abstract.php DELETED
@@ -1,223 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Helper_Plugin_Seo_Abstract extends Fishpig_Wordpress_Helper_Plugin_Abstract
10
- {
11
- /**
12
- * Internal cache variable used to store the action reference
13
- *
14
- * @var Fishpig_Wordpress_Controller_Abstract
15
- */
16
- protected $_action = false;
17
-
18
- /**
19
- * The value used to separate token's in the title
20
- *
21
- * @var string
22
- */
23
- protected $_rewriteTitleToken = '%';
24
-
25
- /**
26
- * Determines whether the plugin is enabled in WP
27
- *
28
- * @return bool
29
- */
30
- abstract public function isEnabled();
31
-
32
- /**
33
- * Retrieve the title format for the given key
34
- *
35
- * @param string $key
36
- * @return string
37
- */
38
- abstract protected function _getTitleFormat($key);
39
-
40
- /**
41
- * Based on the observer data,
42
- * route the request to the appropriate method
43
- * This allows extensions to respond to any event without declaring it in config.xml
44
- *
45
- * @param Varien_Event_Observer $observer
46
- */
47
- public function injectSeoObserver(Varien_Event_Observer $observer)
48
- {
49
- if ($this->isEnabled()) {
50
- $method = sprintf('processRoute%s', uc_words($observer->getEvent()->getAction()->getFullActionName(), ''));
51
-
52
- try {
53
- if (method_exists($this, $method) && is_callable(array($this, $method))) {
54
- $this->_action = $observer->getEvent()->getAction();
55
-
56
- $this->_beforeObserver();
57
-
58
- $result = call_user_func(array($this, $method), $observer->getEvent()->getObject());
59
-
60
- if ($result !== false) {
61
- $this->_afterObserver();
62
- }
63
-
64
- return $result;
65
- }
66
- }
67
- catch (Mage_Core_Controller_Varien_Exception $e) {
68
- throw $e;
69
- }
70
- catch (Exception $e) {
71
- Mage::helper('wordpress')->log($e->getMessage());
72
- }
73
- }
74
- }
75
-
76
- /**
77
- * Perform global actions before the user_func has been called
78
- *
79
- * @return $this
80
- */
81
- protected function _beforeObserver()
82
- {
83
- return $this;
84
- }
85
-
86
- /**
87
- * Perform global actions after the user_func has been called
88
- *
89
- * @return $this
90
- */
91
- protected function _afterObserver()
92
- {
93
- return $this;
94
- }
95
-
96
- /**
97
- * Iterate through the array and apply the values to page's meta info
98
- *
99
- * @param array $meta
100
- * @return $this
101
- */
102
- protected function _applyMeta(array $meta)
103
- {
104
- if (($headBlock = $this->_getHeadBlock()) !== false) {
105
- foreach($meta as $key => $value) {
106
- if (($value = trim($value)) === '') {
107
- continue;
108
- }
109
-
110
- if (($value = $this->_rewriteString($value)) !== false) {
111
- $headBlock->setData($key, $value);
112
-
113
- if ($key === 'title') {
114
- $this->_action->ignoreAutomaticTitles();
115
- }
116
- }
117
- }
118
- }
119
-
120
- return $this;
121
- }
122
-
123
- /**
124
- * Given a key that determines which format to load
125
- * and a data array, merge the 2 to create a valid title
126
- *
127
- * @param string $key
128
- * @param array $data
129
- * @return string|false
130
- */
131
- protected function _rewriteString($format)
132
- {
133
- $data = $this->getRewriteData();
134
- $rwt = $this->_rewriteTitleToken;
135
- $value = array();
136
- $parts = preg_split("/(" . $rwt . "[a-z_-]{1,}" . $rwt . ")/iU", $format, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
137
-
138
- foreach($parts as $part) {
139
- if (substr($part, 0, strlen($rwt)) === $rwt && substr($part, -(strlen($rwt))) === $rwt) {
140
- $part = trim($part, $rwt);
141
-
142
- if (isset($data[$part])) {
143
- $value[] = $data[$part];
144
- }
145
- }
146
- else {
147
- $value[] = $part;
148
- }
149
- }
150
-
151
- if (($value = trim(implode('', $value))) !== '') {
152
- return $value;
153
- }
154
-
155
- return false;
156
- }
157
-
158
- /**
159
- * Retrieve the rewrite data
160
- *
161
- * @return array
162
- */
163
- public function getRewriteData()
164
- {
165
- return array();
166
- }
167
-
168
- protected function _updateBreadcrumb($name, $label, $link = null)
169
- {
170
- if (($label = trim($label)) !== '') {
171
- if (($crumb = $this->getAction()->getCrumb($name)) !== false) {
172
- $crumb[0]['label'] = $label;
173
-
174
- if (!is_null($link)) {
175
- $crumb[0]['link'] = $link;
176
- }
177
-
178
- $this->getAction()->addCrumb($name, $crumb[0], $crumb[1]);
179
- }
180
- }
181
-
182
- return $this;
183
- }
184
-
185
- /**
186
- * Retrieve the head block from the layout object
187
- *
188
- * @return false|Mage_Core_Block_Page_Html_Head
189
- */
190
- protected function _getHeadBlock()
191
- {
192
- if (($headBlock = Mage::getSingleton('core/layout')->getBlock('head')) !== false) {
193
- return $headBlock;
194
- }
195
-
196
- return false;
197
- }
198
-
199
- /**
200
- * Cause the current action to be undispatched and redirect
201
- *
202
- * @param string $path
203
- */
204
- protected function _redirect($path)
205
- {
206
- header('Location: ' . Mage::getUrl('', array('_direct' => $path)));;
207
- exit;
208
-
209
- $exception = new Mage_Core_Controller_Varien_Exception();
210
-
211
- throw $exception->prepareRedirect($path);
212
- }
213
-
214
- /**
215
- * Retrieve the action class
216
- *
217
- * @return Fishpig_Wordpress_Controller_Abstract
218
- */
219
- public function getAction()
220
- {
221
- return $this->_action;
222
- }
223
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Router.php DELETED
@@ -1,294 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Router extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Cache for blog URI
13
- * Can be changed
14
- *
15
- * @static string
16
- **/
17
- static protected $_blogUri = null;
18
-
19
- /**
20
- * Retrieve the blog URI
21
- * This is the whole URI after blog route
22
- *
23
- * @return string
24
- */
25
- public function getBlogUri()
26
- {
27
- if (self::$_blogUri !== null) {
28
- return self::$_blogUri;
29
- }
30
-
31
- $pathInfo = strtolower(trim($this->getRequest()->getPathInfo(), '/'));
32
-
33
- if ($this->getBlogRoute() && strpos($pathInfo, $this->getBlogRoute()) !== 0) {
34
- return null;
35
- }
36
-
37
- $pathInfo = trim(substr($pathInfo, strlen($this->getBlogRoute())), '/');
38
-
39
- self::$_blogUri = '';
40
-
41
- if ($pathInfo === '') {
42
- return '';
43
- }
44
-
45
- $pathInfo = explode('/', $pathInfo);
46
-
47
- // Clean off pager and feed parts
48
- if (($key = array_search('page', $pathInfo)) !== false) {
49
- if (isset($pathInfo[($key+1)]) && preg_match("/[0-9]{1,}/", $pathInfo[($key+1)])) {
50
- $this->getRequest()->setParam('page', $pathInfo[($key+1)]);
51
- unset($pathInfo[($key+1)]);
52
- unset($pathInfo[$key]);
53
-
54
- $pathInfo = array_values($pathInfo);
55
- }
56
- }
57
-
58
- // Clean off feed and trackback variable
59
- if (($key = array_search('feed', $pathInfo)) !== false) {
60
- unset($pathInfo[$key]);
61
-
62
- if (isset($pathInfo[$key+1])) {
63
- unset($pathInfo[$key+1]);
64
- }
65
-
66
- $this->getRequest()->setParam('feed', 'rss2');
67
- $this->getRequest()->setParam('feed_type', 'rss2');
68
- }
69
-
70
- // Remove comments pager variable
71
- foreach($pathInfo as $i => $part) {
72
- $results = array();
73
- if (preg_match("/" . sprintf('^comment-page-%s$', '([0-9]{1,})') . "/", $part, $results)) {
74
- if (isset($results[1])) {
75
- unset($pathInfo[$i]);
76
- }
77
- }
78
- }
79
-
80
- if (count($pathInfo) == 1 && preg_match("/^[0-9]{1,8}$/", $pathInfo[0])) {
81
- $this->getRequest()->setParam('p', $pathInfo[0]);
82
-
83
- array_shift($pathInfo);
84
- }
85
-
86
- $uri = urldecode(implode('/', $pathInfo));
87
-
88
- self::$_blogUri = $uri;
89
-
90
- return $uri;
91
- }
92
-
93
- /**
94
- * Set the Blog URI
95
- *
96
- * @param string $blogUri
97
- * @return $this
98
- **/
99
- public function setBlogUri($blogUri)
100
- {
101
- self::$_blogUri = $blogUri;
102
-
103
- return $this;
104
- }
105
-
106
- /**
107
- * Retrieve the page ID set via the query string
108
- *
109
- * @return int|null
110
- */
111
- public function getPageId()
112
- {
113
- return $this->getRequest()->getParam('page_id');
114
- }
115
-
116
- /**
117
- * Retrieve the request object
118
- *
119
- * @return
120
- */
121
- public function getRequest()
122
- {
123
- return Mage::app()->getRequest();
124
- }
125
-
126
- /**
127
- * Retrieve the search query variable name
128
- *
129
- * @return string
130
- */
131
- public function getSearchVar()
132
- {
133
- return 's';
134
- }
135
-
136
- /**
137
- * Retrieve the search route
138
- *
139
- * @return string
140
- */
141
- public function getSearchRoute()
142
- {
143
- return 'search';
144
- }
145
-
146
- /**
147
- * Retrieve the current search term
148
- *
149
- * @return string
150
- */
151
- public function getSearchTerm($escape = false, $key = null)
152
- {
153
- if (is_null($key)) {
154
- $searchTerm = $this->getRequest()->getParam($this->getSearchVar());
155
- }
156
- else {
157
- $searchTerm = $this->getRequest()->getParam($key);
158
- }
159
-
160
- return $escape
161
- ? Mage::helper('wordpress')->escapeHtml($searchTerm)
162
- : $searchTerm;
163
- }
164
-
165
- /**
166
- * Generate an array of URI's based on $results
167
- *
168
- * @param array $results
169
- * @return array
170
- */
171
- public function generateRoutesFromArray($results, $prefix = '')
172
- {
173
- $objects = array();
174
- $byParent = array();
175
-
176
- foreach($results as $key => $result) {
177
- if (!$result['parent']) {
178
- $objects[$result['id']] = $result;
179
- }
180
- else {
181
- if (!isset($byParent[$result['parent']])) {
182
- $byParent[$result['parent']] = array();
183
- }
184
-
185
- $byParent[$result['parent']][$result['id']] = $result;
186
- }
187
- }
188
-
189
- if (count($objects) === 0) {
190
- return false;
191
- }
192
-
193
- $routes = array();
194
-
195
- foreach($objects as $objectId => $object) {
196
- if (($children = $this->_createArrayTree($objectId, $byParent)) !== false) {
197
- $objects[$objectId]['children'] = $children;
198
- }
199
-
200
- $routes += $this->_createLookupTable($objects[$objectId], $prefix);
201
- }
202
-
203
- return $routes;
204
- }
205
-
206
- /**
207
- * Create a lookup table from an array tree
208
- *
209
- * @param array $node
210
- * @param string $idField
211
- * @param string $field
212
- * @param string $prefix = ''
213
- * @return array
214
- */
215
- protected function _createLookupTable(&$node, $prefix = '')
216
- {
217
- if (!isset($node['id'])) {
218
- return array();
219
- }
220
-
221
- $urls = array(
222
- $node['id'] => ltrim($prefix . '/' . urldecode($node['url_key']), '/')
223
- );
224
-
225
- if (isset($node['children'])) {
226
- foreach($node['children'] as $childId => $child) {
227
- $urls += $this->_createLookupTable($child, $urls[$node['id']]);
228
- }
229
- }
230
-
231
- return $urls;
232
- }
233
-
234
- /**
235
- * Create an array tree. This is used for creating static URL lookup tables
236
- * for categories and pages
237
- *
238
- * @param int $id
239
- * @param array $pool
240
- * @param string $field = 'parent'
241
- * @return false|array
242
- */
243
- protected function _createArrayTree($id, &$pool)
244
- {
245
- if (isset($pool[$id]) && $pool[$id]) {
246
- $children = $pool[$id];
247
-
248
- unset($pool[$id]);
249
-
250
- foreach($children as $childId => $child) {
251
- unset($children[$childId]['parent']);
252
- if (($result = $this->_createArrayTree($childId, $pool)) !== false) {
253
- $children[$childId]['children'] = $result;
254
- }
255
- }
256
-
257
- return $children;
258
- }
259
-
260
- return false;
261
- }
262
-
263
- /**
264
- * If a page is set as a custom homepage, get it's ID
265
- *
266
- * @return false|int
267
- */
268
- public function getHomepagePageId()
269
- {
270
- if (Mage::helper('wordpress')->getWpOption('show_on_front') === 'page') {
271
- if ($pageId = Mage::helper('wordpress')->getWpOption('page_on_front')) {
272
- return $pageId;
273
- }
274
- }
275
-
276
- return false;
277
- }
278
-
279
- /**
280
- * If a page is set as a custom homepage, get it's ID
281
- *
282
- * @return false|int
283
- */
284
- public function getBlogPageId()
285
- {
286
- if (Mage::helper('wordpress')->getWpOption('show_on_front') === 'page') {
287
- if ($pageId = Mage::helper('wordpress')->getWpOption('page_for_posts')) {
288
- return $pageId;
289
- }
290
- }
291
-
292
- return false;
293
- }
294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Abstract.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Helper_Shortcode_Abstract extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Regular expression patterns for identifying
13
- * shortcodes and parameters
14
- *
15
- */
16
- const EXPR_SHOTRCODE_OPEN_TAG = '(\[{{shortcode}}[^\]]{0,}\])';
17
- const EXPR_SHOTRCODE_CLOSE_TAG = '(\[\/{{shortcode}}[^\]]{0,}\])';
18
-
19
- /**
20
- * Retrieve the shortcode tag
21
- *
22
- * @return string
23
- */
24
- abstract public function getTag();
25
-
26
- /**
27
- * Apply the shortcode to the content
28
- *
29
- * @param string $content
30
- * @param Fishpig_Wordpress_Model_Post $post
31
- * @return void
32
- */
33
- abstract protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post);
34
-
35
- /**
36
- * Apply the shortcode to the content
37
- *
38
- * @param string $content
39
- * @param Fishpig_Wordpress_Model_Post $post
40
- * @return void
41
- */
42
- public function apply(&$content, Fishpig_Wordpress_Model_Post $post)
43
- {
44
- if (strpos($content, $this->getTag()) === false) {
45
- return $this;
46
- }
47
-
48
- $content = "\n" . $content . "\n";
49
-
50
- try {
51
- $this->_convertTagAliases($content);
52
- $this->_convertInnerUrls($content);
53
- $this->_convertRawUrls($content);
54
-
55
- return $this->_apply($content, $post);
56
- }
57
- catch (Exception $e) {
58
- $this->log($e);
59
- }
60
- }
61
-
62
- public function getTagAliases()
63
- {
64
- return false;
65
- }
66
-
67
- /**
68
- * Retrieve the shortcode ID key
69
- *
70
- * @return string
71
- */
72
- public function getShortcodeIdKey()
73
- {
74
- return '';
75
- }
76
-
77
- /**
78
- * Retrieve the regex pattern for the inner URL's
79
- *
80
- * @return string
81
- */
82
- public function getInnerUrlsRegex()
83
- {
84
- return '';
85
- }
86
-
87
- /**
88
- * Retrieve the regex pattern for the raw URL's
89
- *
90
- * @return string
91
- */
92
- public function getRawUrlRegex()
93
- {
94
- return '';
95
- }
96
-
97
- /**
98
- * Retrieve the parameter regex
99
- *
100
- * @return string
101
- */
102
- public function getParameterRegex()
103
- {
104
- return '/([a-z]{1,})=([^\s ]{1,})/i';
105
- }
106
-
107
- /**
108
- * Retrieve the content that goes between the shortcode tag and parsed URL
109
- *
110
- * @return string
111
- */
112
- public function getConvertedUrlsMiddle()
113
- {
114
- return ' ';
115
- }
116
-
117
- /**
118
- * Retrieve the HTML string
119
- * This is usually parsed using sprintf
120
- *
121
- * @return string
122
- */
123
- protected function _getHtmlString()
124
- {
125
- return '';
126
- }
127
-
128
- /**
129
- * Convert inner URL's to the shortcode
130
- *
131
- * @param string $content
132
- * @return void
133
- */
134
- protected function _convertInnerUrls(&$content)
135
- {
136
- if (($regex = $this->getInnerUrlsRegex()) !== '') {
137
- if (preg_match_all('/' . sprintf($regex, $this->getTag()) . '/i', $content, $result)) {
138
- foreach($result[1] as $key => $code) {
139
- $content = str_replace($result[0][$key], sprintf('[%s %s %s]', $this->getTag(), rtrim($code, '/'), $result[2][$key]), $content);
140
- }
141
- }
142
- }
143
- }
144
-
145
- /**
146
- * Convert raw URL's to the shortcode
147
- *
148
- * @param string $content
149
- * @return void
150
- */
151
- protected function _convertRawUrls(&$content)
152
- {
153
- $content = "\n" . $content . "\n";
154
-
155
- if (($regex = $this->getRawUrlRegex()) !== '') {
156
- $regexes = array(
157
- '[\r\n]{1}' . $regex . '[\r\n]{1}',
158
- '<p>[\s]{0,}' . $regex . '[\s]{0,}<\/p>',
159
- );
160
-
161
- foreach($regexes as $regex) {
162
- if (preg_match_all('/' . $regex . '/i', $content, $result)) {
163
- foreach($result[1] as $key => $url) {
164
- $content = str_replace(
165
- ltrim($result[0][$key], '>'),
166
- sprintf('[%s%s%s]', $this->getTag(), $this->getConvertedUrlsMiddle(), trim(strip_tags($url))),
167
- $content
168
- );
169
- }
170
- }
171
- }
172
- }
173
- }
174
-
175
- /**
176
- * Convert tag aliases to the correct tag
177
- *
178
- * @param string $content
179
- * @return void
180
- */
181
- protected function _convertTagAliases(&$content)
182
- {
183
- if (($aliases = $this->getTagAliases()) !== false) {
184
- $tag = $this->getTag();
185
-
186
- foreach($aliases as $alias) {
187
- $content = str_replace(array('[' . $alias, '[/' . $alias . ']'), array('[' . $this->getTag(), '[/' . $this->getTag() . ']'), $content);
188
- }
189
- }
190
- }
191
-
192
- /**
193
- * Extract shortcodes from a string
194
- *
195
- * @param string $content
196
- * @return false|array
197
- */
198
- protected function _getShortcodes($content)
199
- {
200
- $shortcodes = array();
201
-
202
- if (strpos($content, '[' . $this->getTag()) !== false) {
203
- $hasCloser = strpos($content, '[/' . $this->getTag() . ']') !== false;
204
- $open = str_replace('{{shortcode}}', $this->getTag(), self::EXPR_SHOTRCODE_OPEN_TAG);
205
-
206
- if ($hasCloser) {
207
- $close = str_replace('{{shortcode}}', $this->getTag(), self::EXPR_SHOTRCODE_CLOSE_TAG);
208
-
209
- if (preg_match_all('/' . $open . '(.*)' . $close . '/iUs', $content, $matches)) {
210
- foreach($matches[0] as $matchId => $match) {
211
- $shortcodes[] = new Varien_Object(array(
212
- 'html' => $match,
213
- 'opening_tag' => $matches[1][$matchId],
214
- 'inner_content' => $matches[2][$matchId],
215
- 'closing_tag' => $matches[3][$matchId],
216
- 'params' => new Varien_Object($this->_parseShortcodeParameters($matches[1][$matchId])),
217
- ));
218
- }
219
- }
220
- }
221
- else if (preg_match_all('/' . $open . '/iU', $content, $matches)) {
222
- foreach($matches[0] as $matchId => $match) {
223
- $shortcodes[] = new Varien_Object(array(
224
- 'html' => $match,
225
- 'opening_tag' => $matches[1][$matchId],
226
- 'params' => new Varien_Object($this->_parseShortcodeParameters($matches[1][$matchId])),
227
- ));
228
- }
229
- }
230
- }
231
-
232
- if (count($shortcodes) > 0) {
233
- return $shortcodes;
234
- }
235
-
236
- return false;
237
- }
238
-
239
- /**
240
- * Extract parameters from a shortcode opening tag
241
- *
242
- * @param string $openingTag
243
- * @return array
244
- */
245
- protected function _parseShortcodeParameters($openingTag)
246
- {
247
- $parameters = array();
248
-
249
- if (($regex = trim($this->getParameterRegex())) !== '') {
250
- $openingTag = trim(substr(trim($openingTag), strlen($this->getTag())+1), '[] ');
251
-
252
- if (preg_match_all($regex, $openingTag, $matches)) {
253
- foreach($matches[2] as $key => $value) {
254
- $parameters[trim($matches[1][$key])] = trim($value, '"\' ');
255
- $openingTag = str_replace($matches[0][$key], '', $openingTag);
256
- }
257
- }
258
-
259
- if ($this->getShortcodeIdKey() !== '') {
260
- foreach(explode(' ', trim($openingTag, ' ')) as $value) {
261
- if (($value = trim($value)) !== '') {
262
- $parameters = array_merge(array($this->getShortcodeIdKey() => $value), $parameters);
263
- break;
264
- }
265
- }
266
- }
267
- }
268
-
269
- return $parameters;
270
- }
271
-
272
- /**
273
- * Wrapper for preg_match that adds extra functionality
274
- *
275
- * @param string $pattern
276
- * @param string $value
277
- * @param int $keyToReturn
278
- * @return mixed
279
- */
280
- public function _match($pattern, $value, $keyToReturn = -1, $default = false)
281
- {
282
- $result = array();
283
- preg_match($pattern, $value, $result);
284
-
285
- if ($keyToReturn == -1) {
286
- return $result;
287
- }
288
-
289
- return isset($result[$keyToReturn]) ? $result[$keyToReturn] : $default;
290
- }
291
-
292
- /**
293
- * Shortcut to create a block
294
- *
295
- * @param string $type
296
- * @param string $name = null
297
- * @return Mage_Core_Block_Abstract
298
- */
299
- public function _createBlock($type, $name = null)
300
- {
301
- return Mage::getSingleton('core/layout')->createBlock($type, $name.microtime());
302
- }
303
-
304
- /**
305
- * Retrieve the template
306
- *
307
- * @param Varien_Object $params
308
- * @return string
309
- */
310
- protected function _getTemplate(Varien_Object $params)
311
- {
312
- return $params->getTemplate() ? $params->getTemplate() : $this->_getDefaultTemplate();
313
- }
314
-
315
- /**
316
- * Retrieve the default template
317
- *
318
- * @return string
319
- */
320
- protected function _getDefaultTemplate()
321
- {
322
- return '';
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/AssociatedProducts.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_AssociatedProducts extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'associated-products';
19
- }
20
-
21
- /**
22
- * Apply the associated products short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $shortcode) {
32
- $params = $shortcode->getParams();
33
- $template = $params->getTemplate() ? $params->getTemplate() : 'wordpress/post/associated/products.phtml';
34
- $title = $params->getTitle() ? $params->getTitle() : Mage::helper('catalog')->__('Related Products');
35
-
36
- $html = $this->_createBlock('wordpress/post_associated_products')
37
- ->setTemplate($template)
38
- ->setTitle($title)
39
- ->toHtml();
40
-
41
- $content = str_replace($shortcode->getHtml(), $html, $content);
42
- }
43
- }
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Caption.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Caption extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'caption';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $shortcode) {
32
- $params = $shortcode->getParams();
33
- $caption = $params->getCaption() ? sprintf('<p class="wp-caption-text">%s</p>', trim($params->getCaption())) : '';
34
- $style = '';
35
-
36
- if ($params->getWidth()) {
37
- $style = $params->getAlign() != 'center' ? ' style="width:'.($params->getWidth()+10).'px;"' : '';
38
- }
39
-
40
- $html = array(
41
- sprintf('<div id="%s" class="wp-caption %s"%s>', $params->getId(), $params->getAlign(), $style),
42
- $shortcode->getInnerContent(),
43
- $caption,
44
- '</div>'
45
- );
46
-
47
- $content = str_replace($shortcode->getHtml(), implode('', $html), $content);
48
- }
49
- }
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Code.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Code extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'code';
19
- }
20
-
21
- /**
22
- * Retrieve an array of tag aliases
23
- *
24
- * @return false|array
25
- */
26
- public function getTagAliases()
27
- {
28
- return array('sourcecode');
29
- }
30
-
31
- /**
32
- * Apply the Vimeo short code
33
- *
34
- * @param string &$content
35
- * @param Fishpig_Wordpress_Model_Post $post
36
- * @param array $params = array
37
- */
38
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
39
- {
40
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
41
- foreach($shortcodes as $shortcode) {
42
- $content = str_replace($shortcode->getOpeningTag(), sprintf('<pre class="brush: %s">', $shortcode->getParams()->getLanguage()), $content);
43
- $content = str_replace($shortcode->getClosingTag(), '</pre>', $content);
44
- }
45
- }
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Dailymotion.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Dailymotion extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'dailymotion';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $shortcode) {
32
- if ($id = $shortcode->getParams()->getId()) {
33
- $content = str_replace($shortcode->getHtml(), sprintf($this->_getHtmlString(), $id), $content);
34
- }
35
- }
36
- }
37
- }
38
-
39
- /**
40
- * Retrieve the shortcode middle content
41
- *
42
- * @return string
43
- */
44
- public function getConvertedUrlsMiddle()
45
- {
46
- return ' id=';
47
- }
48
-
49
- /**
50
- * Retrieve the HTML pattern for the Vimeo
51
- *
52
- * @return string
53
- */
54
- protected function _getHtmlString()
55
- {
56
- return '<iframe src="http://www.dailymotion.com/embed/video/%s" width="625" height="468" frameborder="0"></iframe>';
57
- }
58
-
59
- /**
60
- * Retrieve the regex pattern for the raw URL's
61
- *
62
- * @return string
63
- */
64
- public function getRawUrlRegex()
65
- {
66
- return 'http:\/\/www.dailymotion.com\/video\/([^_]{1,})[^\s]{1,}';
67
- }
68
- }
69
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Gallery.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Gallery extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'gallery';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $it => $shortcode) {
32
- $args = $shortcode->getParams();
33
-
34
- if (!$args->getColumns()) {
35
- $args->setColumns(3);
36
- }
37
-
38
- if (!$args->getSize()) {
39
- $args->setSize('thumbnail');
40
- }
41
-
42
- if (!$args->getLink()) {
43
- $args->setLink('attachment');
44
- }
45
-
46
- if ($args->getPostId()) {
47
- if ($args->getPostId() !== $params['object']->getId()) {
48
- $post = Mage::getModel('catalog/post')->load($args->getPostId());
49
- }
50
- }
51
-
52
- if (($ids = trim($args->getIds(), ',')) !== '') {
53
- $images = new Varien_Data_Collection();
54
-
55
- foreach(explode(',', $ids) as $imageId) {
56
- $image = Mage::getModel('wordpress/image')->load($imageId);
57
-
58
- if ($image->getId()) {
59
- $images->addItem($image);
60
- }
61
- }
62
- }
63
- else {
64
- $images = $post->getImages();
65
- }
66
-
67
- $html = $this->_createBlock('wordpress/template')
68
- ->setImageCollection($images)
69
- ->setColumns($args->getColumns())
70
- ->setPost($post)
71
- ->setSize($args->getSize())
72
- ->setLink($args->getLink())
73
- ->setGalleryIt(($it+1))
74
- ->setTemplate('wordpress/shortcode/gallery.phtml')
75
- ->toHtml();
76
-
77
- $content = str_replace($shortcode->getHtml(), $html, $content);
78
- }
79
- }
80
- }
81
- }
82
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Gist.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Gist extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'gist';
19
- }
20
-
21
- /**
22
- * Retrieve the shortcode ID key
23
- *
24
- * @return string
25
- */
26
- public function getShortcodeIdKey()
27
- {
28
- return 'url';
29
- }
30
-
31
- /**
32
- * Apply the shortcode to the content
33
- *
34
- * @param string $content
35
- * @param Fishpig_Wordpress_Model_Post $post
36
- * @return void
37
- */
38
- public function apply(&$content, Fishpig_Wordpress_Model_Post $post)
39
- {
40
- $content = preg_replace('/(\[' . $this->getTag() . ' .*)([ ]{0,1}\/)(\])/iU', '$1$3', $content);
41
-
42
- return parent::apply($content, $post);
43
- }
44
-
45
- /**
46
- * Apply the Vimeo short code
47
- *
48
- * @param string &$content
49
- * @param Fishpig_Wordpress_Model_Post $post
50
- * @return void
51
- */
52
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
53
- {
54
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
55
- foreach($shortcodes as $shortcode) {
56
- if ($url = $shortcode->getParams()->getUrl()) {
57
- $content = str_replace($shortcode->getHtml(), sprintf($this->_getHtmlString(), $url), $content);
58
- }
59
- }
60
- }
61
- }
62
-
63
- /**
64
- * Retrieve the HTML pattern for the Vimeo
65
- *
66
- * @return string
67
- */
68
- protected function _getHtmlString()
69
- {
70
- return '<script type="text/javascript" src="%s.js"></script>';
71
- }
72
-
73
- /**
74
- * Retrieve the regex pattern for the raw URL's
75
- *
76
- * @return string
77
- */
78
- public function getRawUrlRegex()
79
- {
80
- return '(http[s]{0,1}:\/\/gist\.github\.com\/[0-9]{1,})\s';
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Instagram.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Instagram extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Image sizes
13
- *
14
- * @const int
15
- */
16
- const SIZE_LARGE = 612;
17
- const SIZE_MEDIUM = 306;
18
- const SIZE_THUMBNAIL = 150;
19
-
20
- /**
21
- * Retrieve the shortcode tag
22
- *
23
- * @return string
24
- */
25
- public function getTag()
26
- {
27
- return 'instagram';
28
- }
29
-
30
- /**
31
- * Apply the Vimeo short code
32
- *
33
- * @param string &$content
34
- * @param Fishpig_Wordpress_Model_Post $post
35
- * @return void
36
- */
37
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
38
- {
39
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
40
- foreach($shortcodes as $shortcode) {
41
- $url = $shortcode->getParams()->getUrl();
42
- $width = (int)trim($shortcode->getParams()->getWidth());
43
-
44
- if ($width > self::SIZE_MEDIUM) {
45
- $width = self::SIZE_LARGE;
46
- $size = 'l';
47
- }
48
- else if ($width > self::SIZE_THUMBNAIL) {
49
- $width = self::SIZE_MEDIUM;
50
- $size = 'm';
51
- }
52
- else {
53
- $width = self::SIZE_THUMBNAIL;
54
- $size = 't';
55
- }
56
-
57
- $content = str_replace($shortcode->getHtml(), sprintf($this->_getHtmlString(), $url, $width, $url, $size), $content);
58
- }
59
- }
60
- }
61
-
62
- /**
63
- * Retrieve the HTML pattern for the Vimeo
64
- *
65
- * @return string
66
- */
67
- protected function _getHtmlString()
68
- {
69
- return '<a href="%s"><img width="%s" alt="" src="%smedia/?size=%s"></a>';
70
- }
71
-
72
- /**
73
- * Retrieve the regex pattern for the raw URL's
74
- *
75
- * @return string
76
- */
77
- public function getRawUrlRegex()
78
- {
79
- return '\n(http:\/\/instagram.com\/p\/[a-zA-Z0-9_-]{1,}[\/]{1,})';
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Product.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Product extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'product';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $shortcode) {
32
- $params = $shortcode->getParams();
33
- $collection = Mage::getResourceModel('catalog/product_collection');
34
-
35
- try {
36
- if ($params->getId()) {
37
- $params->setIds(array($params->getId()));
38
- }
39
- else if ($params->getSku()) {
40
- $params->setIds(array(Mage::getResourceModel('catalog/product')->getIdBySku($params->getSku())));
41
- }
42
- else if ($params->getIds()) {
43
- $params->setIds(explode(',', $params->getIds()));
44
- }
45
- else if ($params->getSkus()) {
46
- $ids = array();
47
- $resource = Mage::getResourceModel('catalog/product');
48
-
49
- foreach(explode(',', $params->getSkus()) as $sku) {
50
- if ($id = $resource->getIdBySku($sku)) {
51
- $ids[] = $id;
52
- }
53
- }
54
-
55
- $params->setIds($ids);
56
- }
57
-
58
- if ($params->getIds()) {
59
- $collection->addAttributeToFilter('entity_id', array('in' => $params->getIds()));
60
- }
61
- else if ($params->getAttribute() && ($params->getValue() || $params->getValueId())) {
62
- if ($params->getValue()) {
63
- $attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $params->getAttribute());
64
-
65
- if (!$attribute->getSourceModel()) {
66
- $params->setValueId($params->getValue());
67
- }
68
- else if ($optionId = $attribute->getSource()->getOptionId($params->getValue())) {
69
- $params->setValueId($optionId);
70
- }
71
- }
72
-
73
- if ($params->getValueId()) {
74
- $collection->addAttributeToFilter($attribute->getAttributeCode(), $params->getValueId());
75
- }
76
- else {
77
- throw new Exception('Invalid value/value_id set for attribute in the product shortcode.');
78
- }
79
-
80
- if ($params->getOrder()) {
81
- $collection->setOrder($params->getOrder(), ($params->getDir() ? $params->getDir() : 'asc'));
82
- }
83
-
84
- if ($params->getLimit()) {
85
- $collection->setPageSize((int)$params->getLimit());
86
- }
87
- }
88
- else if (!$params->getIds()) {
89
- throw new Exception('The id, sku, ids or attribute parameter is not set for the product shortcode');
90
- }
91
-
92
- if (!Mage::getStoreConfigFlag('cataloginventory/options/show_out_of_stock')) {
93
- Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
94
- }
95
-
96
- $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
97
- ->addAttributeToFilter('status', 1)
98
- ->addAttributeToFilter('visibility', array('in' => array(2, 4)))
99
- ->load();
100
-
101
- if ($collection->count() === 0) {
102
- throw new Exception('No valid products used in product shortcode');
103
- }
104
-
105
- $template = $params->getTemplate() ? $params->getTemplate() : 'wordpress/shortcode/product.phtml';
106
-
107
- $html = $this->_createBlock('wordpress/shortcode_product')
108
- ->setTemplate($template)
109
- ->setItems($collection)
110
- ->setProducts($collection)
111
- ->setProduct($collection->getFirstItem())
112
- ->setProductId($collection->getFirstItem()->getId())
113
- ->setShortcodeParams($params)
114
- ->toHtml();
115
-
116
- $content = str_replace($shortcode->getHtml(), $html, $content);
117
- }
118
- catch (Exception $e) {
119
- $content = str_replace($shortcode->getHtml(), '', $content);
120
- }
121
- }
122
- }
123
- }
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Scribd.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Scribd extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'scribd';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
31
- foreach($shortcodes as $shortcode) {
32
- if ($id = $shortcode->getParams()->getId()) {
33
- $content = str_replace($shortcode->getHtml(), sprintf($this->_getHtmlString(), $id, $id), $content);
34
- }
35
- }
36
- }
37
- }
38
-
39
- /**
40
- * Retrieve the shortcode middle content
41
- *
42
- * @return string
43
- */
44
- public function getConvertedUrlsMiddle()
45
- {
46
- return ' mode=list id=';
47
- }
48
-
49
- /**
50
- * Retrieve the HTML pattern for the Vimeo
51
- *
52
- * @return string
53
- */
54
- protected function _getHtmlString()
55
- {
56
- return '<iframe class="scribd_iframe_embed" src="http://www.scribd.com/embeds/%s/content" data-aspect-ratio="0.772727272727273" scrolling="no" id="%s" width="625" height="938" frameborder="0"></iframe>
57
- <script type="text/javascript">(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "http://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();</script>';
58
- }
59
-
60
- /**
61
- * Retrieve the regex pattern for the raw URL's
62
- *
63
- * @return string
64
- */
65
- public function getRawUrlRegex()
66
- {
67
- return 'http:\/\/www.scribd.com\/doc\/([0-9]{1,})\/[^\s]{1,}';
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Spotify.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Spotify extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'spotify';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- // Convert URLs to spotify strings
31
- if (preg_match_all('/http[s]{0,1}:\/\/(open|play|embed).spotify.com\/(.*)[\n]{1,}/U', "\n" . $content . "\n", $matches)) {
32
- foreach($matches[2] as $it => $value) {
33
- $content = str_replace(trim(strip_tags($matches[0][$it])), 'spotify:' . str_replace('/', ':', trim(strip_tags($value))), $content);
34
- }
35
- }
36
-
37
- // Convert Spotify URLs to iframes
38
- if (preg_match_all('/[\s]{1,}(spotify:.*)[\s<]{1,}/U', $content, $matches)) {
39
- foreach($matches[1] as $it => $value) {
40
- $content = str_replace($value, $this->_getSpotifyEmbedHtml($value), $content);
41
- }
42
- }
43
-
44
- // Clean up the <p> tags around the iframes that aren't needed
45
- $content = preg_replace('/<p>[\s]{0,}(<iframe.*><\/iframe>)[\s]{0,}<\/p>/U', '$1', $content);
46
-
47
- return $this;
48
- }
49
-
50
- /**
51
- * Retrieve the HTML pattern for the Vimeo
52
- *
53
- * @return string
54
- */
55
- protected function _getSpotifyEmbedHtml($src)
56
- {
57
- return sprintf(
58
- '<iframe src="https://embed.spotify.com/?uri=%s" width="300" height="380" frameborder="0" allowtransparency="true"></iframe>',
59
- $src
60
- );
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Vimeo.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Vimeo extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'vimeo';
19
- }
20
-
21
- /**
22
- * Retrieve the shortcode ID key
23
- *
24
- * @return string
25
- */
26
- public function getShortcodeIdKey()
27
- {
28
- return 'code';
29
- }
30
-
31
- /**
32
- * Apply the Vimeo short code
33
- *
34
- * @param string &$content
35
- * @param Fishpig_Wordpress_Model_Post $post
36
- * @return void
37
- */
38
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
39
- {
40
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
41
- foreach($shortcodes as $shortcode) {
42
- $params = $shortcode->getParams();
43
-
44
- if (!($videoCode = $params->getCode())) {
45
- continue;
46
- }
47
-
48
- $width = $params->getW() ? $params->getW() : 625;
49
- $height = $params->getH() ? $params->getH() : 352;
50
-
51
- $content = str_replace($shortcode->getHtml(), sprintf($this->_getHtmlString(), $videoCode, $width, $height), $content);
52
- }
53
-
54
- $content = str_replace('<p><iframe', '<iframe', $content);
55
- $content = str_replace('</iframe></p>', '</iframe>', $content);
56
- }
57
- }
58
-
59
- /**
60
- * Retrieve the HTML pattern for the Vimeo
61
- *
62
- * @return string
63
- */
64
- protected function _getHtmlString()
65
- {
66
- return '<iframe src="http://player.vimeo.com/video/%s" width="%d" height="%d" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
67
- }
68
-
69
- /**
70
- * Retrieve the regex pattern for the inner URL's
71
- *
72
- * @return string
73
- */
74
- public function getInnerUrlsRegex()
75
- {
76
- return '\[%s http:\/\/vimeo.com\/([0-9]{1,})(.*)\]';
77
- }
78
-
79
- /**
80
- * Retrieve the regex pattern for the raw URL's
81
- *
82
- * @return string
83
- */
84
- public function getRawUrlRegex()
85
- {
86
- return 'http:\/\/vimeo.com\/([0-9]{1,})';
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Shortcode/Youtube.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Shortcode_Youtube extends Fishpig_Wordpress_Helper_Shortcode_Abstract
10
- {
11
- /**
12
- * Retrieve the shortcode tag
13
- *
14
- * @return string
15
- */
16
- public function getTag()
17
- {
18
- return 'youtube';
19
- }
20
-
21
- /**
22
- * Apply the Vimeo short code
23
- *
24
- * @param string &$content
25
- * @param Fishpig_Wordpress_Model_Post $post
26
- * @return void
27
- */
28
- protected function _apply(&$content, Fishpig_Wordpress_Model_Post $post)
29
- {
30
- if (preg_match_all('/\[youtube=(.*)\]/iU', $content, $matches)) {
31
- foreach($matches[1] as $key => $match) {
32
- $content = str_replace($matches[0][$key], sprintf('[%s url=%s]', $this->getTag(), str_replace('&', ' ', $match)), $content);
33
- }
34
- }
35
-
36
- if (($shortcodes = $this->_getShortcodes($content)) !== false) {
37
- foreach($shortcodes as $shortcode) {
38
- $params = $shortcode->getParams();
39
-
40
- // Parse the URLs querystring
41
- parse_str(parse_url($params->getUrl(), PHP_URL_QUERY), $queryString);
42
-
43
- // Remove the URL from the params
44
- $params->unsetData('url');
45
-
46
- // Merge params with query string params
47
- $params = array_merge($params->getData(), $queryString);
48
-
49
- $url = 'https://www.youtube.com/embed/' . $params['v'];
50
-
51
- // Remove the v code from the params
52
- unset($params['v']);
53
-
54
- $url = rtrim($url . '?' . http_build_query($params), '?');
55
-
56
- $content = str_replace(
57
- $shortcode->getHtml(),
58
- $this->_getYoutubeEmbedHtml($url, isset($params['w']) ? $params['w'] : null, isset($params['h']) ? $params['h'] : null),
59
- $content
60
- );
61
- }
62
- }
63
- }
64
-
65
- /**
66
- * Retrieve the HTML pattern for the Vimeo
67
- *
68
- * @return string
69
- */
70
- protected function _getYoutubeEmbedHtml($src, $width = null, $height = null)
71
- {
72
- return sprintf(
73
- '<iframe width="%s" height="%s" src="%s" frameborder="0" allowfullscreen></iframe>',
74
- $width ? $width : 560,
75
- $height ? $height : 315,
76
- $src
77
- );
78
- }
79
-
80
- /**
81
- * Retrieve the content that goes between the shortcode tag and parsed URL
82
- *
83
- * @return string
84
- */
85
- public function getConvertedUrlsMiddle()
86
- {
87
- return '=';
88
- }
89
-
90
- /**
91
- * Retrieve the regex pattern for the raw URL's
92
- *
93
- * @return string
94
- */
95
- public function getRawUrlRegex()
96
- {
97
- return '(http[s]{0,1}:\/\/www.youtube.com\/watch\?.*)';
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/Social.php DELETED
@@ -1,154 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_Social extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Service alias
13
- *
14
- * @const string
15
- */
16
- const SERVICE_SHARETHIS = 'sharethis';
17
-
18
- /**
19
- * Determine whether the social functionality is enabled
20
- *
21
- * @return bool
22
- */
23
- public function isEnabled()
24
- {
25
- return Mage::getStoreConfigFlag('wordpress/social/enabled');
26
- }
27
-
28
- /**
29
- * Get the selected service
30
- *
31
- * @return bool|string
32
- */
33
- public function getService()
34
- {
35
- if (!$this->isEnabled()) {
36
- return false;
37
- }
38
-
39
- $service = trim(Mage::getStoreConfig('wordpress/social/service'));
40
-
41
- return $service !== ''
42
- ? $service
43
- : false;
44
- }
45
-
46
- /**
47
- * Determine whether the selected service is ShareThis
48
- *
49
- * @return bool
50
- */
51
- public function isShareThis()
52
- {
53
- return $this->getService() === self::SERVICE_SHARETHIS;
54
- }
55
-
56
- /**
57
- * Add the required JS/CSS to the head of the page
58
- *
59
- * @return $this
60
- */
61
- public function addCodeToHead()
62
- {
63
- if ($this->isShareThis()) {
64
- $_layout = Mage::getSingleton('core/layout');
65
-
66
- $_layout->getBlock('head')->append(
67
- $_layout->createBlock('core/text')
68
- ->setText(
69
- $this->_getHeadHtml()
70
- )
71
- );
72
- }
73
-
74
- return $this;
75
- }
76
-
77
- /**
78
- * Get the buttons HTML for the given $post and selected service
79
- *
80
- * @param Fishpig_Wordpress_Model_Post $post
81
- * @return string
82
- */
83
- public function getButtons(Fishpig_Wordpress_Model_Post $post)
84
- {
85
- if ($this->isShareThis()) {
86
- $buttonsHtml = $this->_getButtonsHtml();
87
-
88
- if (preg_match_all('/(<span.*)(>.*<\/span>)/Us', $buttonsHtml, $matches)) {
89
- foreach($matches[1] as $it => $prefix) {
90
- $suffix = $matches[2][$it];
91
-
92
- $middle = sprintf(' st_title="%s"', $this->_sanitizeString($post->getPostTitle()));
93
- $middle .= sprintf(' st_url="%s"', $post->getPermalink());
94
-
95
- if ($featuredImage = $post->getFeaturedImage()) {
96
- $middle .= sprintf(' st_image="%s"', $featuredImage->getAvailableImage());
97
- }
98
-
99
- if (($excerpt = trim($post->getMetaValue('_yoast_wpseo_metadesc'))) !== '') {
100
- $middle .= sprintf(' st_summary="%s"', $this->_sanitizeString($excerpt, '<a><span><strong><em>'));
101
- }
102
- else if (($excerpt = trim($post->getData('post_excerpt'))) !== '') {
103
- $middle .= sprintf(' st_summary="%s"', $this->_sanitizeString($excerpt, '<a><span><strong><em>'));
104
- }
105
- else {
106
- $middle .= sprintf(' st_summary="%s"', $this->_sanitizeString($post->getPostExcerpt(20), '<a><span><strong><em>'));
107
- }
108
-
109
- $buttonsHtml = str_replace($matches[0][$it], $prefix . $middle . $suffix, $buttonsHtml);
110
- }
111
-
112
- return $buttonsHtml;
113
- }
114
- }
115
-
116
- return '';
117
- }
118
-
119
- /**
120
- * Get the HTML required for the head of the page
121
- * This is loaded from the Magento configuration
122
- *
123
- * @return string
124
- */
125
- protected function _getHeadHtml()
126
- {
127
- return Mage::getStoreConfig('wordpress/social/head_html');
128
- }
129
-
130
- /**
131
- * Get the raw buttons HTML provided by the social share service
132
- * This is loaded from the Magento configuration
133
- *
134
- * @return string
135
- */
136
- protected function _getButtonsHtml()
137
- {
138
- return Mage::getStoreConfig('wordpress/social/buttons_html');
139
- }
140
-
141
- /**
142
- * Sanitize a string so it becomes a valid HTML element parameter value
143
- *
144
- * @param string $s
145
- * @return string
146
- */
147
- protected function _sanitizeString($s)
148
- {
149
- return addcslashes(
150
- trim(strip_tags($s)),
151
- '"'
152
- );
153
- }
154
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper app/code/community/Fishpig/Wordpress/Helper/System.php DELETED
@@ -1,533 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Helper_System extends Fishpig_Wordpress_Helper_Abstract
10
- {
11
- /**
12
- * Useragent for CURL request
13
- *
14
- * @var string
15
- */
16
- const CURL_USERAGENT = 'FishPig-MagentoWordPressIntegration';
17
-
18
- /**
19
- * Cache for the integration results
20
- *
21
- * @var array
22
- */
23
- protected $_integrationTestResults = null;
24
-
25
- /**
26
- * Generate and retrieve the integration test results
27
- *
28
- * @return array
29
- */
30
- public function getIntegrationTestResults()
31
- {
32
- if (!Mage::helper('wordpress')->isEnabled()) {
33
- return false;
34
- }
35
-
36
- if ($this->_integrationTestResults !== null) {
37
- return $this->_integrationTestResults;
38
- }
39
-
40
- $this->_integrationTestResults = array();
41
-
42
- Mage::dispatchEvent('wordpress_integration_tests_before', array('helper' => $this));
43
-
44
- if ($this->applyTest('_validateDatabaseConnection')) {
45
- if (Mage::helper('wordpress')->isFullyIntegrated()) {
46
- $this->applyTest('_validateHomeUrl');
47
- $this->applyTest('_validatePath');
48
- $this->applyTest('_validateTheme');
49
- $this->applyTest('_validatePlugins', array());
50
- $this->applyTest('_validatePermalinks');
51
- $this->applyTest('_validateHtaccess');
52
- $this->applyTest('_validateL10nPermissions');
53
-
54
- Mage::dispatchEvent('wordpress_integration_tests_after', array('helper' => $this));
55
- }
56
- }
57
-
58
-
59
- return $this->_integrationTestResults;
60
- }
61
-
62
- /**
63
- * Check whether the database is connected
64
- *
65
- * @return void
66
- */
67
- protected function _validateDatabaseConnection()
68
- {
69
- if (Mage::helper('wordpress/app')->getDbConnection() === false) {
70
- throw Fishpig_Wordpress_Exception::error(
71
- 'Database Error',
72
- $this->__('Error establishing a database connection')
73
- . '. You can confirm your WordPress database details by opening the file wp-config.php, which is in your WordPress root directory.'
74
- );
75
- }
76
-
77
- return true;
78
- }
79
-
80
- /**
81
- * Determine whether the blog route is valid
82
- *
83
- * @return Varien_Object
84
- */
85
- protected function _validateHomeUrl()
86
- {
87
- $helper = Mage::helper('wordpress');
88
-
89
- $site = rtrim($helper->getWpOption('siteurl'), '/');
90
- $home = rtrim($helper->getWpOption('home'), '/');
91
- $mage = rtrim(($helper->getUrl()), '/');
92
-
93
- if ($site === $mage) {
94
- throw Fishpig_Wordpress_Exception::error('Site URL',
95
- $this->__('Your integrated blog URL (%s) matches your WordPress Site URL. Either change your blog route below or move WordPress to a different sub-directory.', $mage)
96
- );
97
- }
98
- else if ($mage !== $home) {
99
- throw Fishpig_Wordpress_Exception::error('Home URL',
100
- stripslashes(Mage::helper('wordpress')->__('Your WordPress home URL %s is invalid. Please fix the <a href=\"%s\">home option</a>.', $home, 'http://codex.wordpress.org/Changing_The_Site_URL" target="_blank'))
101
- . $this->__(' Change to %s', $mage)
102
- );
103
- }
104
-
105
- if ($helper->getBlogRoute() && is_dir(Mage::getBaseDir() . DS . $helper->getBlogRoute())) {
106
- throw Fishpig_Wordpress_Exception::error('Home URL',
107
- stripslashes(Mage::helper('wordpress')->__("A '%s' directory exists in your Magento root that will stop your integrated WordPress from displaying. You must delete this before your blog will display.", $helper->getBlogRoute()))
108
- );
109
- }
110
-
111
- return true;
112
- }
113
-
114
- /**
115
- * Ensure the correct WordPress theme is installed
116
- *
117
- * @return bool
118
- */
119
- protected function _validateTheme()
120
- {
121
- if (Mage::helper('wordpress')->getWpOption('template') !== 'twentytwelve') {
122
- throw Fishpig_Wordpress_Exception::error('Themes',
123
- stripslashes(Mage::helper('wordpress')->__('You are using a non-supported WordPress theme that has not been tested. To improve your integration, enable the Twenty Twelve WordPress theme.'))
124
- );
125
- }
126
-
127
- return true;
128
- }
129
-
130
- /**
131
- * Determine whether the WordPress path is valid
132
- *
133
- * @return void
134
- */
135
- protected function _validatePath()
136
- {
137
- if (Mage::helper('wordpress')->getWordPressPath() === false) {
138
- throw Fishpig_Wordpress_Exception::error(
139
- 'WordPress ' . $this->__('Path'),
140
- $this->__("Unable to find a WordPress installation at '%s'", Mage::helper('wordpress')->getRawWordPressPath())
141
- );
142
- }
143
-
144
- return true;
145
- }
146
-
147
- /**
148
- * Validate the plugins/extensions
149
- *
150
- * @param Varien_Object $params
151
- * @return void
152
- */
153
- protected function _validatePlugins(Varien_Object $params)
154
- {
155
- $file = Mage::getModuleDir('etc', 'Fishpig_Wordpress') . DS . 'fishpig.xml';
156
-
157
- if (!is_file($file)) {
158
- return $this;
159
- }
160
-
161
- $xml = simplexml_load_file($file);
162
- $results = $params->getResults();
163
-
164
- foreach((array)$xml->fishpig->extensions as $moduleName => $data) {
165
- $this->applyTest('_validatePlugin', array_merge(
166
- (array)$data,
167
- array('current_version' => (string)Mage::getConfig()->getNode()->modules->$moduleName->version)
168
- ));
169
- }
170
-
171
- $params->setResults($results);
172
-
173
- return $this;
174
- }
175
-
176
- /**
177
- * Validate a single plugin
178
- *
179
- * @param Varien_Object $params
180
- * @return void
181
- */
182
- protected function _validatePlugin(Varien_Object $params)
183
- {
184
- if ($params->getCurrentVersion() && version_compare($params->getNewVersion(), $params->getCurrentVersion(), '>')) {
185
- throw Fishpig_Wordpress_Exception::warning($params->getName(), $this->__('You have version %s installed. Update to %s.',
186
- $params->getCurrentVersion(),
187
- sprintf('<a href="%s" target="_blank">%s</a>', $params->getUrl(), $params->getNewVersion())
188
- ));
189
- }
190
-
191
- if ($params->getId() && !$params->getCurrentVersion()) {
192
- if (Mage::helper('wordpress')->isPluginEnabled($params->getId())) {
193
- throw Fishpig_Wordpress_Exception::warning(
194
- $params->getName(),
195
- $this->__('Extension required for plugin to work. ') . $this->__('Install %s', sprintf('<a href="%s" target="_blank">extension</a>.', $params->getUrl()))
196
- );
197
- }
198
- }
199
-
200
- return $this;
201
- }
202
-
203
- /**
204
- * Ensure that custom permalinks are setup
205
- *
206
- * @return $this
207
- */
208
- protected function _validatePermalinks()
209
- {
210
- Mage::helper('wordpress/app')->init();
211
-
212
- if (Mage::getModel('wordpress/post')->setPostType('post')->getTypeInstance()->useGuidLinks()) {
213
- throw Fishpig_Wordpress_Exception::warning(
214
- 'Permalinks',
215
- 'You are using the default permalinks. To stop potential duplicate content issues, change them to something else in the WordPress Admin.'
216
- );
217
- }
218
-
219
- return $this;
220
- }
221
-
222
- /**
223
- * Ensure the .htaccess file exists and doesn't reference the blog route
224
- *
225
- * @return $this
226
- */
227
- protected function _validateHtaccess()
228
- {
229
- if (isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower($_SERVER["SERVER_SOFTWARE"]), 'nginx') !== false) {
230
- return $this;
231
- }
232
-
233
- if (($path = Mage::helper('wordpress')->getWordPressPath()) !== false) {
234
- $file = rtrim($path, DS) . DS . '.htaccess';
235
-
236
- if (!is_file($file)) {
237
- throw Fishpig_Wordpress_Exception::warning(
238
- '.htaccess',
239
- 'You do not have a WordPress .htaccess file.'
240
- );
241
- }
242
-
243
- if (is_readable($file) && ($data = @file_get_contents($file))) {
244
- $blogRoute = Mage::helper('wordpress')->getBlogRoute();
245
-
246
- if (preg_match('/\nRewriteBase \/' . preg_quote($blogRoute, '/') . '\//i', $data)) {
247
- throw Fishpig_Wordpress_Exception::warning(
248
- '.htaccess',
249
- 'Your .htaccess file references your blog route but should reference your WordPress installation directory.'
250
- );
251
- }
252
- }
253
- }
254
-
255
- return $this;
256
- }
257
-
258
- /**
259
- * Ensure the L10n file is writable if using add-on extensions that use Core
260
- *
261
- * @return $this
262
- **/
263
- protected function _validateL10nPermissions()
264
- {
265
- if (($path = Mage::helper('wordpress')->getWordPressPath()) !== false) {
266
- $file = $path . 'wp-includes' . DS . 'l10n.php';
267
-
268
- if (Mage::getConfig()->getNode('wordpress/core/modules')) {
269
- if (is_file($file) && !is_writable($file)) {
270
- throw Fishpig_Wordpress_Exception::error(
271
- 'Permissions',
272
- 'The following file must be writable: ' . $file
273
- );
274
- }
275
- }
276
- }
277
-
278
- return $this;
279
- }
280
-
281
- /**
282
- * Apply an integration test
283
- *
284
- * @param string $func
285
- * @param array $results
286
- * @param mixed $params = null
287
- * @return mixed
288
- */
289
- public function applyTest($func, $params = null)
290
- {
291
- $funcResult = false;
292
-
293
- try {
294
- if (is_array($params)) {
295
- $params = new Varien_Object($params);
296
- $params->setResults($this->_integrationTestResults);
297
- }
298
- else {
299
- $params = null;
300
- }
301
-
302
- if (is_array($func)) {
303
- $funcResult = call_user_func($func, $params);
304
- }
305
- else {
306
- $funcResult = $this->$func($params);
307
- }
308
-
309
- if ($params) {
310
- $results = $params->getResults();
311
- }
312
-
313
- return true;
314
- }
315
- catch (Fishpig_Wordpress_Exception $e) {
316
- switch($e->getCode()) {
317
- case 1:
318
- $colour = '#00CC33';
319
- break;
320
- case 2:
321
- $colour = 'yellow';
322
- break;
323
- case 3:
324
- $colour = '#FF3333';
325
- break;
326
- default:
327
- $colour = '#444';
328
- }
329
-
330
- $this->_integrationTestResults[] = new Varien_Object(array(
331
- 'title' => Mage::helper('wordpress')->__($e->getMessage()),
332
- 'message' => $e->getLongMessage(),
333
- 'bg_colour' => $colour,
334
- ));
335
- }
336
- catch (Exception $e) {
337
- $this->_integrationTestResults[] = new Varien_Object(array(
338
- 'title' => Mage::helper('wordpress')->__('An unidentified error has occurred.'),
339
- 'message' => $e->getMessage(),
340
- 'bg_colour' => '#444',
341
- ));
342
- }
343
-
344
- return $funcResult;
345
- }
346
-
347
- /**
348
- * Attempt to login to WordPress
349
- *
350
- * @param string $username
351
- * @param string $password
352
- * @param string $destination
353
- * @return bool
354
- */
355
- public function loginToWordPress($username, $password, $destination = null, $redirect = true)
356
- {
357
- if (is_null($destination)) {
358
- $destination = Mage::helper('wordpress')->getAdminUrl('index.php');
359
- }
360
-
361
- // Required for some hosting companies (1&1)
362
- $result = $this->makeHttpGetRequest(Mage::helper('wordpress')->getBaseUrl('wp-login.php'));
363
-
364
- $result = $this->makeHttpPostRequest(Mage::helper('wordpress')->getBaseUrl('wp-login.php'), array(
365
- 'log' => $username,
366
- 'pwd' => $password,
367
- 'rememberme' => 'forever',
368
- 'redirect_to' => $destination,
369
- ));
370
-
371
- if ($result !== false) {
372
- if (strpos($result, 'Location: ') === false) {
373
- throw new Exception('WordPress Auto Login Failed: ' . substr($result, 0, strpos($result, "\r\n\r\n")));
374
- }
375
-
376
- foreach(explode("\n", $result) as $line) {
377
- if (substr(ltrim($line), 0, 1) === '<' && strpos($line, ':') !== false) {
378
- break;
379
- }
380
-
381
- if ($redirect === false && strpos(ltrim($line), 'Location') === 0) {
382
- continue;
383
- }
384
-
385
- header($line, false);
386
- }
387
-
388
- return true;
389
- }
390
-
391
- return false;
392
- }
393
-
394
- public function makeHttpGetRequest($url)
395
- {
396
- if (!$this->hasValidCurlMethods()) {
397
- $ch = curl_init();
398
-
399
- curl_setopt($ch, CURLOPT_URL, $url);
400
- curl_setopt($ch, CURLOPT_USERAGENT, self::CURL_USERAGENT);
401
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
402
- curl_setopt($ch, CURLOPT_HEADER, true);
403
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
404
-
405
- if (strpos($url, 'https://') !== false) {
406
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
407
- }
408
-
409
- $response = curl_exec($ch);
410
-
411
- if (curl_errno($ch) || curl_error($ch)) {
412
- throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', curl_errno($ch), curl_error($ch)));
413
- }
414
-
415
- curl_close($ch);
416
-
417
- return $response;
418
- }
419
-
420
- $curl = new Varien_Http_Adapter_Curl();
421
-
422
- $curl->setConfig(array(
423
- 'verifypeer' => strpos($url, 'https://') !== false,
424
- 'header' => true,
425
- 'timeout' => 15,
426
- 'referrer' => Mage::helper('wordpress')->getBaseUrl('wp-login.php'),
427
- ));
428
-
429
- $curl->addOption(CURLOPT_FOLLOWLOCATION, true);
430
- $curl->addOption(CURLOPT_USERAGENT, self::CURL_USERAGENT);
431
- $curl->addOption(CURLOPT_REFERER, true);
432
-
433
- $curl->write(Zend_Http_Client::GET, $url, '1.1');
434
-
435
- $response = $curl->read();
436
-
437
- if ($curl->getErrno() || $curl->getError()) {
438
- throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', $curl->getErrno(), $curl->getError()));
439
- }
440
-
441
- $curl->close();
442
-
443
- return $response;
444
- }
445
-
446
- /**
447
- * Send a HTTP Post request
448
- *
449
- * @param string $url
450
- * @param array $data = array
451
- * @return false|string
452
- */
453
- public function makeHttpPostRequest($url, array $data = array())
454
- {
455
- if (!$this->hasValidCurlMethods()) {
456
- foreach($data as $key => $value) {
457
- $data[$key] = urlencode($key) . '=' . urlencode($value);
458
- }
459
-
460
- $body = implode('&', $data);
461
-
462
- $ch = curl_init();
463
-
464
- curl_setopt($ch, CURLOPT_URL, $url);
465
- curl_setopt($ch, CURLOPT_POST, count($data));
466
- curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
467
- curl_setopt($ch, CURLOPT_USERAGENT, self::CURL_USERAGENT);
468
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
469
- curl_setopt($ch, CURLOPT_HEADER, true);
470
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
471
-
472
- if (strpos($url, 'https://') !== false) {
473
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
474
- }
475
-
476
- $response = curl_exec($ch);
477
-
478
- if (curl_errno($ch) || curl_error($ch)) {
479
- throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', curl_errno($ch), curl_error($ch)));
480
- }
481
-
482
- curl_close($ch);
483
-
484
- return $response;
485
- }
486
-
487
- $curl = new Varien_Http_Adapter_Curl();
488
-
489
- $curl->setConfig(array(
490
- 'verifypeer' => strpos($url, 'https://') !== false,
491
- 'header' => true,
492
- 'timeout' => 15,
493
- 'referrer' => Mage::helper('wordpress')->getBaseUrl('wp-login.php'),
494
- ));
495
-
496
- $curl->addOption(CURLOPT_FOLLOWLOCATION, false);
497
- $curl->addOption(CURLOPT_USERAGENT, self::CURL_USERAGENT);
498
- $curl->addOption(CURLOPT_REFERER, true);
499
-
500
- $curl->write(Zend_Http_Client::POST, $url, '1.1', array('Expect:'), $data);
501
-
502
- $response = $curl->read();
503
-
504
- if ($curl->getErrno() || $curl->getError()) {
505
- throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', $curl->getErrno(), $curl->getError()));
506
- }
507
-
508
- $curl->close();
509
-
510
- return $response;
511
- }
512
-
513
- /**
514
- * Retrieve the extension version
515
- *
516
- * @param string $extension
517
- * @return string
518
- */
519
- public function getExtensionVersion($extension = 'Fishpig_Wordpress')
520
- {
521
- return (string)Mage::getConfig()->getNode('modules/' . $extension . '/version');
522
- }
523
-
524
- /**
525
- * Has valid CURL methods
526
- *
527
- * @return bool
528
- */
529
- public function hasValidCurlMethods()
530
- {
531
- return method_exists('Varien_Http_Adapter_Curl', 'addOption');
532
- }
533
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Abstract.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- * @info http://fishpig.co.uk/wordpress-integration.html
8
- */
9
-
10
- abstract class Fishpig_Wordpress_Model_Abstract extends Mage_Core_Model_Abstract
11
- {
12
- /**
13
- * Name of entity meta table
14
- * false if entity does not have a meta table
15
- *
16
- * @var string
17
- */
18
- protected $_metaTable = false;
19
-
20
- /**
21
- * Name of entity meta field
22
- *
23
- * @var false|string
24
- */
25
- protected $_metaTableObjectField = false;
26
-
27
- /**
28
- * Determine whether some meta fields have a prefix
29
- * if true, the database table prefix is used
30
- *
31
- * @var bool
32
- */
33
- protected $_metaHasPrefix = false;
34
-
35
- /**
36
- * Array of entity's meta values
37
- *
38
- * @var array
39
- */
40
- protected $_meta = array();
41
-
42
- /**
43
- * An array of all meta keys that have changed
44
- *
45
- * @var array
46
- */
47
- protected $_metaKeysChanged = array();
48
-
49
- /**
50
- * Cache for objects to avoid re-use
51
- *
52
- * @var array (static)
53
- */
54
- static $_objectCache = array();
55
-
56
- /**
57
- * Override load method to provide object cache
58
- *
59
- * @param mixed $id
60
- * @param string $field = null
61
- * @return $this
62
- */
63
- public function load($id, $field=null)
64
- {
65
- if (!is_null($field)) {
66
- $id = $this->_encodeLoadingValue($id, $field);
67
- }
68
-
69
- if ($this->getSkipObjectCache()) {
70
- return parent::load($id, $field);
71
- }
72
-
73
- $class = get_class($this);
74
-
75
- if ($this->getPostType()) {
76
- $class = '::' . $this->getPostType();
77
- }
78
-
79
- if (!isset(self::$_objectCache[$class])) {
80
- self::$_objectCache[$class] = array();
81
- }
82
-
83
- if (is_null($field) && isset(self::$_objectCache[$class][$id])) {
84
- return self::$_objectCache[$class][$id];
85
- }
86
-
87
- parent::load($id, $field);
88
-
89
- if ($this->getId()) {
90
- self::$_objectCache[$class][$id] = $this;
91
- }
92
-
93
- return $this;
94
- }
95
-
96
- /**
97
- * Encode the loading value
98
- *
99
- * @param mixed $value
100
- * @param string $field
101
- * @return string
102
- */
103
- protected function _encodeLoadingValue($value, $field)
104
- {
105
- return strpos($field, 'email') === false
106
- ? urlencode($value)
107
- : $value;
108
- }
109
-
110
- /**
111
- * Retrieve the name of the meta database table
112
- *
113
- * @return false|string
114
- */
115
- public function getMetaTable()
116
- {
117
- if ($this->hasMeta()) {
118
- return $this->getResource()->getTable($this->_metaTable);
119
- }
120
-
121
- return false;
122
- }
123
-
124
- /**
125
- * Retrieve the name of the column used to identify the entity
126
- *
127
- * @return string
128
- */
129
- public function getMetaObjectField()
130
- {
131
- return $this->_metaTableObjectField;
132
- }
133
-
134
- /**
135
- * Retrieve the column name of the primary key fields
136
- *
137
- * @return string
138
- */
139
- public function getMetaPrimaryKeyField()
140
- {
141
- return 'meta_id';
142
- }
143
-
144
- /**
145
- * Determine whether the entity type has a meta table
146
- *
147
- * @return bool
148
- */
149
- public function hasMeta()
150
- {
151
- return $this->_metaTable !== false && $this->_metaTableObjectField !== false;
152
- }
153
-
154
- /**
155
- * Retrieve a meta value
156
- *
157
- * @param string $key
158
- * @return false|string
159
- */
160
- public function getMetaValue($key)
161
- {
162
- if ($this->hasMeta()) {
163
- if (!isset($this->_meta[$key])) {
164
- $value = $this->getResource()->getMetaValue($this, $this->_getRealMetaKey($key));
165
-
166
- $meta = new Varien_Object(array(
167
- 'key' => $key,
168
- 'value' => $value,
169
- ));
170
-
171
- Mage::dispatchEvent($this->_eventPrefix . '_get_meta_value', array('object' => $this, $this->_eventObject => $this, 'meta' => $meta));
172
-
173
- $this->_meta[$key] = $meta->getValue();
174
- }
175
-
176
- return $this->_meta[$key];
177
- }
178
-
179
- return false;
180
- }
181
-
182
- /**
183
- * Get an array of all of the meta values associated with this post
184
- *
185
- * @return false|array
186
- */
187
- public function getAllMetaValues()
188
- {
189
- return $this->hasMeta()
190
- ? $this->getResource()->getAllMetaValues($this)
191
- : false;
192
- }
193
-
194
- /**
195
- * Retrieve all of the meta data as an array
196
- *
197
- * @return false|array
198
- */
199
- public function getMetaData()
200
- {
201
- if ($this->hasMeta()) {
202
- return $this->_meta;
203
- }
204
-
205
- return false;
206
- }
207
-
208
- /**
209
- * Set a custom field
210
- * value isn't saved until entity is saved
211
- *
212
- * @param string $key
213
- * @param mixed $value
214
- * @return $this
215
- */
216
- public function setMetaValue($key, $value)
217
- {
218
- if ($this->hasMeta()) {
219
- $this->_meta[$key] = $value;
220
- $this->_metaKeysChanged[$key] = $key;
221
- $this->_hasDataChanges = true;
222
- }
223
-
224
- return $this;
225
- }
226
-
227
- /**
228
- * Save any meta key values that have changed
229
- *
230
- * @return $this
231
- */
232
- public function afterCommitCallback()
233
- {
234
- parent::afterCommitCallback();
235
-
236
- if ($this->hasMeta()) {
237
- foreach($this->_metaKeysChanged as $index => $key) {
238
- if (isset($this->_meta[$key])) {
239
- $this->getResource()->setMetaValue($this, $this->_getRealMetaKey($key), $this->_meta[$key]);
240
- }
241
-
242
- unset($this->_metaKeysChanged[$index]);
243
- }
244
- }
245
-
246
- return $this;
247
- }
248
-
249
- /**
250
- * Changes the wp_ to the correct table prefix
251
- *
252
- * @param string $key
253
- * @return string
254
- */
255
- protected function _getRealMetaKey($key)
256
- {
257
- if ($this->_metaHasPrefix) {
258
- $tablePrefix = Mage::helper('wordpress/app')->getTablePrefix();
259
-
260
- if ($tablePrefix !== 'wp_') {
261
- if (preg_match('/^(wp_)(.*)$/', $key, $matches)) {
262
- return $tablePrefix . $matches[2];
263
- }
264
- }
265
- }
266
-
267
- return $key;
268
- }
269
-
270
- /**
271
- * Deprecreated from version 2.4.0
272
- * use self::getMetaValue
273
- *
274
- * @param string $key
275
- * @return mixed
276
- */
277
- public function getCustomField($key)
278
- {
279
- return $this->getMetaValue($key);
280
- }
281
-
282
- /**
283
- * Deprecreated from version 2.4.0
284
- * use self::getMetaValue
285
- *
286
- * @param string $key
287
- * @return mixed
288
- */
289
- public function setCustomField($key, $value)
290
- {
291
- return $this->setMetaValue($key, $value);
292
- }
293
-
294
- /**
295
- * Retrieve the event prefix
296
- *
297
- * @return string
298
- */
299
- public function getEventPrefix()
300
- {
301
- return $this->_eventPrefix;
302
- }
303
-
304
- /**
305
- * Retrieve the event object name
306
- *
307
- * @return string
308
- */
309
- public function getEventObject()
310
- {
311
- return $this->_eventObject;
312
- }
313
-
314
- /**
315
- * Get a collection of posts
316
- * Child class should filter posts accordingly
317
- *
318
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
319
- */
320
- public function getPostCollection()
321
- {
322
- return Mage::getResourceModel('wordpress/post_collection')->setFlag('source', $this);
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Archive.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Archive extends Varien_Object
10
- {
11
- public function getName()
12
- {
13
- return Mage::helper('wordpress')->translateDate($this->_getData('name'));
14
- }
15
-
16
- /**
17
- * Load an archive model by it's YYYY/MM
18
- * EG: 2010/06
19
- *
20
- * @param string $value
21
- */
22
- public function load($value)
23
- {
24
- $this->setId($value);
25
-
26
- if (strlen($value) == 7) {
27
- $this->setName(date('F Y', strtotime($value.'/01 01:01:01')));
28
- $this->setDateString(strtotime(str_replace('/', '-', $value) . ' 01:01:01'));
29
- }
30
- else {
31
- $this->setName(date('F j, Y', strtotime($value.' 01:01:01')));
32
- $this->setDateString(strtotime(str_replace('/', '-', $value) . '-01 01:01:01'));
33
- $this->setIsDaily(true);
34
- }
35
-
36
- return $this;
37
- }
38
-
39
- /**
40
- * Get a date formatted string
41
- *
42
- * @param string $format
43
- * @return string
44
- */
45
- public function getDatePart($format)
46
- {
47
- return date($format, $this->getDateString());
48
- }
49
-
50
- /**
51
- * Get the archive page URL
52
- *
53
- * @return string
54
- */
55
- public function getUrl()
56
- {
57
- return rtrim(Mage::helper('wordpress')->getUrl($this->getId()), '/') . '/';
58
- }
59
-
60
- /**
61
- * Determine whether posts exist for this archive
62
- *
63
- * @return bool
64
- */
65
- public function hasPosts()
66
- {
67
- if ($this->hasData('post_count')) {
68
- return $this->getPostCount() > 0;
69
- }
70
-
71
- return $this->getPostCollection()->count() > 0;
72
- }
73
-
74
- /**
75
- * Retrieve a collection of blog posts
76
- *
77
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
78
- */
79
- public function getPostCollection()
80
- {
81
- if (!$this->hasPostCollection()) {
82
- $collection = Mage::getResourceModel('wordpress/post_collection')
83
- ->setFlag('source', $this)
84
- ->addIsViewableFilter()
85
- ->addArchiveDateFilter($this->getId(), $this->getIsDaily())
86
- ->setOrderByPostDate();
87
-
88
- $this->setPostCollection($collection);
89
- }
90
-
91
- return $this->getData('post_collection');
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Image.php DELETED
@@ -1,184 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Image extends Fishpig_Wordpress_Model_Post_Attachment_Abstract
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/image');
14
- }
15
-
16
- /**
17
- * Retrieve the thumbnail image URL
18
- *
19
- * @return string
20
- */
21
- public function getThumbnailImage()
22
- {
23
- return $this->_getImagePath('thumbnail');
24
- }
25
-
26
- /**
27
- * Retrieve the medium image URL
28
- *
29
- * @return string
30
- */
31
- public function getMediumImage()
32
- {
33
- return $this->_getImagePath('medium');
34
- }
35
-
36
- /**
37
- * Retrieve the large image URL
38
- *
39
- * @return string
40
- */
41
- public function getLargeImage()
42
- {
43
- return $this->_getImagePath('large');
44
- }
45
-
46
- /**
47
- * Retrieve the fullsize image URL
48
- *
49
- * @return string
50
- */
51
- public function getFullSizeImage()
52
- {
53
- return $this->_getImagePath();
54
- }
55
-
56
- /**
57
- * Retrieve the post thumbnail image URL
58
- *
59
- * @return string
60
- */
61
- public function getPostThumbnailImage()
62
- {
63
- return $this->_getImagePath('post-thumbnail');
64
- }
65
-
66
- /**
67
- * Retrieve any available image URL
68
- *
69
- * @return string
70
- */
71
- public function getAvailableImage()
72
- {
73
- if ($sizes = $this->getSizes()) {
74
- foreach($sizes as $type => $data) {
75
- return $this->_getImagePath($type);
76
- }
77
- }
78
-
79
- return $this->_getImagePath();
80
- }
81
-
82
- /**
83
- * Retrieve the an image URL by type
84
- *
85
- * @param string $type = 'thumbnail'
86
- * @return string
87
- */
88
- public function getImageByType($type = 'thumbnail')
89
- {
90
- return $this->_getImagePath($type);
91
- }
92
-
93
- /**
94
- * Retrieve the an image URL by type
95
- *
96
- * @param string $type = 'thumbnail'
97
- * @return string
98
- */
99
- protected function _getImagePath($type = null)
100
- {
101
- $filename = null;
102
-
103
- if ($type == null) {
104
- $filename = basename($this->getFile());
105
- }
106
- else {
107
- $sizes = $this->getSizes();
108
-
109
- if (isset($sizes[$type]['file'])) {
110
- $filename = $sizes[$type]['file'];
111
- }
112
- }
113
-
114
- if (!$filename) {
115
- return null;
116
- }
117
-
118
- return $this->_getThisImageUrl().$filename;
119
- }
120
-
121
- /**
122
- * Retrieve the URL to the folder that the image is stored in
123
- *
124
- * @return string
125
- */
126
- protected function _getThisImageUrl()
127
- {
128
- $url = $this->getFileUploadUrl() . dirname($this->getFile()) . '/';
129
-
130
- return Mage::app()->getStore()->isCurrentlySecure()
131
- ? str_replace('http://', 'https://', $url)
132
- : $url;
133
- }
134
-
135
- /**
136
- * Retrieve the upload URL
137
- *
138
- * @return string
139
- */
140
- public function getFileUploadUrl()
141
- {
142
- return Mage::helper('wordpress')->getFileUploadUrl();
143
- }
144
-
145
- /**
146
- * Retrieve the alt text for the image
147
- *
148
- * @return string
149
- */
150
- public function getAltText()
151
- {
152
- return $this->getMetaValue('image_alt');
153
- }
154
-
155
- /**
156
- * Retrieve the description for the image
157
- *
158
- * @return string
159
- */
160
- public function getDescription()
161
- {
162
- return $this->_getData('post_content');
163
- }
164
-
165
- /**
166
- * Retrieve the title for the image
167
- *
168
- * @return string
169
- */
170
- public function getTitle()
171
- {
172
- return $this->_getData('post_title');
173
- }
174
-
175
- /**
176
- * Retrieve the caption for the image
177
- *
178
- * @return string
179
- */
180
- public function getCaption()
181
- {
182
- return $this->_getData('post_excerpt');
183
- }
184
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Menu.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Menu extends Fishpig_Wordpress_Model_Term
10
- {
11
- /**
12
- * Event data
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_menu';
17
- protected $_eventObject = 'menu';
18
-
19
- public function _construct()
20
- {
21
- $this->_init('wordpress/menu');
22
- }
23
-
24
- /**
25
- * Retrieve the taxonomy type
26
- *
27
- * @return string
28
- */
29
- public function getTaxonomy()
30
- {
31
- return 'nav_menu';
32
- }
33
-
34
- /**
35
- * Retrieve the root menu items
36
- *
37
- * @return Fishpig_Wordpress_Model_Resource_Menu_Item_Collection
38
- */
39
- public function getMenuItems()
40
- {
41
- return $this->_getObjectResourceModel()
42
- ->addIsViewableFilter()
43
- ->addTermIdFilter($this->getId(), $this->getTaxonomy());
44
- }
45
-
46
- /**
47
- * Retrieve the object resource model
48
- *
49
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
50
- */
51
- protected function _getObjectResourceModel()
52
- {
53
- return Mage::getResourceModel('wordpress/menu_item_collection')
54
- ->addParentItemIdFilter(0);
55
- }
56
-
57
- /**
58
- * Inject links into $node
59
- *
60
- * @param Varien_Data_Tree_Node $node
61
- * @return bool
62
- */
63
- public function applyToTreeNode($node)
64
- {
65
- if (count($items = $this->getMenuItems()) > 0) {
66
- return $this->_injectLinks($items, $node);
67
- }
68
-
69
- return false;
70
- }
71
-
72
- /**
73
- * Inject links into the top navigation
74
- *
75
- * @param Fishpig_Wordpress_Model_Resource_Menu_Item_Collection $items
76
- * @param Varien_Data_Tree_Node $parentNode
77
- * @return bool
78
- */
79
- protected function _injectLinks($items, $parentNode)
80
- {
81
- if (!$parentNode) {
82
- return false;
83
- }
84
-
85
- foreach($items as $item) {
86
- try {
87
- $nodeId = 'wp-node-' . $item->getId();
88
-
89
- $data = array(
90
- 'name' => $item->getLabel(),
91
- 'id' => $nodeId,
92
- 'url' => $item->getUrl(),
93
- 'is_active' => $item->isItemActive(),
94
- );
95
-
96
- if ($data['is_active']) {
97
- $parentNode->setIsActive(true);
98
- $buffer = $parentNode;
99
-
100
- while($buffer->getParent()) {
101
- $buffer = $buffer->getParent();
102
- $buffer->setIsActive(true);
103
- }
104
- }
105
-
106
- $itemNode = new Varien_Data_Tree_Node($data, 'id', $parentNode->getTree(), $parentNode);
107
- $parentNode->addChild($itemNode);
108
-
109
- if (count($children = $item->getChildrenItems()) > 0) {
110
- $this->_injectLinks($children, $itemNode);
111
- }
112
- }
113
- catch (Exception $e) {
114
- Mage::helper('wordpress')->log($e->getMessage());
115
- }
116
- }
117
-
118
- return true;
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Menu/Item.php DELETED
@@ -1,201 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Menu_Item extends Fishpig_Wordpress_Model_Post
10
- {
11
- /**
12
- * Link types used to determine menu item functionality
13
- *
14
- * @const string
15
- */
16
- const LINK_TYPE_CUSTOM = 'custom';
17
- const LINK_TYPE_POST_TYPE = 'post_type';
18
- const LINK_TYPE_TAXONOMY = 'taxonomy';
19
-
20
- /**
21
- * Prefix of model events names
22
- *
23
- * @var string
24
- */
25
- protected $_eventPrefix = 'wordpress_menu_item';
26
-
27
- /**
28
- * Parameter name in event
29
- *
30
- * @var string
31
- */
32
- protected $_eventObject = 'menu_item';
33
-
34
-
35
- public function _construct()
36
- {
37
- $this->_init('wordpress/menu_item');
38
- }
39
-
40
- /**
41
- * Retrieve the post type for this post
42
- *
43
- * @return string
44
- */
45
- public function getPostType()
46
- {
47
- return 'nav_menu_item';
48
- }
49
-
50
- /**
51
- * Determine whether the link is a custom link
52
- *
53
- * @return bool
54
- */
55
- public function isCustomLink()
56
- {
57
- return $this->getItemType() === self::LINK_TYPE_CUSTOM;
58
- }
59
-
60
- /**
61
- * Determine whether the object type is a post_type
62
- *
63
- * @return bool
64
- */
65
- public function isPostTypeLink()
66
- {
67
- return $this->getItemType() === self::LINK_TYPE_POST_TYPE;
68
- }
69
-
70
- /**
71
- * Determine whether the object type is a post_type
72
- *
73
- * @return bool
74
- */
75
- public function isTaxonomyLink()
76
- {
77
- return $this->getItemType() === self::LINK_TYPE_TAXONOMY;
78
- }
79
-
80
- /**
81
- * Retrieve the link object
82
- *
83
- * @return false|Fishpig_Wordpress_Model_Abstract
84
- */
85
- public function getObject()
86
- {
87
-
88
- $this->setObject(false);
89
-
90
- if (!$this->isCustomLink()) {
91
- if ($this->getObjectType()) {
92
- if ($menuObjectId = $this->getMetaValue('_menu_item_object_id')) {
93
- if ($this->isPostTypeLink()) {
94
- $object = Mage::getModel('wordpress/post')->setPostType($this->getObjectType());
95
- }
96
- else if ($this->isTaxonomyLink()) {
97
- $object = Mage::getModel('wordpress/term')->setTaxonomy($this->getObjectType());
98
- }
99
- else {
100
- $object = Mage::getModel('wordpress/' . $this->getObjectType());
101
- }
102
-
103
- if ($object && $object->setSkipObjectCache(true)->load($menuObjectId)->getId()) {
104
- $this->setObject($object);
105
- }
106
- }
107
- }
108
- }
109
-
110
- return $this->_getData('object');
111
- }
112
-
113
- /**
114
- * Retrieve the menu item type
115
- *
116
- * @return string
117
- */
118
- public function getItemType()
119
- {
120
- return $this->getMetaValue('_menu_item_type');
121
- }
122
-
123
- /**
124
- * Retrieve the object type
125
- *
126
- * @return string
127
- */
128
- public function getObjectType()
129
- {
130
- if (!$this->_getData('object_type')) {
131
- $this->setObjectType($this->getMetaValue('_menu_item_object'));
132
- }
133
-
134
- return $this->_getData('object_type');
135
- }
136
-
137
- /**
138
- * Retrieve the URL for the link
139
- *
140
- * @return string
141
- */
142
- public function getUrl()
143
- {
144
- if ($this->isCustomLink()) {
145
- return $this->getMetaValue('_menu_item_url');
146
- }
147
- else if ($this->getObject() !== false) {
148
- if (in_array($this->getObjectType(), array('page', 'post'))) {
149
- return $this->getObject()->getPermalink();
150
- }
151
- else {
152
- return $this->getObject()->getUrl();
153
- }
154
- }
155
- }
156
-
157
- /**
158
- * Retrieve the link label
159
- *
160
- * @return string
161
- */
162
- public function getLabel()
163
- {
164
- if ($this->getPostTitle() || $this->isCustomLink()) {
165
- return $this->getPostTitle();
166
- }
167
- else if ($this->isPostTypeLink() && $this->getObject()) {
168
- return $this->getObject()->getPostTitle();
169
- }
170
- else if ($this->isTaxonomyLink() && $this->getObject()) {
171
- return $this->getObject()->getName();
172
- }
173
- }
174
-
175
- /**
176
- * Determine whether the link is active
177
- *
178
- * @return bool
179
- */
180
- public function isItemActive()
181
- {
182
- $currentUrl = Mage::getUrl('*/*/*', array('_current' => true, '_use_rewrite' => true));
183
-
184
- if (strpos($currentUrl, '?') !== false) {
185
- $currentUrl = substr($currentUrl, 0, strpos($currentUrl, '?'));
186
- }
187
-
188
- return $currentUrl === $this->getUrl();
189
- }
190
-
191
- /**
192
- * Retrieve children menu items
193
- *
194
- * @return Fishpig_Wordpress_Model_Resource_Menu_Item_Collection
195
- */
196
- public function getChildrenItems()
197
- {
198
- return Mage::getResourceModel('wordpress/menu_item_collection')
199
- ->addParentItemIdFilter($this->getId());
200
- }
201
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Observer.php DELETED
@@ -1,242 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Observer extends Varien_Object
10
- {
11
- /**
12
- * Flag used to ensure observers only run once per cycle
13
- *
14
- * @var static array
15
- */
16
- static protected $_singleton = array();
17
-
18
- /**
19
- * Save the associations
20
- *
21
- * @param Varien_Event_Observer $observer
22
- * @return bool
23
- */
24
- public function saveAssociationsObserver(Varien_Event_Observer $observer)
25
- {
26
- if (!$this->_observerCanRun(__METHOD__)) {
27
- return false;
28
- }
29
-
30
- try {
31
- Mage::helper('wordpress/associations')->processObserver($observer);
32
- }
33
- catch (Exception $e) {
34
- Mage::helper('wordpress')->log($e);
35
- }
36
- }
37
-
38
- /**
39
- * Inject links into the top navigation
40
- *
41
- * @param Varien_Event_Observer $observer
42
- * @return bool
43
- */
44
- public function injectTopmenuLinksObserver(Varien_Event_Observer $observer)
45
- {
46
- if (!$this->_observerCanRun(__METHOD__)) {
47
- return false;
48
- }
49
-
50
- if (Mage::getStoreConfigFlag('wordpress/menu/enabled')) {
51
- return $this->injectTopmenuLinks($observer->getEvent()->getMenu());
52
- }
53
- }
54
-
55
- /**
56
- * Inject links into the Magento topmenu
57
- *
58
- * @param Varien_Data_Tree_Node $topmenu
59
- * @return bool
60
- */
61
- public function injectTopmenuLinks($topmenu, $menuId = null)
62
- {
63
- if (is_null($menuId)) {
64
- $menuId = Mage::getStoreConfig('wordpress/menu/id');
65
- }
66
-
67
- if (!$menuId) {
68
- return false;
69
- }
70
-
71
- $menu = Mage::getModel('wordpress/menu')->load($menuId);
72
-
73
- if (!$menu->getId()) {
74
- return false;
75
- }
76
-
77
- return $menu->applyToTreeNode($topmenu);
78
- }
79
-
80
- /**
81
- * Inject links into the Magento XML sitemap
82
- *
83
- * @param Varien_Data_Tree_Node $topmenu
84
- * @return bool
85
- */
86
- public function injectXmlSitemapLinksObserver(Varien_Event_Observer $observer)
87
- {
88
- $sitemap = $observer
89
- ->getEvent()
90
- ->getSitemap();
91
-
92
- if (!$this->_observerCanRun(__METHOD__ . $sitemap->getStoreId())) {
93
- return false;
94
- }
95
-
96
- try {
97
- $appEmulation = Mage::getSingleton('core/app_emulation');
98
- $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($sitemap->getStoreId());
99
-
100
- if (!Mage::getStoreConfigFlag('wordpress/module/enabled', $sitemap->getStoreId())) {
101
- return false;
102
- }
103
-
104
- $sitemapFilename = Mage::getBaseDir() . '/' . ltrim($sitemap->getSitemapPath() . $sitemap->getSitemapFilename(), '/' . DS);
105
-
106
- if (!file_exists($sitemapFilename)) {
107
- return $this;
108
- }
109
-
110
- $xml = trim(file_get_contents($sitemapFilename));
111
-
112
- // Trim off trailing </urlset> tag so we can add more
113
- $xml = substr($xml, 0, -strlen('</urlset>'));
114
-
115
- // Add the blog homepage
116
- $xml .= sprintf(
117
- '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
118
- htmlspecialchars(Mage::helper('wordpress')->getUrl()),
119
- Mage::getSingleton('core/date')->gmtDate('Y-m-d'),
120
- 'daily',
121
- '1.0'
122
- );
123
-
124
- $posts = Mage::getResourceModel('wordpress/post_collection')
125
- ->addIsViewableFilter()
126
- ->setOrderByPostDate()
127
- ->load();
128
-
129
- foreach($posts as $post) {
130
- $xml .= sprintf(
131
- '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>',
132
- htmlspecialchars($post->getUrl()),
133
- $post->getPostModifiedDate('Y-m-d'),
134
- 'monthly',
135
- '0.5'
136
- );
137
- }
138
-
139
- $xml .= '</urlset>';
140
-
141
- @file_put_contents($sitemapFilename, $xml);
142
- }
143
- catch (Exception $e) {
144
- if (isset($initialEnvironmentInfo)) {
145
- $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
146
- }
147
-
148
- Mage::helper('wordpress')->log($e);
149
- }
150
-
151
- return $this;
152
- }
153
-
154
- /**
155
- * Initialise the configuration for the extension
156
- *
157
- * @param Varien_Event_Observer $observer
158
- * @return $this
159
- */
160
- public function initWordpressConfigObserver(Varien_Event_Observer $observer)
161
- {
162
- return $this;
163
- }
164
-
165
- /**
166
- * Inject content (JS, CSS) from WordPress
167
- *
168
- * @param Varien_Event_Observer $observer
169
- * @return $this
170
- **/
171
- public function injectWordPressContentObserver(Varien_Event_Observer $observer)
172
- {
173
- if (!$this->_observerCanRun(__METHOD__)) {
174
- return $this;
175
- }
176
-
177
- if (Mage::helper('wordpress')->isApiRequest()) {
178
- return $this;
179
- }
180
-
181
- $modulesConfigObjects = Mage::getConfig()->getNode('wordpress/core/modules');
182
-
183
- if (!$modulesConfigObjects) {
184
- return $this;
185
- }
186
-
187
- $modules = array_keys($modulesConfigObjects->asArray());
188
- $content = array();
189
-
190
- foreach($modules as $module) {
191
- if ($code = trim(Mage::getSingleton($module . '/observer')->getHeadFooterContent())) {
192
- $content[] = $code;
193
- }
194
- }
195
-
196
- if (count($content) === 0) {
197
- return $this;
198
- }
199
-
200
- $bodyHtml = $observer->getEvent()
201
- ->getFront()
202
- ->getResponse()
203
- ->getBody();
204
-
205
- $baseUrl = Mage::helper('wordpress')->getBaseUrl();
206
- $jsTemplate = '<script type="text/javascript" src="%s"></script>';
207
-
208
- if (Mage::getStoreConfigFlag('wordpress/misc/include_underscore')) {
209
- array_unshift($content, sprintf($jsTemplate, $baseUrl . 'wp-includes/js/underscore.min.js?ver=1.6.0'));
210
- }
211
-
212
- if (Mage::getStoreConfigFlag('wordpress/misc/include_jquery')) {
213
- array_unshift($content, sprintf($jsTemplate, $baseUrl . 'wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'));
214
- array_unshift($content, sprintf($jsTemplate, $baseUrl . 'wp-includes/js/jquery/jquery.js?ver=1.12.4'));
215
- }
216
-
217
- $observer->getEvent()
218
- ->getFront()
219
- ->getResponse()
220
- ->setBody(str_replace('</body>', implode('', $content) . '</body>', $bodyHtml));
221
-
222
- return $this;
223
- }
224
-
225
- /**
226
- * Determine whether the observer method can run
227
- * This stops methods being called twice in a single cycle
228
- *
229
- * @param string $method
230
- * @return bool
231
- */
232
- protected function _observerCanRun($method)
233
- {
234
- if (!isset(self::$_singleton[$method])) {
235
- self::$_singleton[$method] = true;
236
-
237
- return true;
238
- }
239
-
240
- return false;
241
- }
242
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post.php DELETED
@@ -1,699 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Post extends Fishpig_Wordpress_Model_Abstract
10
- {
11
- /**
12
- * Entity meta infromation
13
- *
14
- * @var string
15
- */
16
- protected $_metaTable = 'wordpress/post_meta';
17
- protected $_metaTableObjectField = 'post_id';
18
-
19
- /**
20
- * Event data
21
- *
22
- * @var string
23
- */
24
- protected $_eventPrefix = 'wordpress_post';
25
- protected $_eventObject = 'post';
26
-
27
- /**
28
- * Set the model's resource
29
- *
30
- * @return void
31
- */
32
- public function _construct()
33
- {
34
- $this->_init('wordpress/post');
35
- }
36
-
37
- /**
38
- * Set the categories after loading
39
- *
40
- * @return $this
41
- */
42
- protected function _afterLoad()
43
- {
44
- parent::_afterLoad();
45
-
46
- $this->getResource()->preparePosts(array($this));
47
-
48
- return $this;
49
- }
50
-
51
- /**
52
- * Returns the permalink used to access this post
53
- *
54
- * @return string
55
- */
56
- public function getPermalink()
57
- {
58
- return $this->getUrl();
59
- }
60
-
61
- public function getPostFormat()
62
- {
63
- if (!$this->hasPostFormat()) {
64
- $this->setPostFormat(false);
65
-
66
- $formats = Mage::getResourceModel('wordpress/term_collection')
67
- ->addTaxonomyFilter('post_format')
68
- ->setPageSize(1)
69
- ->load();
70
-
71
- if (count($formats) > 0) {
72
- $this->setPostFormat(
73
- str_replace('post-format-', '', $formats->getFirstItem()->getSlug())
74
- );
75
- }
76
- }
77
-
78
- return $this->_getData('post_format');
79
- }
80
-
81
- /**
82
- * Retrieve the post GUID
83
- *
84
- * @return string
85
- */
86
- public function getGuid()
87
- {
88
- if ($this->getPostType() === 'page') {
89
- return Mage::helper('wordpress')->getUrl() . '?page_id=' . $this->getId();
90
- }
91
- else if ($this->getPostType() === 'post') {
92
- return Mage::helper('wordpress')->getUrl() . '?p=' . $this->getId();
93
- }
94
-
95
- return Mage::helper('wordpress')->getUrl() . '?p=' . $this->getId() . '&post_type=' . $this->getPostType();
96
- }
97
-
98
- /**
99
- * Retrieve the post excerpt
100
- * If no excerpt, try to shorten the post_content field
101
- *
102
- * @return string
103
- */
104
- public function getPostExcerpt($maxWords = 0)
105
- {
106
- if (!$this->getData('post_excerpt')) {
107
- if ($this->hasMoreTag()) {
108
- $this->setPostExcerpt($this->_getPostTeaser(true));
109
- }
110
- else if ((int)$maxWords > 1) {
111
- $excerpt = trim(strip_tags(str_replace(array("\n", ' ', ' '), ' ', $this->_getData('post_content'))));
112
- $excerpt = preg_replace('/\[[\/]{0,1}[^\]]{1,}\]/', '', $excerpt);
113
- $excerpt = explode(' ', $excerpt);
114
-
115
- if (count($excerpt) > $maxWords) {
116
- $excerpt = rtrim(implode(' ', array_slice($excerpt, 0, $maxWords)), "!@£$%^&*()_-+=[{]};:'\",<.>/? ") . '...';
117
- }
118
- else {
119
- $excerpt = implode(' ', $excerpt);
120
- }
121
-
122
- return $excerpt;
123
- }
124
- else {
125
- $this->setPostExcerpt($this->getPostContent('excerpt'));
126
- }
127
- }
128
-
129
- return $this->getData('post_excerpt');
130
- }
131
-
132
- /**
133
- * Determine twhether the post has a more tag in it's content field
134
- *
135
- * @return bool
136
- */
137
- public function hasMoreTag()
138
- {
139
- return strpos($this->getData('post_content'), '<!--more') !== false;
140
- }
141
-
142
- /**
143
- * Retrieve the post teaser
144
- * This is the data from the post_content field upto to the MORE_TAG
145
- *
146
- * @return string
147
- */
148
- protected function _getPostTeaser($includeSuffix = true)
149
- {
150
- if ($this->hasMoreTag()) {
151
- $content = $this->getPostContent('excerpt');
152
-
153
- if (preg_match('/<!--more (.*)-->/', $content, $matches)) {
154
- $anchor = $matches[1];
155
- $split = $matches[0];
156
- }
157
- else {
158
- $split = '<!--more-->';
159
- $anchor = $this->_getTeaserAnchor();
160
- }
161
-
162
- $excerpt = trim(substr($content, 0, strpos($content, $split)));
163
-
164
- if ($excerpt !== '' && $includeSuffix && $anchor) {
165
- $excerpt .= sprintf(' <a href="%s" class="read-more">%s</a>', $this->getPermalink(), $anchor);
166
- }
167
-
168
- return $excerpt;
169
- }
170
-
171
- return null;
172
- }
173
-
174
- /**
175
- * Get the parent term
176
- * This is the term with the taxonomy as $taxonomy with the lowest term_id
177
- * If Yoast SEO is installed, the primary category will be used (if $taxonomy === category)
178
- *
179
- * @param string $taxonomy
180
- * @return Fishpig_Wordpress_Model_Term
181
- **/
182
- public function getParentTerm($taxonomy)
183
- {
184
- if ($taxonomy === 'category' && Mage::helper('wordpress')->isAddonInstalled('WordPressSEO')) {
185
- if ($category = Mage::helper('wp_addon_yoastseo')->getPostPrimaryCategory($this)) {
186
- return $category;
187
- }
188
- }
189
-
190
- $terms = $this->getTermCollection($taxonomy)
191
- ->setPageSize(1)
192
- ->setCurPage(1)
193
- ->load();
194
-
195
- return count($terms) > 0 ? $terms->getFirstItem() : false;
196
- }
197
-
198
- /**
199
- * Get a collection of terms by the taxonomy
200
- *
201
- * @param string $taxonomy
202
- * @return Fishpig_Wordpress_Model_Resource_Term_Collection
203
- */
204
- public function getTermCollection($taxonomy)
205
- {
206
- return Mage::getResourceModel('wordpress/term_collection')
207
- ->addTaxonomyFilter($taxonomy)
208
- ->addPostIdFilter($this->getId());
209
- }
210
-
211
- /**
212
- * Retrieve a collection of all parent categories
213
- *
214
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Category_Collection
215
- */
216
- public function getParentCategories()
217
- {
218
- return $this->getTermCollection('category');
219
- }
220
-
221
- /**
222
- * Gets a collection of post tags
223
- *
224
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Tag_Collection
225
- */
226
- public function getTags()
227
- {
228
- return $this->getTermCollection('post_tag');
229
- }
230
-
231
- /**
232
- * Retrieve the read more anchor text
233
- *
234
- * @return string|false
235
- */
236
- protected function _getTeaserAnchor()
237
- {
238
- // Allows translation
239
- return stripslashes(Mage::helper('wordpress')->__('Continue reading <span class=\"meta-nav\">&rarr;</span>'));
240
- }
241
-
242
- /**
243
- * Retrieve the previous post
244
- *
245
- * @return false|Fishpig_Wordpress_Model_Post
246
- */
247
- public function getPreviousPost()
248
- {
249
- if (!$this->hasPreviousPost()) {
250
- $this->setPreviousPost(false);
251
-
252
- $collection = Mage::getResourceModel('wordpress/post_collection')
253
- ->addIsViewableFilter()
254
- ->addPostTypeFilter($this->getPostType())
255
- ->addPostDateFilter(array('lt' => $this->_getData('post_date')))
256
- ->setPageSize(1)
257
- ->setCurPage(1)
258
- ->setOrderByPostDate()
259
- ->load();
260
-
261
- if ($collection->count() > 0) {
262
- $this->setPreviousPost($collection->getFirstItem());
263
- }
264
- }
265
-
266
- return $this->_getData('previous_post');
267
- }
268
-
269
- /**
270
- * Retrieve the next post
271
- *
272
- * @return false|Fishpig_Wordpress_Model_Post
273
- */
274
- public function getNextPost()
275
- {
276
- if (!$this->hasNextPost()) {
277
- $this->setNextPost(false);
278
-
279
- $collection = Mage::getResourceModel('wordpress/post_collection')
280
- ->addIsViewableFilter()
281
- ->addPostTypeFilter($this->getPostType())
282
- ->addPostDateFilter(array('gt' => $this->_getData('post_date')))
283
- ->setPageSize(1)
284
- ->setCurPage(1)
285
- ->setOrderByPostDate('asc')
286
- ->load();
287
-
288
- if ($collection->count() > 0) {
289
- $this->setNextPost($collection->getFirstItem());
290
- }
291
- }
292
-
293
- return $this->_getData('next_post');
294
- }
295
-
296
- public function isType($type)
297
- {
298
- return $this->getPostType() === $type;
299
- }
300
-
301
- public function getTypeInstance()
302
- {
303
- if (!$this->hasTypeInstance() && $this->getPostType()) {
304
- if ($this->getPostType() === 'revision') {
305
- if ($this->getParentPost()) {
306
- $this->setTypeInstance(
307
- $this->getParentPost()->getTypeInstance()
308
- );
309
- }
310
- }
311
- else if ($typeInstance = Mage::helper('wordpress/app')->getPostType($this->getPostType())) {
312
- $this->setTypeInstance($typeInstance);
313
- }
314
- else {
315
- $this->setTypeInstance(Mage::helper('wordpress/app')->getPostType('post'));
316
- }
317
- }
318
-
319
- return $this->_getData('type_instance');
320
- }
321
-
322
- /**
323
- * Inject string 'Protected: ' on password protected posts
324
- *
325
- * @return string
326
- */
327
- public function getPostTitle()
328
- {
329
- if ($this->getPostPassword() !== '') {
330
- return Mage::helper('wordpress')->__('Protected: %s', $this->_getData('post_title'));
331
- }
332
-
333
- return $this->_getData('post_title');
334
- }
335
-
336
- /**
337
- * Retrieve the URL for the comments feed
338
- *
339
- * @return string
340
- */
341
- public function getCommentFeedUrl()
342
- {
343
- return rtrim($this->getPermalink(), '/') . '/feed/';
344
- }
345
-
346
- /**
347
- * Gets the post content
348
- *
349
- * @return string
350
- */
351
- public function getPostContent($context = 'full')
352
- {
353
- $key = rtrim('filtered_post_content_' . $context, '_');
354
-
355
- if (!$this->hasData($key)) {
356
- $this->setData($key, Mage::helper('wordpress/filter')->applyFilters($this->_getData('post_content'), $this, $context));
357
- }
358
-
359
- return $this->_getData($key);
360
- }
361
-
362
- /**
363
- * Returns a collection of comments for this post
364
- *
365
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Comment_Collection
366
- */
367
- public function getComments()
368
- {
369
- if (!$this->hasData('comments')) {
370
- $this->setData('comments', $this->getResource()->getPostComments($this));
371
- }
372
-
373
- return $this->getData('comments');
374
- }
375
-
376
- /**
377
- * Returns a collection of images for this post
378
- *
379
- * @return Fishpig_Wordpress_Model_Mysql4_Image_Collection
380
- *
381
- * NB. This function has not been thoroughly tested
382
- * Please report any bugs
383
- */
384
- public function getImages()
385
- {
386
- if (!$this->hasData('images')) {
387
- $this->setImages(Mage::getResourceModel('wordpress/image_collection')->setParent($this->getData('ID')));
388
- }
389
-
390
- return $this->getData('images');
391
- }
392
-
393
- /**
394
- * Get images embedded in the post
395
- *
396
- * @return false|array
397
- **/
398
- public function getEmbeddedImages()
399
- {
400
- if (!$this->hasEmbeddedImages()) {
401
- $this->setEmbeddedImages(false);
402
-
403
- if (preg_match_all('/<img[^>]{1,}src=([\'"]{1})(.*)\1/U', $this->getPostContent(), $matches)) {
404
- $this->setEmbeddedImages(array_unique($matches[2]));
405
- }
406
- }
407
-
408
- return $this->_getData('embedded_images');
409
- }
410
-
411
- /**
412
- * Returns the featured image for the post
413
- *
414
- * This image must be uploaded and assigned in the WP Admin
415
- *
416
- * @return Fishpig_Wordpress_Model_Image
417
- */
418
- public function getFeaturedImage()
419
- {
420
- if (!$this->hasData('featured_image')) {
421
- $this->setFeaturedImage($this->getResource()->getFeaturedImage($this));
422
- }
423
-
424
- return $this->getData('featured_image');
425
- }
426
-
427
- /**
428
- * Get the model for the author of this post
429
- *
430
- * @return Fishpig_Wordpress_Model_Author
431
- */
432
- public function getAuthor()
433
- {
434
- return Mage::getModel('wordpress/user')->load($this->getAuthorId());
435
- }
436
-
437
- /**
438
- * Returns the author ID of the current post
439
- *
440
- * @return int
441
- */
442
- public function getAuthorId()
443
- {
444
- return $this->getData('post_author');
445
- }
446
-
447
- /**
448
- * Returns the post date formatted
449
- * If not format is supplied, the format specified in your Magento config will be used
450
- *
451
- * @return string
452
- */
453
- public function getPostDate($format = null)
454
- {
455
- if (($date = $this->getData('post_date_gmt')) === '0000-00-00 00:00:00' || $date === '') {
456
- $date = now();
457
- }
458
-
459
- return Mage::helper('wordpress')->formatDate($date, $format);
460
- }
461
-
462
- /**
463
- * Returns the post date formatted
464
- * If not format is supplied, the format specified in your Magento config will be used
465
- *
466
- * @return string
467
- */
468
- public function getPostModifiedDate($format = null)
469
- {
470
- if (($date = $this->getData('post_modified_gmt')) === '0000-00-00 00:00:00' || $date === '') {
471
- $date = now();
472
- }
473
-
474
- return Mage::helper('wordpress')->formatDate($date, $format);
475
- }
476
-
477
- /**
478
- * Returns the post time formatted
479
- * If not format is supplied, the format specified in your Magento config will be used
480
- *
481
- * @return string
482
- */
483
- public function getPostTime($format = null)
484
- {
485
- if (($date = $this->getData('post_date_gmt')) === '0000-00-00 00:00:00' || $date === '') {
486
- $date = now();
487
- }
488
-
489
- return Mage::helper('wordpress')->formatDate($date, $format);
490
- }
491
-
492
- /**
493
- * Determine whether the post has been published
494
- *
495
- * @return bool
496
- */
497
- public function isPublished()
498
- {
499
- return $this->getPostStatus() == 'publish';
500
- }
501
-
502
- /**
503
- * Determine whether the post has been published
504
- *
505
- * @return bool
506
- */
507
- public function isPending()
508
- {
509
- return $this->getPostStatus() == 'pending';
510
- }
511
-
512
- /**
513
- * Retrieve the preview URL
514
- *
515
- * @return string
516
- */
517
- public function getPreviewUrl()
518
- {
519
- if ($this->isPending()) {
520
- return Mage::helper('wordpress')->getUrl('?p=' . $this->getId() . '&preview=1');
521
- }
522
-
523
- return '';
524
- }
525
-
526
- /**
527
- * Determine whether the current user can view the post/page
528
- * If visibility is protected and user has supplied wrong password, return false
529
- *
530
- * @return bool
531
- */
532
- public function isViewableForVisitor()
533
- {
534
- return $this->getPostPassword() === ''
535
- || Mage::getSingleton('core/session')->getPostPassword() == $this->getPostPassword();
536
- }
537
-
538
- /**
539
- * Determine whether the post is a sticky post
540
- * This only works if the post collection has been loaded with addStickyPostsToCollection
541
- *
542
- * @return bool
543
- */
544
- public function isSticky()
545
- {
546
- return $this->_getData('is_sticky');
547
- }
548
-
549
- /**
550
- * Determine whether a post object can be viewed
551
- *
552
- * @return string
553
- */
554
- public function canBeViewed()
555
- {
556
- return $this->isPublished()
557
- || ($this->getPostStatus() === 'private' && Mage::getSingleton('customer/session')->isLoggedIn());
558
- }
559
-
560
- /**
561
- * Wrapper for self::getPermalink()
562
- *
563
- * @return string
564
- */
565
- public function getUrl()
566
- {
567
- if (!$this->hasUrl()) {
568
- $this->setUrl($this->getGuid());
569
-
570
- if ($this->hasPermalink()) {
571
- $this->setUrl(Mage::helper('wordpress')->getUrl(
572
- $this->_urlEncode($this->_getData('permalink'))
573
- ));
574
- }
575
- else if ($this->getTypeInstance()->isHierarchical()) {
576
- if ($uris = $this->getTypeInstance()->getAllRoutes()) {
577
- if (isset($uris[$this->getId()])) {
578
- $this->setUrl(Mage::helper('wordpress')->getUrl($uris[$this->getId()] . '/'));
579
- }
580
- }
581
- }
582
- }
583
-
584
- return $this->_getData('url');
585
- }
586
-
587
- /**
588
- * Encode the URL, ignoring '/' character
589
- *
590
- * @param string $url
591
- * @return string
592
- */
593
- protected function _urlEncode($url)
594
- {
595
- if (strpos($url, '/') !== false) {
596
- $parts = explode('/', $url);
597
-
598
- foreach($parts as $key => $value) {
599
- $parts[$key] = urlencode($value);
600
- }
601
-
602
- return implode('/', $parts);
603
- }
604
-
605
- return urlencode($url);
606
- }
607
-
608
- /**
609
- * Get the parent ID of the post
610
- *
611
- * @return int
612
- */
613
- public function getParentId()
614
- {
615
- return (int)$this->_getData('post_parent');
616
- }
617
-
618
- /**
619
- * Retrieve the parent page
620
- *
621
- * @return false|Fishpig_Wordpress_Model_Post
622
- */
623
- public function getParentPost()
624
- {
625
- if (!$this->hasParentPost()) {
626
- $this->setParentPost(false);
627
-
628
- if ($this->getParentId()) {
629
- $parent = Mage::getModel('wordpress/post')
630
- ->setPostType($this->getPostType() === 'revision' ? '*' : $this->getPostType())
631
- ->load($this->getParentId());
632
-
633
- if ($parent->getId()) {
634
- $this->setParentPost($parent);
635
- }
636
- }
637
- }
638
-
639
- return $this->_getData('parent_post');
640
- }
641
-
642
- /**
643
- * Retrieve the page's children pages
644
- *
645
- * @return Fishpig_Wordpress_Model_Mysql_Page_Collection
646
- */
647
- public function getChildrenPosts()
648
- {
649
- return $this->getCollection()
650
- ->addPostParentIdFilter($this->getId());
651
- }
652
-
653
- /**
654
- * Determine whether children exist
655
- *
656
- * @return bool
657
- */
658
- public function hasChildrenPosts()
659
- {
660
- return $this->getResource()->hasChildrenPosts($this);
661
- }
662
-
663
- /**
664
- * The methods here are legacy methods that have been ported over from the old Page class
665
- * These are deprecated and will be removed shortly.
666
- */
667
-
668
- public function getMenuLabel()
669
- {
670
- return $this->getPostTitle();
671
- }
672
-
673
- public function getParentPage()
674
- {
675
- return $this->isType('page')
676
- ? $this->getParentPost()
677
- : false;
678
- }
679
-
680
- public function hasChildren()
681
- {
682
- return $this->hasChildrenPosts();
683
- }
684
-
685
- public function getChildren()
686
- {
687
- return $this->getChildrenPosts();
688
- }
689
-
690
- public function isHomepagePage()
691
- {
692
- return $this->isType('page') && (int)$this->getId() === (int)Mage::helper('wordpress/router')->getHomepagePageId();
693
- }
694
-
695
- public function isBlogListingPage()
696
- {
697
- return $this->isType('page') && (int)$this->getId() === (int)Mage::helper('wordpress/router')->getBlogPageId();
698
- }
699
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Attachment/Abstract.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Model_Post_Attachment_Abstract extends Fishpig_Wordpress_Model_Post
10
- {
11
-
12
- protected function _afterLoad()
13
- {
14
- $this->loadSerializedData();
15
-
16
- return parent::_afterLoad();
17
- }
18
-
19
- /**
20
- * Load the serialized attachment data
21
- *
22
- */
23
- public function loadSerializedData()
24
- {
25
- if ($this->getId() > 0 && !$this->getIsFullyLoaded()) {
26
- $this->setIsFullyLoaded(true);
27
-
28
- $select = Mage::helper('wordpress/app')->getDbConnection()
29
- ->select()
30
- ->from($this->getResource()->getTable('wordpress/post_meta'), 'meta_value')
31
- ->where('meta_key=?', '_wp_attachment_metadata')
32
- ->where('post_id=?', $this->getId())
33
- ->limit(1);
34
-
35
- $data = unserialize(Mage::helper('wordpress/app')->getDbConnection()->fetchOne($select));
36
-
37
- if (is_array($data)) {
38
- foreach($data as $key => $value) {
39
- $this->setData($key, $value);
40
- }
41
- }
42
- }
43
- }
44
-
45
- public function getMetaValue($key)
46
- {
47
- return parent::getMetaValue('_wp_attachment_' . $key);
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Comment.php DELETED
@@ -1,232 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Post_Comment extends Fishpig_Wordpress_Model_Abstract
10
- {
11
- /**
12
- * Base URL used for Gravatar images
13
- *
14
- * @var const string
15
- */
16
- const GRAVATAR_BASE_URL = 'http://www.gravatar.com/avatar/';
17
- const GRAVATAR_BASE_URL_SECURE = 'https://secure.gravatar.com/avatar/';
18
-
19
- public function _construct()
20
- {
21
- $this->_init('wordpress/post_comment');
22
- }
23
-
24
- /**
25
- * Retrieve the post that this comment is associated to
26
- *
27
- * @return Fishpig_Wordpress_Model_Post
28
- */
29
- public function getPost()
30
- {
31
- if (!$this->hasPost()) {
32
- $post = Mage::getModel('wordpress/post')
33
- ->setPostType('*')
34
- ->load((int)$this->getData('comment_post_ID'));
35
-
36
- $this->setPost($post->getId() ? $post : false);
37
- }
38
-
39
- return $this->getData('post');
40
- }
41
-
42
- /**
43
- * Returns the comment date
44
- * If no format is specified, the default format is used from the Magento config
45
- *
46
- * @return string
47
- */
48
- public function getCommentDate($format = null)
49
- {
50
- return Mage::helper('wordpress')->formatDate($this->getData('comment_date'), $format);
51
- }
52
-
53
- /**
54
- * Returns the comment time
55
- * If no format is specified, the default format is used from the Magento config
56
- *
57
- * @return string
58
- */
59
- public function getCommentTime($format = null)
60
- {
61
- return Mage::helper('wordpress')->formatTime($this->getData('comment_date'), $format);
62
- }
63
-
64
- /**
65
- * Return the URL for the comment author
66
- *
67
- * @return string
68
- */
69
- public function getCommentAuthorUrl()
70
- {
71
- if ($url = $this->_getData('comment_author_url')) {
72
- if (strpos($url, 'http') !== 0) {
73
- $url = 'http://' . $url;
74
- }
75
-
76
- return $url;
77
- }
78
-
79
- return '#';
80
- }
81
-
82
- /**
83
- * Get the comment GUID
84
- *
85
- * @return string
86
- */
87
- public function getGuid()
88
- {
89
- return Mage::helper('wordpress')->getUrl('?p='. $this->getPost()->getId() . '#comment-' . $this->getId());
90
- }
91
-
92
- /**
93
- * Retrieve the URL for this comment
94
- *
95
- * @return string
96
- */
97
- public function getUrl()
98
- {
99
- if (!$this->hasUrl()) {
100
- if ($post = $this->getPost()) {
101
- $pageId = '';
102
-
103
- if (Mage::helper('wordpress')->getWpOption('page_comments')) {
104
- $pageId = '/comment-page-' . $this->getCommentPageId();
105
- }
106
-
107
- $fragment = '#comment-' . $this->getId();
108
-
109
- if ($post->getTypeInstance()->permalinkHasTrainingSlash()) {
110
- $fragment = '/' . $fragment;
111
- }
112
-
113
- $this->setUrl(rtrim($post->getUrl(), '/') . $pageId . $fragment);
114
- }
115
- }
116
-
117
- return $this->getData('url');
118
- }
119
-
120
- /**
121
- * Retrieve the page number that the comment is on
122
- *
123
- * @return int
124
- */
125
- public function getCommentPageId()
126
- {
127
- if (!$this->hasCommentPageId()) {
128
- $this->setCommentPageId(1);
129
- if ($post = $this->getPost()) {
130
- $totalComments = count($post->getComments());
131
- $commentsPerPage = Mage::helper('wordpress')->getWpOption('comments_per_page', 50);
132
-
133
- if ($commentsPerPage > 0 && $totalComments > $commentsPerPage) {
134
- $it = 0;
135
-
136
- foreach($post->getComments() as $comment) { ++$it;
137
- if ($this->getId() == $comment->getId()) {
138
- $position = $it;
139
- break;
140
- }
141
- }
142
-
143
- $this->setCommentPageId(ceil($position / $commentsPerPage));
144
- }
145
- else {
146
- $this->setCommentPageId(1);
147
- }
148
- }
149
- }
150
-
151
- return $this->getData('comment_page_id');
152
- }
153
-
154
- /**
155
- * Retrieve the child comments
156
- *
157
- * @return Varien_Data_Collection
158
- */
159
- public function getChildrenComments()
160
- {
161
- return $this->getCollection()
162
- ->addCommentApprovedFilter()
163
- ->addParentCommentFilter($this->getId())
164
- ->addOrderByDate();
165
- }
166
-
167
- /**
168
- * Retrieve the Gravatar URL for the comment
169
- *
170
- * @return null|string
171
- */
172
- public function getAvatarUrl($size = 50)
173
- {
174
- if (!$this->hasGravatarUrl()) {
175
- if (Mage::helper('wordpress')->getWpOption('show_avatars')) {
176
- if ($this->getCommentAuthorEmail()) {
177
- $params = array(
178
- 'r' => Mage::helper('wordpress')->getWpOption('avatar_rating'),
179
- 's' => (int)$size,
180
- 'd' => Mage::helper('wordpress')->getWpOption('avatar_default'),
181
- 'v' => 45345
182
- );
183
-
184
- $baseUrl = Mage::app()->getStore()->isCurrentlySecure()
185
- ? self::GRAVATAR_BASE_URL_SECURE
186
- : self::GRAVATAR_BASE_URL;
187
-
188
- $url = $baseUrl
189
- . md5(strtolower($this->getCommentAuthorEmail()))
190
- . '/?' . http_build_query($params);
191
-
192
- $this->setGravatarUrl($url);
193
- }
194
- }
195
- }
196
-
197
- return $this->_getData('gravatar_url');
198
- }
199
-
200
- /**
201
- * Deprecated. Use self::getAvatarUrl($size)
202
- *
203
- * @param int $size
204
- * @return string
205
- */
206
- public function getGravatarUrl($size = 50)
207
- {
208
- return $this->getAvatarUrl($size);
209
- }
210
-
211
- /**
212
- * Determine whether the comment is approved
213
- *
214
- * @return bool
215
- */
216
- public function isApproved()
217
- {
218
- return $this->_getData('comment_approved') === '1';
219
- }
220
-
221
- /**
222
- * Retrieve the comment anchor
223
- *
224
- * @return string
225
- */
226
- public function getAnchor()
227
- {
228
- $helper = Mage::helper('wordpress');
229
-
230
- return sprintf('<a href="%s" title="%s">%s</a>', $this->getUrl(), $helper->escapeHtml($this->getCommentAuthor()), $helper->escapeHtml($this->getPost()->getPostTitle()));
231
- }
232
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Post/Type.php DELETED
@@ -1,335 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Post_Type extends Mage_Core_Model_Abstract
10
- {
11
- /**
12
- * Cache of URI's for hierarchical post types
13
- *
14
- * @var array static
15
- */
16
- static $_uriCache = array();
17
-
18
- /**
19
- * Determine whether post type uses GUID links
20
- *
21
- * @return bool
22
- */
23
- public function useGuidLinks()
24
- {
25
- return trim($this->getData('rewrite/slug')) === '';
26
- }
27
-
28
- /**
29
- * Determine whether the post type is a built-in type
30
- *
31
- * @return bool
32
- */
33
- public function isDefault()
34
- {
35
- return (int)$this->_getData('_builtin') === 1;
36
- }
37
-
38
- /**
39
- * Get the permalink structure as a string
40
- *
41
- * @return string
42
- */
43
- public function getPermalinkStructure()
44
- {
45
- $structure = ltrim(str_replace('index.php/', '', ltrim($this->getData('rewrite/slug'), ' -/')), '/');
46
-
47
- if (!$this->isDefault() && strpos($structure, '%postname%') === false) {
48
- $structure = rtrim($structure, '/') . '/%postname%/';
49
- }
50
-
51
- if ($this->isHierarchical()) {
52
- $structure = str_replace('%postname%', '%postnames%', $structure);
53
- }
54
-
55
-
56
- if ((int)$this->getData('rewrite/with_front') === 1) {
57
- $postPermalink = Mage::helper('wordpress/app')->getPostType('post')->getPermalinkStructure();
58
-
59
- if (substr($postPermalink, 0, 1) !== '%') {
60
- $front = trim(substr($postPermalink, 0, strpos($postPermalink, '%')), '/');
61
-
62
- $structure = $front . '/' . $structure;
63
- }
64
- }
65
-
66
- return $structure;
67
- }
68
-
69
- /**
70
- * Retrieve the permalink structure in array format
71
- *
72
- * @return false|array
73
- */
74
- public function getExplodedPermalinkStructure()
75
- {
76
- $structure = $this->getPermalinkStructure();
77
- $parts = preg_split("/(\/|-)/", $structure, -1, PREG_SPLIT_DELIM_CAPTURE);
78
- $structure = array();
79
-
80
- foreach($parts as $part) {
81
- if ($result = preg_split("/(%[a-zA-Z0-9_]{1,}%)/", $part, -1, PREG_SPLIT_DELIM_CAPTURE)) {
82
- $results = array_filter(array_unique($result));
83
-
84
- foreach($results as $result) {
85
- array_push($structure, $result);
86
- }
87
- }
88
- else {
89
- $structure[] = $part;
90
- }
91
- }
92
-
93
- return $structure;
94
- }
95
-
96
- /**
97
- * Determine whether the permalink has a trailing slash
98
- *
99
- * @return bool
100
- */
101
- public function permalinkHasTrainingSlash()
102
- {
103
- return substr($this->getData('rewrite/slug'), -1) === '/' || substr($this->getPermalinkStructure(), -1) === '/';
104
- }
105
-
106
- /**
107
- * Retrieve the URL to the cpt page
108
- *
109
- * @return string
110
- */
111
- public function getUrl()
112
- {
113
- return Mage::helper('wordpress')->getUrl($this->getArchiveSlug() . '/');
114
- }
115
-
116
- /**
117
- * Retrieve the post collection for this post type
118
- *
119
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
120
- */
121
- public function getPostCollection()
122
- {
123
- return Mage::getResourceModel('wordpress/post_collection')->addPostTypeFilter($this->getPostType());
124
- }
125
-
126
- /**
127
- * Get the archive slug for the post type
128
- *
129
- * @return string
130
- */
131
- public function getSlug()
132
- {
133
- return $this->getData('rewrite/slug');
134
- }
135
-
136
- /**
137
- * Get the archive slug for the post type
138
- *
139
- * @return string
140
- */
141
- /**
142
- * Get the archive slug for the post type
143
- *
144
- * @return string
145
- */
146
- public function getArchiveSlug()
147
- {
148
- if (!$this->hasArchive()) {
149
- return false;
150
- }
151
-
152
- if (((string)$slug = $this->getHasArchive()) !== '1') {
153
- return $slug;
154
- }
155
-
156
- if ($slug = $this->getSlug()) {
157
- if (strpos($slug, '%') !== false) {
158
- $slug = trim(substr($slug, 0, strpos($slug, '%')), '%/');
159
- }
160
-
161
- if ($slug) {
162
- return $slug;
163
- }
164
- }
165
-
166
- return $this->getPostType();
167
- }
168
-
169
- /**
170
- * Get the URL of the archive page
171
- *
172
- * @return string
173
- */
174
- public function getArchiveUrl()
175
- {
176
- return $this->hasArchive()
177
- ? Mage::helper('wordpress')->getUrl($this->getArchiveSlug() . '/')
178
- : '';
179
- }
180
-
181
- /**
182
- * Determine whether $taxonomy is supported by the post type
183
- *
184
- * @param string $taxonomy
185
- * @return bool
186
- */
187
- public function isTaxonomySupported($taxonomy)
188
- {
189
- return $this->getTaxonomies()
190
- ? in_array($taxonomy, $this->getTaxonomies())
191
- : false;
192
- }
193
-
194
- /**
195
- * Get a taxonomy that is supported by the post type
196
- *
197
- * @return string
198
- */
199
- public function getAnySupportedTaxonomy($prioritise = array())
200
- {
201
- if (!is_array($prioritise)) {
202
- $prioritise = array($prioritise);
203
- }
204
-
205
- foreach($prioritise as $type) {
206
- if ($this->isTaxonomySupported($type)) {
207
- return Mage::helper('wordpress/app')->getTaxonomy($type);
208
- }
209
- }
210
-
211
- if ($taxonomies = $this->getTaxonomies()) {
212
- return Mage::helper('wordpress/app')->getTaxonomy(array_shift($taxonomies));
213
- }
214
-
215
- return false;
216
- }
217
-
218
-
219
- /**
220
- * Get the name of the post type
221
- *
222
- * @return string
223
- */
224
- public function getName()
225
- {
226
- return $this->getData('labels/name');
227
- }
228
-
229
- /**
230
- * Determine whether this post type is hierarchical
231
- *
232
- * @return bool
233
- */
234
- public function isHierarchical()
235
- {
236
- return (int)$this->getData('hierarchical') === 1;
237
- }
238
-
239
- /**
240
- * Get the hierarchical post name for a post
241
- * This is the same as %postname% but with all of the parent post names included
242
- *
243
- * @param int $id
244
- * @return string|false
245
- */
246
- public function getHierarchicalPostName($id)
247
- {
248
- if ($routes = $this->getHierarchicalPostNames()) {
249
- return isset($routes[$id]) ? $routes[$id] : false;
250
- }
251
-
252
- return false;
253
- }
254
-
255
- /**
256
- * Get all routes (hierarchical)
257
- *
258
- * @return false|array
259
- */
260
- public function getAllRoutes()
261
- {
262
- return $this->getHierarchicalPostNames();
263
- }
264
-
265
- /**
266
- * Get an array of hierarchical post names
267
- *
268
- * @return false|array
269
- */
270
- public function getHierarchicalPostNames()
271
- {
272
- if (!$this->isHierarchical()) {
273
- return false;
274
- }
275
-
276
- if (isset(self::$_uriCache[$this->getPostType()])) {
277
- return self::$_uriCache[$this->getPostType()];
278
- }
279
-
280
- if (!($db = Mage::helper('wordpress/app')->getDbConnection())) {
281
- return false;
282
- }
283
-
284
- $select = $db->select()
285
- ->from(array('term' => Mage::getSingleton('core/resource')->getTableName('wordpress/post')), array(
286
- 'id' => 'ID',
287
- 'url_key' => 'post_name',
288
- 'parent' => 'post_parent'
289
- ))
290
- ->where('post_type=?', $this->getPostType())
291
- ->where('post_status=?', 'publish');
292
-
293
- self::$_uriCache[$this->getPostType()] = Mage::helper('wordpress/router')->generateRoutesFromArray(
294
- $db->fetchAll($select)
295
- );
296
-
297
- return self::$_uriCache[$this->getPostType()];
298
- }
299
-
300
- /**
301
- * Determine whether this post type has an archive
302
- *
303
- * @return bool
304
- */
305
- public function hasArchive()
306
- {
307
- return $this->getHasArchive() && $this->getHasArchive() !== '0';
308
- }
309
-
310
- /**
311
- * Get the archive list template for the post type
312
- *
313
- * @return string
314
- */
315
- public function getArchiveTemplate()
316
- {
317
- $customTemplateFile = 'wordpress/post/list/renderer/' . $this->getPostType() . '.phtml';
318
- $customTemplate = Mage::getBaseDir('design') . DS . Mage::getDesign()->getTemplateFilename($customTemplateFile, array('_relative'=>true));
319
-
320
- return is_file($customTemplate) ? $customTemplateFile : false;
321
- }
322
-
323
- /**
324
- * Get the archive list template for the post type
325
- *
326
- * @return string
327
- */
328
- public function getViewTemplate()
329
- {
330
- $customTemplateFile = 'wordpress/post/view/' . $this->getPostType() . '.phtml';
331
- $customTemplate = Mage::getBaseDir('design') . DS . Mage::getDesign()->getTemplateFilename($customTemplateFile, array('_relative'=>true));
332
-
333
- return is_file($customTemplate) ? $customTemplateFile : false;
334
- }
335
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Abstract.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- * @info http://fishpig.co.uk/wordpress-integration.html
8
- */
9
-
10
- abstract class Fishpig_Wordpress_Model_Resource_Abstract extends Mage_Core_Model_Resource_Db_Abstract
11
- {
12
- /**
13
- * Retrieve the appropriate read adapter
14
- *
15
- * @return
16
- */
17
- protected function _getReadAdapter()
18
- {
19
- return Mage::helper('wordpress/app')->getDbConnection();
20
- }
21
-
22
- /**
23
- * Retrieve the appropriate write adapter
24
- *
25
- * @return
26
- */
27
- protected function _getWriteAdapter()
28
- {
29
- return Mage::helper('wordpress/app')->getDbConnection();
30
- }
31
-
32
- /**
33
- * Retrieve a meta value from the database
34
- * This only works if the model is setup to work a meta table
35
- * If not, null will be returned
36
- *
37
- * @param Fishpig_Wordpress_Model_Meta_Abstract $object
38
- * @param string $metaKey
39
- * @param string $selectField
40
- * @return null|mixed
41
- */
42
- public function getMetaValue(Fishpig_Wordpress_Model_Abstract $object, $metaKey, $selectField = 'meta_value')
43
- {
44
- if ($object->hasMeta()) {
45
- $select = $this->_getReadAdapter()
46
- ->select()
47
- ->from($object->getMetaTable(), $selectField)
48
- ->where($object->getMetaObjectField() . '=?', $object->getId())
49
- ->where('meta_key=?', $metaKey)
50
- ->limit(1);
51
-
52
- if (($value = $this->_getReadAdapter()->fetchOne($select)) !== false) {
53
- return trim($value);
54
- }
55
-
56
- return false;
57
- }
58
-
59
- return null;
60
- }
61
-
62
- /**
63
- * Save a meta value to the database
64
- * This only works if the model is setup to work a meta table
65
- *
66
- * @param Fishpig_Wordpress_Model_Meta_Abstract $object
67
- * @param string $metaKey
68
- * @param string $metaValue
69
- */
70
- public function setMetaValue(Fishpig_Wordpress_Model_Abstract $object, $metaKey, $metaValue)
71
- {
72
- if ($object->hasMeta()) {
73
- $metaValue = trim($metaValue);
74
- $metaData = array(
75
- $object->getMetaObjectField() => $object->getId(),
76
- 'meta_key' => $metaKey,
77
- 'meta_value' => $metaValue,
78
- );
79
-
80
- if (($metaId = $this->getMetaValue($object, $metaKey, $object->getMetaPrimaryKeyField())) !== false) {
81
- $this->_getWriteAdapter()->update($object->getMetaTable(), $metaData, $object->getMetaPrimaryKeyField() . '=' . $metaId);
82
- }
83
- else {
84
- $this->_getWriteAdapter()->insert($object->getMetaTable(), $metaData);
85
- }
86
- }
87
- }
88
-
89
- /**
90
- * Get an array of all of the meta values associated with this post
91
- *
92
- * @param Fishpig_Wordpress_Model_Meta_Abstract $object
93
- * @return false|array
94
- */
95
- public function getAllMetaValues(Fishpig_Wordpress_Model_Meta_Abstract $object)
96
- {
97
- if ($object->hasMeta()) {
98
- $select = $this->_getReadAdapter()
99
- ->select()
100
- ->from($object->getMetaTable(), array('meta_key', 'meta_value'))
101
- ->where($object->getMetaObjectField() . '=?', $object->getId());
102
-
103
- if (($values = $this->_getReadAdapter()->fetchPairs($select)) !== false) {
104
- return $values;
105
- }
106
- }
107
-
108
- return false;
109
- }
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Collection/Abstract.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- * @info http://fishpig.co.uk/wordpress-integration.html
8
- */
9
-
10
- abstract class Fishpig_Wordpress_Model_Resource_Collection_Abstract extends Mage_Core_Model_Resource_Db_Collection_Abstract
11
- {
12
- /**
13
- * An array of all of the meta fields that have been joined to this collection
14
- *
15
- * @var array
16
- */
17
- protected $_metaFieldsJoined = array();
18
-
19
- /**
20
- * Removes all order data set at the collection level
21
- * This does not remove order set using self::getSelect()->order($field, $dir)
22
- *
23
- * @return $this
24
- */
25
- public function resetOrderBy()
26
- {
27
- $this->_orders = array();
28
-
29
- return $this;
30
- }
31
-
32
- /**
33
- * Add a meta field to the select statement columns section
34
- *
35
- * @param string $field
36
- * @return $this
37
- */
38
- public function addMetaFieldToSelect($metaKey)
39
- {
40
- if (($field = $this->_joinMetaField($metaKey)) !== false) {
41
- $this->getSelect()->columns(array($metaKey => $field));
42
- }
43
-
44
- return $this;
45
- }
46
-
47
- /**
48
- * Add a meta field to the filter (where) part of the query
49
- *
50
- * @param string $field
51
- * @param string|array $filter
52
- * @return $this
53
- */
54
- public function addMetaFieldToFilter($metaKey, $filter)
55
- {
56
- if (($field = $this->_joinMetaField($metaKey)) !== false) {
57
- $this->addFieldToFilter($field, $filter);
58
- }
59
-
60
- return $this;
61
- }
62
-
63
- /**
64
- * Add a meta field to the SQL order section
65
- *
66
- * @param string $field
67
- * @param string $dir = 'asc'
68
- * @return $this
69
- */
70
- public function addMetaFieldToSort($field, $dir = 'asc')
71
- {
72
- $this->getSelect()->order($field . ' ' . $dir);
73
-
74
- return $this;
75
- }
76
-
77
- /**
78
- * Join a meta field to the query
79
- *
80
- * @param string $field
81
- * @return $this
82
- */
83
- protected function _joinMetaField($field)
84
- {
85
- $model = $this->getNewEmptyItem();
86
-
87
- if ($model->hasMeta()) {
88
- if (!isset($this->_metaFieldsJoined[$field])) {
89
- $alias = $this->_getMetaFieldAlias($field);
90
-
91
- $meta = new Varien_Object(array(
92
- 'key' => $field,
93
- 'alias' => $alias,
94
- ));
95
-
96
- Mage::dispatchEvent($model->getEventPrefix() . '_join_meta_field', array('collection' => $this, 'meta' => $meta));
97
-
98
- if ($meta->getCanSkipJoin()) {
99
- $this->_metaFieldsJoined[$field] = $meta->getAlias();
100
- }
101
- else {
102
- $condition = "`{$alias}`.`{$model->getMetaObjectField()}`=`main_table`.`{$model->getResource()->getIdFieldName()}` AND "
103
- . $this->getConnection()->quoteInto("`{$alias}`.`meta_key`=?", $field);
104
-
105
- $this->getSelect()->joinLeft(array($alias => $model->getMetaTable()), $condition, '');
106
-
107
- $this->_metaFieldsJoined[$field] = $alias . '.meta_value';;
108
- }
109
- }
110
-
111
- return $this->_metaFieldsJoined[$field];
112
- }
113
-
114
- return false;
115
- }
116
-
117
- /**
118
- * Convert a meta key to it's alias
119
- * This is used in all SQL queries
120
- *
121
- * @param string $field
122
- * @return string
123
- */
124
- protected function _getMetaFieldAlias($field)
125
- {
126
- return 'meta_field_' . str_replace('-', '_', $field);
127
- }
128
-
129
- /**
130
- * After loading a collection, dispatch the pre-set event
131
- *
132
- * @return $this
133
- */
134
- protected function _afterLoad()
135
- {
136
- if ($this->getFlag('after_load_event_name')) {
137
- Mage::dispatchEvent($this->getFlag('after_load_event_name'), array(
138
- 'collection' => $this,
139
- 'wrapper_block' => $this->getFlag('after_load_event_block')
140
- ));
141
- }
142
-
143
- return parent::_afterLoad();
144
- }
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Image.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Image extends Fishpig_Wordpress_Model_Resource_Post_Attachment_Abstract
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/image', 'ID');
14
- }
15
-
16
- public function isImagePostName($postName)
17
- {
18
- $select = $this->_getReadAdapter()
19
- ->select()
20
- ->from($this->getMainTable(), 'ID')
21
- ->where('post_type=?', 'attachment')
22
- ->where('post_name=?', $postName)
23
- ->limit(1);
24
-
25
- return $this->_getReadAdapter()->fetchOne($select);
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Image/Collection.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Image_Collection extends Fishpig_Wordpress_Model_Resource_Post_Attachment_Collection_Abstract
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/image');
14
- }
15
-
16
- /**
17
- * Load an image
18
- * Ensure that only images are returned
19
- *
20
- * @param bool $printQuery
21
- * @param bool $logQuery
22
- * @return $this
23
- */
24
- public function load($printQuery = false, $logQuery = false)
25
- {
26
- $this->getSelect()->where("post_mime_type LIKE 'image%'");
27
-
28
- return parent::load($printQuery, $logQuery);
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Menu extends Fishpig_Wordpress_Model_Resource_Term
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/menu', 'term_id');
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Collection.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Menu_Collection extends Fishpig_Wordpress_Model_Resource_Term_Collection
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/menu');
14
- }
15
-
16
- /**
17
- * Filter the term collection so that only nav_menu's are included
18
- *
19
- * @return $this
20
- */
21
- protected function _initSelect()
22
- {
23
- parent::_initSelect();
24
-
25
- $this->getSelect()
26
- ->where('taxonomy.taxonomy=?', $this->getNewEmptyItem()->getTaxonomy());
27
-
28
- return $this;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Item.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Menu_Item extends Fishpig_Wordpress_Model_Resource_Post
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/menu_item', 'ID');
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Menu/Item/Collection.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Menu_Item_Collection extends Fishpig_Wordpress_Model_Resource_Post_Collection
10
- {
11
- /**
12
- * Name prefix of events that are dispatched by model
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_menu_item_collection';
17
-
18
- /**
19
- * Name of event parameter
20
- *
21
- * @var string
22
- */
23
- protected $_eventObject = 'menu_items';
24
-
25
- /**
26
- * Initialise the object
27
- *
28
- */
29
- public function _construct()
30
- {
31
- $this->_init('wordpress/menu_item');
32
-
33
- $this->addPostTypeFilter('nav_menu_item');
34
- }
35
-
36
- /**
37
- * Ensures that only posts and not pages are returned
38
- * WP stores posts and pages in the same DB table
39
- *
40
- */
41
- protected function _initSelect()
42
- {
43
- parent::_initSelect();
44
-
45
- $this->getSelect()->order('menu_order ASC');
46
-
47
- return $this;
48
- }
49
-
50
- /**
51
- * Filter the collection by parent ID
52
- * Set 0 as $parentId to return root menu items
53
- *
54
- * @param int $parentId = 0
55
- * @return $this
56
- */
57
- public function addParentItemIdFilter($parentId = 0)
58
- {
59
- return $this->addMetaFieldToFilter('_menu_item_menu_item_parent', $parentId);
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post.php DELETED
@@ -1,451 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Post extends Fishpig_Wordpress_Model_Resource_Abstract
10
- {
11
- /**
12
- * Set the table and primary key
13
- *
14
- * @return void
15
- */
16
- public function _construct()
17
- {
18
- $this->_init('wordpress/post', 'ID');
19
- }
20
-
21
- /**
22
- * Custom load SQL
23
- *
24
- * @param string $field - field to match $value to
25
- * @param string|int $value - $value to load record based on
26
- * @param Mage_Core_Model_Abstract $object - object we're trying to load to
27
- */
28
- protected function _getLoadSelect($field, $value, $object)
29
- {
30
- $select = $this->_getReadAdapter()->select()
31
- ->from(array('e' => $this->getMainTable()))
32
- ->where("e.{$field}=?", $value)
33
- ->limit(1);
34
-
35
- $postType = $object->getPostType();
36
-
37
- if (!in_array($postType, array('*', ''))) {
38
- $select->where('e.post_type ' . (is_array($postType) ? 'IN' : '=') . ' (?)', $postType);
39
- }
40
-
41
- $select->columns(array('permalink' => $this->getPermalinkSqlColumn()));
42
-
43
- return $select;
44
- }
45
-
46
- public function completePostSlug($slug, $postId, $postType)
47
- {
48
- if (!preg_match_all('/(\%[a-z0-9_-]{1,}\%)/U', $slug, $matches)) {
49
- return $slug;
50
- }
51
-
52
- $matchedTokens = $matches[0];
53
-
54
- foreach($matchedTokens as $mtoken) {
55
- if ($mtoken === '%postnames%') {
56
- $slug = str_replace($mtoken, $postType->getHierarchicalPostName($postId), $slug);
57
- }
58
- else if ($taxonomy = Mage::helper('wordpress/app')->getTaxonomy(trim($mtoken, '%'))) {
59
- $termData = $this->getParentTermsByPostId(array($postId), $taxonomy->getTaxonomyType(), false);
60
-
61
- foreach($termData as $key => $term) {
62
- if ((int)$term['object_id'] === (int)$postId) {
63
- $slug = str_replace($mtoken, $taxonomy->getUriById($term['term_id'], false), $slug);
64
-
65
- break;
66
- }
67
- }
68
- }
69
- }
70
-
71
- return urldecode($slug);
72
- }
73
-
74
- /**
75
- * Prepare a collection/array of posts
76
- *
77
- * @param mixed $posts
78
- * @return $this
79
- */
80
- public function preparePosts($posts)
81
- {
82
- foreach($posts as $post) {
83
- $post->setData(
84
- 'permalink',
85
- $this->completePostSlug($post->getData('permalink'), $post->getId(), $post->getTypeInstance())
86
- );
87
- }
88
-
89
- return $this;
90
- }
91
-
92
- /**
93
- * Get the category IDs that are related to the postIds
94
- *
95
- * @param array $postIds
96
- * @param bool $getAllIds = true
97
- * @return array|false
98
- */
99
- public function getParentTermsByPostId($postId, $taxonomy = 'category')
100
- {
101
- $select = $this->_getReadAdapter()->select()
102
- ->distinct()
103
- ->from(array('_relationship' => $this->getTable('wordpress/term_relationship')), 'object_id')
104
- ->where('object_id = (?)', $postId)
105
- ->order('_term.term_id ASC');
106
-
107
- $select->join(
108
- array('_taxonomy' => $this->getTable('wordpress/term_taxonomy')),
109
- $this->_getReadAdapter()->quoteInto("_taxonomy.term_taxonomy_id = _relationship.term_taxonomy_id AND _taxonomy.taxonomy= ?", $taxonomy),
110
- '*'
111
- );
112
-
113
- $select->join(
114
- array('_term' => $this->getTable('wordpress/term')),
115
- "`_term`.`term_id` = `_taxonomy`.`term_id`",
116
- 'name'
117
- );
118
-
119
- if (Mage::helper('wordpress')->isAddonInstalled('WordPressSEO')) {
120
- Mage::helper('wp_addon_yoastseo')->addPrimaryCategoryToSelect($select, $postId);
121
- }
122
-
123
- $select->reset('columns')
124
- ->columns(array(
125
- $taxonomy . '_id' => '_term.term_id',
126
- 'term_id' => '_term.term_id',
127
- 'object_id'
128
- ))->limit(1);
129
-
130
- return $this->_getReadAdapter()->fetchAll($select);
131
-
132
- $wrapper = $this->_getReadAdapter()
133
- ->select()
134
- ->from(array('squery' => new Zend_Db_Expr('(' . (string)$select . ')')))
135
- ->group('squery.object_id')
136
- ->reset('columns')
137
- ->columns(array(
138
- 'object_id',
139
- 'category_ids' => new Zend_Db_Expr("GROUP_CONCAT(`squery`.`term_id` ORDER BY `squery`.`name` ASC)"
140
- )));
141
-
142
- return $this->_getReadAdapter()->fetchAll($wrapper);
143
- }
144
-
145
- /**
146
- * Get the permalink SQL as a SQL string
147
- *
148
- * @return string
149
- */
150
- public function getPermalinkSqlColumn()
151
- {
152
- if (!($postTypes = Mage::helper('wordpress/app')->getPostTypes())) {
153
- return false;
154
- }
155
-
156
- $sqlColumns = array();
157
- $fields = $this->getPermalinkSqlFields();
158
-
159
- foreach($postTypes as $postType) {
160
- $tokens = $postType->getExplodedPermalinkStructure();
161
- $sqlFields = array();
162
-
163
- foreach($tokens as $token) {
164
- if (substr($token, 0, 1) === '%' && isset($fields[trim($token, '%')])) {
165
- $sqlFields[] = $fields[trim($token, '%')];
166
- }
167
- else {
168
- $sqlFields[] = "'" . $token . "'";
169
- }
170
- }
171
-
172
- if (count($sqlFields) > 0) {
173
- $sqlColumns[$postType->getPostType()] = ' WHEN `post_type` = \'' . $postType->getPostType() . '\' THEN (CONCAT(' . implode(', ', $sqlFields) . '))';
174
- }
175
- }
176
-
177
- return count($sqlColumns) > 0
178
- ? new Zend_Db_Expr(sprintf("CASE %s END", implode("", $sqlColumns)))
179
- : false;
180
- }
181
-
182
- /**
183
- * Get permalinks by the URI
184
- * Given a $uri, this will retrieve all permalinks that *could* match
185
- *
186
- * @param string $uri = ''
187
- * @param array $postTypes = null
188
- * @return false|array
189
- */
190
- public function getPermalinksByUri($uri = '')
191
- {
192
- $originalUri = $uri;
193
- $permalinks = array();
194
-
195
- if ($postTypes = Mage::helper('wordpress/app')->getPostTypes()) {
196
- $fields = $this->getPermalinkSqlFields();
197
-
198
- foreach($postTypes as $postType) {
199
- if (false && $postType->isHierarchical()) {
200
- $tokens = $postType->getExplodedPermalinkStructure();
201
-
202
- if (count($tokens) === 2 && $tokens[0] === '%postname%' && strpos($tokens[1], '%') === false) {
203
- $hierarchicalRoutes = $postType->getHierarchicalPostNames();
204
-
205
- if ($hierarchicalRoutes) {
206
- foreach($hierarchicalRoutes as $routeId => $route) {
207
- if ($route === $originalUri) {
208
- $permalinks += array($routeId => $route);
209
- }
210
- }
211
- }
212
-
213
- continue;
214
- }
215
- }
216
-
217
- if (!($tokens = $postType->getExplodedPermalinkStructure())) {
218
- continue;
219
- }
220
-
221
- $uri = $originalUri;
222
-
223
- if ($postType->permalinkHasTrainingSlash()) {
224
- $uri = rtrim($uri, '/') . '/';
225
- }
226
-
227
- $filters = array();
228
- $lastToken = $tokens[count($tokens)-1];
229
-
230
- # Allow for trailing static strings (eg. .html)
231
- if (substr($lastToken, 0, 1) !== '%') {
232
- if (substr($uri, -strlen($lastToken)) !== $lastToken) {
233
- continue;
234
- }
235
-
236
- $uri = substr($uri, 0, -strlen($lastToken));
237
-
238
- array_pop($tokens);
239
- }
240
-
241
- try {
242
- for($i = 0; $i <= 1; $i++) {
243
- if ($i === 1) {
244
- $uri = implode('/', array_reverse(explode('/', $uri)));
245
- $tokens = array_reverse($tokens);
246
- }
247
-
248
- foreach($tokens as $key => $token) {
249
- if (substr($token, 0, 1) === '%') {
250
- if (!isset($fields[trim($token, '%')])) {
251
- if ($taxonomy = Mage::helper('wordpress/app')->getTaxonomy(trim($token, '%'))) {
252
- $endsWithPostname = isset($tokens[$key+1]) && $tokens[$key+1] === '/'
253
- && isset($tokens[$key+2]) && $tokens[$key+2] === '%postname%'
254
- && !isset($tokens[$key+3]);
255
-
256
-
257
- if ($endsWithPostname) {
258
- $uri = rtrim(substr($uri, strrpos(rtrim($uri, '/'), '/')), '/');
259
- continue;
260
- }
261
- }
262
-
263
- break;
264
- }
265
-
266
- if (isset($tokens[$key+1]) && substr($tokens[$key+1], 0, 1) !== '%') {
267
- $filters[trim($token, '%')] = substr($uri, 0, strpos($uri, $tokens[$key+1]));
268
- $uri = substr($uri, strpos($uri, $tokens[$key+1]));
269
- }
270
- else if (!isset($tokens[$key+1])) {
271
- $filters[trim($token, '%')] = $uri;
272
- $uri = '';
273
- }
274
- else {
275
- throw new Exception('Ignore me #1');
276
- }
277
- }
278
- else if (substr($uri, 0, strlen($token)) === $token) {
279
- $uri = substr($uri, strlen($token));
280
- }
281
- else {
282
- throw new Exception('Ignore me #2');
283
- }
284
-
285
- unset($tokens[$key]);
286
- }
287
- }
288
-
289
- if (isset($filters['post_id']) && isset($filters['postname'])) {
290
- if ((int)$filters['postname'] > 0 && (int)$filters['post_id'] === 0) {
291
- $temp = $filters['post_id'];
292
- $filters['post_id'] = $filters['postname'];
293
- $filters['postname'] = $temp;
294
- }
295
- }
296
-
297
- if ($buffer = $this->getPermalinks($filters, $postType)) {
298
- foreach($buffer as $routeId => $route) {
299
- if (rtrim($route, '/') === $originalUri) {
300
- $permalinks[$routeId] = $route;
301
- throw new Exception('Break');
302
- }
303
- }
304
-
305
- # $permalinks += $buffer;
306
- }
307
- }
308
- catch (Exception $e) {
309
- if ($e->getMessage() === 'Break') {
310
- break;
311
- }
312
-
313
- // Exception thrown to escape nested loops
314
- }
315
- }
316
- }
317
-
318
- return count($permalinks) > 0 ? $permalinks : false;
319
- }
320
-
321
- /**
322
- * Get an array of post ID's and permalinks
323
- * $filters is applied but if empty, all permalinks are returned
324
- *
325
- * @param array $filters = array()
326
- * @return array|false
327
- */
328
- public function getPermalinks(array $filters = array(), $postType)
329
- {
330
- $tokens = $postType->getExplodedPermalinkStructure();
331
- $fields = $this->getPermalinkSqlFields();
332
-
333
- $select = $this->_getReadAdapter()
334
- ->select()
335
- ->from(array('main_table' => $this->getMainTable()), array('id' => 'ID', 'permalink' => $this->getPermalinkSqlColumn()))
336
- ->where('post_type = ?', $postType->getPostType())
337
- ->where('post_status IN (?)', array('publish', 'protected', 'private'));
338
-
339
- foreach($filters as $field => $value) {
340
- if (isset($fields[$field])) {
341
- $select->where($fields[$field] . '=?', urlencode($value));
342
- }
343
- }
344
-
345
- if ($routes = $this->_getReadAdapter()->fetchPairs($select)) {
346
- foreach($routes as $id => $permalink) {
347
- $routes[$id] = urldecode($this->completePostSlug($permalink, $id, $postType));
348
- }
349
-
350
- return $routes;
351
- }
352
-
353
- return false;
354
- }
355
-
356
- /**
357
- * Get the SQL data for the permalink
358
- *
359
- * @return array
360
- */
361
- public function getPermalinkSqlFields()
362
- {
363
- return array(
364
- 'year' => 'SUBSTRING(post_date_gmt, 1, 4)',
365
- 'monthnum' => 'SUBSTRING(post_date_gmt, 6, 2)',
366
- 'day' => 'SUBSTRING(post_date_gmt, 9, 2)',
367
- 'hour' => 'SUBSTRING(post_date_gmt, 12, 2)',
368
- 'minute' => 'SUBSTRING(post_date_gmt, 15, 2)',
369
- 'second' => 'SUBSTRING(post_date_gmt, 18, 2)',
370
- 'post_id' => 'ID',
371
- 'postname' => 'post_name',
372
- 'author' => 'post_author',
373
- );
374
- }
375
-
376
- /**
377
- * Determine whether the given post has any children posts
378
- *
379
- * @param Fishpig_Wordpress_Model_Post $post
380
- * @return bool
381
- */
382
- public function hasChildrenPosts(Fishpig_Wordpress_Model_Post $post)
383
- {
384
- $select = $this->_getReadAdapter()
385
- ->select()
386
- ->from($this->getMainTable(), 'ID')
387
- ->where('post_parent=?', $post->getId())
388
- ->where('post_type=?', $post->getPostType())
389
- ->where('post_status=?', 'publish')
390
- ->limit(1);
391
-
392
- return $this->_getReadAdapter()->fetchOne($select) !== false;
393
- }
394
-
395
- /**
396
- * Retrieve a collection of post comments
397
- *
398
- * @param Fishpig_Wordpress_Model_Post $post
399
- * @return Fishpig_Wordpress_Model_Resource_Post_Comment_Collection
400
- */
401
- public function getPostComments(Fishpig_Wordpress_Model_Post $post)
402
- {
403
- return Mage::getResourceModel('wordpress/post_comment_collection')
404
- ->addPostIdFilter($post->getId())
405
- ->addCommentApprovedFilter()
406
- ->addParentCommentFilter(0)
407
- ->addOrderByDate();
408
- }
409
-
410
- /**
411
- * Retrieve the featured image for the post
412
- *
413
- * @param Fishpig_Wordpress_Model_Post $post
414
- * @return Fishpig_Wordpress_Model_Image $image
415
- */
416
- public function getFeaturedImage(Fishpig_Wordpress_Model_Post $post)
417
- {
418
- if ($images = $post->getImages()) {
419
- $select = $this->_getReadAdapter()
420
- ->select()
421
- ->from($this->getTable('wordpress/post_meta'), 'meta_value')
422
- ->where('post_id=?', $post->getId())
423
- ->where('meta_key=?', '_thumbnail_id')
424
- ->limit(1);
425
-
426
- if (($imageId = $this->_getReadAdapter()->fetchOne($select)) !== false) {
427
- if (preg_match('/([a-z-]{1,})([0-9]{1,})/', $imageId, $matches)) {
428
- if (($prefix = trim($matches[1], '- ')) !== '') {
429
- $eventData = array(
430
- 'object' => $post,
431
- 'image_id' => $matches[2],
432
- 'original_image_id' => $imageId,
433
- 'result' => new Varien_Object(),
434
- );
435
-
436
- Mage::dispatchEvent('wordpress_post_get_featured_image_' . $prefix, $eventData);
437
-
438
- if ($eventData['result']->getFeaturedImage()) {
439
- return $eventData['result']->getFeaturedImage();
440
- }
441
- }
442
- }
443
- else {
444
- return Mage::getModel('wordpress/image')->load($imageId);
445
- }
446
- }
447
- }
448
-
449
- return false;
450
- }
451
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Attachment/Abstract.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Model_Resource_Post_Attachment_Abstract extends Fishpig_Wordpress_Model_Resource_Post
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Attachment/Collection/Abstract.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- abstract class Fishpig_Wordpress_Model_Resource_Post_Attachment_Collection_Abstract extends Fishpig_Wordpress_Model_Resource_Collection_Abstract
10
- {
11
- /**
12
- * Load an attachment
13
- *
14
- * @param bool $printQuery
15
- * @param bool $logQuery
16
- * @return $this
17
- */
18
- public function load($printQuery = false, $logQuery = false)
19
- {
20
- $this->getSelect()
21
- ->where("post_type = ?", 'attachment')
22
- ->where("post_mime_type LIKE 'image%'");
23
-
24
- return parent::load($printQuery, $logQuery);
25
- }
26
-
27
- /**
28
- * Set the parent ID
29
- *
30
- * @param int $parentId = 0
31
- * @return $this
32
- */
33
- public function setParent($parentId = 0)
34
- {
35
- $this->getSelect()->where("post_parent = ?", $parentId);
36
-
37
- return $this;
38
- }
39
-
40
- /**
41
- * After loading the collection, unserialize data
42
- *
43
- * @return $this
44
- */
45
- protected function _afterLoad()
46
- {
47
- parent::_afterLoad();
48
-
49
- foreach($this->_items as $item) {
50
- $item->loadSerializedData();
51
- }
52
-
53
- return $this;
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Collection.php DELETED
@@ -1,469 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Post_Collection extends Fishpig_Wordpress_Model_Resource_Collection_Abstract
10
- {
11
- /**
12
- * Name prefix of events that are dispatched by model
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_post_collection';
17
-
18
- /**
19
- * Name of event parameter
20
- *
21
- * @var string
22
- */
23
- protected $_eventObject = 'posts';
24
-
25
- /**
26
- * True if term tables have been joined
27
- * This stops the term tables being joined repeatedly
28
- *
29
- * @var array()
30
- */
31
- protected $_termTablesJoined = array();
32
-
33
- /**
34
- * Store post types to be allowed in collection
35
- *
36
- * @var array
37
- */
38
- protected $_postTypes = array();
39
-
40
- /**
41
- * Set the resource
42
- *
43
- * @return void
44
- */
45
- public function _construct()
46
- {
47
- $this->_init('wordpress/post');
48
-
49
- $this->_map['fields']['ID'] = 'main_table.ID';
50
- $this->_map['fields']['post_type'] = 'main_table.post_type';
51
- $this->_map['fields']['post_status'] = 'main_table.post_status';
52
- }
53
-
54
- /**
55
- * Init collection select
56
- *
57
- * @return Mage_Core_Model_Resource_Db_Collection_Abstract
58
- */
59
- protected function _initSelect()
60
- {
61
- parent::_initSelect();
62
-
63
- return $this->setOrder('main_table.menu_order', 'ASC')
64
- ->setOrder('main_table.post_date', 'DESC');
65
- }
66
-
67
- /**
68
- * Add the permalink data before loading the collection
69
- *
70
- * @return $this
71
- */
72
- protected function _beforeLoad()
73
- {
74
- parent::_beforeLoad();
75
-
76
- if (!$this->getFlag('skip_permalink_generation')) {
77
- if ($sql = $this->getResource()->getPermalinkSqlColumn()) {
78
- $this->getSelect()->columns(array('permalink' => $sql));
79
- }
80
- }
81
-
82
- if (!$this->hasPostTypeFilter()) {
83
- if ($this->getFlag('source') instanceof Fishpig_Wordpress_Model_Term) {
84
- if ($postTypes = Mage::helper('wordpress/app')->getPostTypes()) {
85
- $supportedTypes = array();
86
-
87
- foreach($postTypes as $postType) {
88
- if ($postType->isTaxonomySupported($this->getFlag('source')->getTaxonomy())) {
89
- $supportedTypes[] = $postType->getPostType();
90
- }
91
- }
92
-
93
- $this->addPostTypeFilter($supportedTypes);
94
- }
95
- }
96
- }
97
-
98
- if (count($this->_postTypes) === 1) {
99
- if ($this->_postTypes[0] === '*') {
100
- $this->_postTypes = array();
101
- }
102
- }
103
-
104
- if (count($this->_postTypes) === 0) {
105
- $this->addFieldToFilter('post_type', array('in' => array_keys(Mage::helper('wordpress/app')->getPostTypes())));
106
- }
107
- else {
108
- $this->addFieldToFilter('post_type', array('in' => $this->_postTypes));
109
- }
110
-
111
- return $this;
112
- }
113
-
114
- /**
115
- * Ensure that is any pages are in the collection, they are correctly cast
116
- *
117
- * @return $this
118
- */
119
- protected function _afterLoad()
120
- {
121
- parent::_afterLoad();
122
-
123
- $this->getResource()->preparePosts($this->_items);
124
-
125
- return $this;
126
- }
127
-
128
- /**
129
- * Filters the collection by an array of post ID's and category ID's
130
- * When filtering by a category ID, all posts from that category will be returned
131
- * If you change the param $operator to AND, only posts that are in a category specified in
132
- * $categoryIds and $postIds will be returned
133
- *
134
- * @param mixed $postIds
135
- * @param mixed $categoryIds
136
- * @param string $operator
137
- */
138
- public function addCategoryAndPostIdFilter($postIds, $categoryIds, $operator = 'OR')
139
- {
140
- if (!is_array($postIds)) {
141
- $postIds = array($postIds);
142
- }
143
-
144
- if (!is_array($categoryIds)) {
145
- $categoryIds = array($categoryIds);
146
- }
147
-
148
- if (count($categoryIds) > 0) {
149
- $this->joinTermTables('category');
150
- }
151
-
152
- $readAdapter = Mage::helper('wordpress/app')->getDbConnection();
153
-
154
- $postSql = $readAdapter->quoteInto("`main_table`.`ID` IN (?)", $postIds);
155
- $categorySql = $readAdapter->quoteInto("`tax_category`.`term_id` IN (?)", $categoryIds);
156
-
157
- if (count($postIds) > 0 && count($categoryIds) > 0) {
158
- $this->getSelect()->where("{$postSql} {$operator} {$categorySql}");
159
- }
160
- else if (count($postIds) > 0) {
161
- $this->getSelect()->where("{$postSql}");
162
- }
163
- else if (count($categoryIds) > 0) {
164
- $this->getSelect()->where("{$categorySql}");
165
- }
166
-
167
- return $this;
168
- }
169
-
170
- /**
171
- * Filter the collection by a category ID
172
- *
173
- * @param int $categoryId
174
- * @return $this
175
- */
176
- public function addCategoryIdFilter($categoryId)
177
- {
178
- return $this->addTermIdFilter($categoryId, 'category');
179
- }
180
-
181
- /**
182
- * Filter the collection by a tag ID
183
- *
184
- * @param int $categoryId
185
- * @return $this
186
- */
187
- public function addTagIdFilter($tagId)
188
- {
189
- return $this->addTermIdFilter($tagId, 'post_tag');
190
- }
191
-
192
- /**
193
- * Filters the collection with an archive date
194
- * EG: 2010/10
195
- *
196
- * @param string $archiveDate
197
- */
198
- public function addArchiveDateFilter($archiveDate, $isDaily = false)
199
- {
200
- if ($isDaily) {
201
- $this->getSelect()->where("`main_table`.`post_date` LIKE ?", str_replace("/", "-", $archiveDate)." %");
202
- }
203
- else {
204
- $this->getSelect()->where("`main_table`.`post_date` LIKE ?", str_replace("/", "-", $archiveDate)."-%");
205
- }
206
-
207
- return $this;
208
- }
209
-
210
- /**
211
- * Add sticky posts to the filter
212
- *
213
- * @param bool $isSticky = true
214
- * @return $this
215
- */
216
- public function addStickyPostsToCollection()
217
- {
218
- if (($sticky = trim(Mage::helper('wordpress')->getWpOption('sticky_posts'))) !== '') {
219
- $stickyIds = unserialize($sticky);
220
-
221
- if (count($stickyIds) > 0) {
222
- $select = Mage::helper('wordpress/app')->getDbConnection()
223
- ->select()
224
- ->from($this->getTable('wordpress/post'), new Zend_Db_Expr(1))
225
- ->where('main_table.ID IN (?)', $stickyIds)
226
- ->limit(1);
227
-
228
- $this->getSelect()
229
- ->columns(array('is_sticky' => '(' . $select . ')'))
230
- ->order('is_sticky DESC');
231
- }
232
- }
233
-
234
- return $this;
235
- }
236
-
237
- /**
238
- * Add a post type filter to the collection
239
- *
240
- * @param string|array $postTypes
241
- * @return $this
242
- */
243
- public function addPostTypeFilter($postTypes)
244
- {
245
- if (!is_array($postTypes) && strpos($postTypes, ',') !== false) {
246
- $postTypes = explode(',', $postTypes);
247
- }
248
-
249
- $this->_postTypes = array_values(array_merge($this->_postTypes, (array)$postTypes));
250
-
251
- return $this;
252
- }
253
-
254
- /**
255
- * Determine whether any post type filters exist
256
- *
257
- * @return bool
258
- */
259
- public function hasPostTypeFilter()
260
- {
261
- return count($this->_postTypes) > 0;
262
- }
263
-
264
- /**
265
- * Adds a published filter to collection
266
- *
267
- */
268
- public function addIsPublishedFilter()
269
- {
270
- return $this->addIsViewableFilter();
271
- }
272
-
273
- /**
274
- * Filters the collection so that only posts that can be viewed are displayed
275
- *
276
- * @return $this
277
- */
278
- public function addIsViewableFilter()
279
- {
280
- $fields = Mage::app()->getStore()->isAdmin()
281
- || (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::helper('wordpress')->isAddonInstalled('CS'))
282
- ? array('publish', 'private', 'protected')
283
- : array('publish', 'protected');
284
-
285
- return $this->addStatusFilter($fields);
286
- }
287
-
288
- /**
289
- * Adds a filter to the status column
290
- *
291
- * @param string $status
292
- */
293
- public function addStatusFilter($status)
294
- {
295
- $op = is_array($status) ? 'in' : 'eq';
296
-
297
- return $this->addFieldToFilter('post_status', array($op => $status));
298
- }
299
-
300
- /**
301
- * Orders the collection by post date
302
- *
303
- * @param string $dir
304
- */
305
- public function setOrderByPostDate($dir = 'desc')
306
- {
307
- $this->_orders = array();
308
-
309
- return $this->setOrder('post_date', $dir);
310
- }
311
-
312
- /**
313
- * Filter the collection by a date
314
- *
315
- * @param string $dateStr
316
- */
317
- public function addPostDateFilter($dateStr)
318
- {
319
- if (!is_array($dateStr) && strpos($dateStr, '%') !== false) {
320
- $this->addFieldToFilter('post_date', array('like' => $dateStr));
321
- }
322
- else {
323
- $this->addFieldToFilter('post_date', $dateStr);
324
- }
325
-
326
- return $this;
327
- }
328
-
329
- /**
330
- * Skip the permalink generation
331
- *
332
- * @return $this
333
- */
334
- public function removePermalinkFromSelect()
335
- {
336
- return $this->setFlag('skip_permalink_generation', true);
337
- }
338
-
339
- /**
340
- * Filters the collection by an array of words on the array of fields
341
- *
342
- * @param array $words - words to search for
343
- * @param array $fields - fields to search
344
- * @param string $operator
345
- */
346
- public function addSearchStringFilter(array $words, array $fields)
347
- {
348
- if (count($words) > 0) {
349
- foreach($words as $word) {
350
- $conditions = array();
351
-
352
- foreach($fields as $key => $field) {
353
- $conditions[] = $this->getConnection()->quoteInto('`main_table`.`' . $field . '` LIKE ?', '%' . $word . '%');
354
- }
355
-
356
- $this->getSelect()->where(join(' ' . Zend_Db_Select::SQL_OR . ' ', $conditions));
357
- }
358
-
359
- $this->addFieldToFilter('post_password', '');
360
- }
361
- else {
362
- $this->getSelect()->where('1=2');
363
- }
364
-
365
- return $this;
366
- }
367
-
368
- /**
369
- * Filters the collection by a term ID and type
370
- *
371
- * @param int|array $termId
372
- * @param string $type
373
- */
374
- public function addTermIdFilter($termId, $type)
375
- {
376
- $this->joinTermTables($type);
377
-
378
- if (is_array($termId)) {
379
- $this->getSelect()->where("`tax_{$type}`.`term_id` IN (?)", $termId);
380
- }
381
- else {
382
- $this->getSelect()->where("`tax_{$type}`.`term_id` = ?", $termId);
383
- }
384
-
385
- return $this;
386
- }
387
-
388
- /**
389
- * Filters the collection by a term and type
390
- *
391
- * @param int|array $termId
392
- * @param string $type
393
- */
394
- public function addTermFilter($term, $type, $field = 'slug')
395
- {
396
- $this->joinTermTables($type);
397
-
398
- if (is_array($term)) {
399
- $this->getSelect()->where("`terms_{$type}`.`{$field}` IN (?)", $term);
400
- }
401
- else {
402
- $this->getSelect()->where("`terms_{$type}`.`{$field}` = ?", $term);
403
- }
404
-
405
- return $this;
406
- }
407
-
408
- /**
409
- * Joins the category tables to the collection
410
- * This allows filtering by category
411
- */
412
- public function joinTermTables($type)
413
- {
414
- $type = strtolower(trim($type));
415
-
416
- if (!isset($this->_termTablesJoined[$type])) {
417
- $tableTax = $this->getTable('wordpress/term_taxonomy');
418
- $tableTermRel = $this->getTable('wordpress/term_relationship');
419
- $tableTerms = $this->getTable('wordpress/term');
420
-
421
- $this->getSelect()->join(array('rel_' . $type => $tableTermRel), "`rel_{$type}`.`object_id`=`main_table`.`ID`", '')
422
- ->join(array('tax_' . $type => $tableTax), "`tax_{$type}`.`term_taxonomy_id`=`rel_{$type}`.`term_taxonomy_id` AND `tax_{$type}`.`taxonomy`='{$type}'", '')
423
- ->join(array('terms_' . $type => $tableTerms), "`terms_{$type}`.`term_id` = `tax_{$type}`.`term_id`", '')
424
- ->distinct();
425
-
426
- $this->_termTablesJoined[$type] = true;
427
- }
428
-
429
- return $this;
430
- }
431
-
432
- /**
433
- * Add post parent ID filter
434
- *
435
- * @param int $postParentId
436
- */
437
- public function addPostParentIdFilter($postParentId)
438
- {
439
- $this->getSelect()->where("main_table.post_parent=?", $postParentId);
440
-
441
- return $this;
442
- }
443
-
444
- /**
445
- * Calculate the collection size correctly
446
- *
447
- * @return int
448
- **/
449
- public function getSize()
450
- {
451
- if (is_null($this->_totalRecords)) {
452
- $this->_totalRecords = count($this->getConnection()->fetchCol($this->getSelectCountSql()));
453
- }
454
-
455
- return intval($this->_totalRecords);
456
- }
457
-
458
- /**
459
- * Get a valid count SQL object
460
- *
461
- * @return
462
- **/
463
- public function getSelectCountSql()
464
- {
465
- return parent::getSelectCountSql()
466
- ->reset(Zend_Db_Select::COLUMNS)
467
- ->columns('main_table.ID');
468
- }
469
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Comment.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Post_Comment extends Fishpig_Wordpress_Model_Resource_Abstract
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/post_comment', 'comment_ID');
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Post/Comment/Collection.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Post_Comment_Collection extends Fishpig_Wordpress_Model_Resource_Collection_Abstract
10
- {
11
- /**
12
- * Name prefix of events that are dispatched by model
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_post_comment_collection';
17
-
18
- /**
19
- * Name of event parameter
20
- *
21
- * @var string
22
- */
23
- protected $_eventObject = 'post_comments';
24
-
25
- public function _construct()
26
- {
27
- $this->_init('wordpress/post_comment');
28
- }
29
-
30
- /**
31
- * Order the comments by date
32
- *
33
- * @param string $dir = null
34
- * @return $this
35
- */
36
- public function addOrderByDate($dir = null)
37
- {
38
- if (is_null($dir)) {
39
- $dir = Mage::helper('wordpress')->getWpOption('comment_order');
40
- $dir = in_array($dir, array('asc', 'desc')) ? $dir : 'asc';
41
- }
42
-
43
- $this->getSelect()->order('main_table.comment_date ' . $dir);
44
-
45
- return $this;
46
- }
47
-
48
- /**
49
- * Add parent comment filter
50
- *
51
- * @param int $parentId = 0
52
- * @return $this
53
- */
54
- public function addParentCommentFilter($parentId = 0)
55
- {
56
- return $this->addFieldToFilter('comment_parent', $parentId);
57
- }
58
-
59
- /**
60
- * Filters the collection of comments
61
- * so only comments for a certain post are returned
62
- *
63
- * @return $this
64
- */
65
- public function addPostIdFilter($postId)
66
- {
67
- return $this->addFieldToFilter('comment_post_ID', $postId);
68
- }
69
-
70
- /**
71
- * Filter the collection by a user's ID
72
- *
73
- * @param int $userId
74
- * @return $this
75
- */
76
- public function addUserIdFilter($userId)
77
- {
78
- return $this->addFieldToFilter('user_id', $userId);
79
- }
80
-
81
- /**
82
- * Filter the collection by the comment_author_email column
83
- *
84
- * @param string $email
85
- * @return $this
86
- */
87
- public function addCommentAuthorEmailFilter($email)
88
- {
89
- return $this->addFieldToFilter('comment_author_email', $email);
90
- }
91
-
92
- /**
93
- * Filters the collection so only approved comments are returned
94
- *
95
- * @return $this
96
- */
97
- public function addCommentApprovedFilter($status = 1)
98
- {
99
- return $this->addFieldToFilter('comment_approved', $status);
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Setup.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
10
- {
11
- /**
12
- * If Legacy add-on extension installed
13
- * Apply legacy hacks
14
- *
15
- * @param string $resourceName
16
- * @return void
17
- */
18
- public function __construct($resourceName)
19
- {
20
- if (Mage::helper('wordpress')->isLegacy()) {
21
- if ($helper = Mage::helper('wp_addon_legacy')) {
22
- $helper->applyLegacyHacks();
23
- }
24
- }
25
-
26
- parent::__construct($resourceName);
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Term.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Term extends Fishpig_Wordpress_Model_Resource_Abstract
10
- {
11
- /**
12
- * Determine whether there is a term order field
13
- *
14
- * @static bool
15
- */
16
- protected static $_tableHasTermOrder = null;
17
-
18
- public function _construct()
19
- {
20
- $this->_init('wordpress/term', 'term_id');
21
- }
22
-
23
- /**
24
- * Custom load SQL to combine required tables
25
- *
26
- * @param string $field
27
- * @param string|int $value
28
- * @param Mage_Core_Model_Abstract $object
29
- */
30
- protected function _getLoadSelect($field, $value, $object)
31
- {
32
- $select = $this->_getReadAdapter()->select()
33
- ->from(array('main_table' => $this->getMainTable()));
34
-
35
- if (strpos($field, '.') !== false) {
36
- $select->where($field . '=?', $value);
37
- }
38
- else {
39
- $select->where("main_table.{$field}=?", $value);
40
- }
41
-
42
- $select->join(
43
- array('taxonomy' => $this->getTable('wordpress/term_taxonomy')),
44
- '`main_table`.`term_id` = `taxonomy`.`term_id`',
45
- array('term_taxonomy_id', 'taxonomy', 'description', 'count', 'parent')
46
- );
47
-
48
- if ($object->getTaxonomy()) {
49
- $select->where('taxonomy.taxonomy=?', $object->getTaxonomy());
50
- }
51
-
52
- return $select->limit(1);
53
- }
54
-
55
- /**
56
- * Determine whether a 'term_order' field is present
57
- *
58
- * @return bool
59
- */
60
- public function tableHasTermOrderField()
61
- {
62
- if (!is_null(self::$_tableHasTermOrder)) {
63
- return self::$_tableHasTermOrder;
64
- }
65
-
66
- try {
67
- self::$_tableHasTermOrder = $this->_getReadAdapter()
68
- ->fetchOne('SHOW COLUMNS FROM ' . $this->getMainTable() . ' WHERE Field = \'term_order\'')
69
- !== false;
70
- }
71
- catch (Exception $e) {
72
- self::$_tableHasTermOrder = false;
73
- }
74
-
75
- return self::$_tableHasTermOrder;
76
- }
77
-
78
- /**
79
- * Get all child ID's for a parent
80
- * This includes recursive levels
81
- *
82
- * @param int $parentId
83
- * @return array
84
- */
85
- public function getChildIds($parentId)
86
- {
87
- $select = $this->_getReadAdapter()
88
- ->select()
89
- ->from($this->getTable('wordpress/term_taxonomy'), 'term_id')
90
- ->where('parent=?', $parentId)
91
- ->where('count>?', 0);
92
-
93
- if ($termIds = $this->_getReadAdapter()->fetchCol($select)) {
94
- foreach($termIds as $key => $termId) {
95
- $termIds = array_merge($termIds, $this->getChildIds($termId));
96
- }
97
-
98
- return array_unique(array_merge(array($parentId), $termIds));
99
- }
100
-
101
- return array($parentId);
102
- }
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/Term/Collection.php DELETED
@@ -1,213 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_Term_Collection extends Fishpig_Wordpress_Model_Resource_Collection_Abstract
10
- {
11
- /**
12
- * Name prefix of events that are dispatched by model
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_term_collection';
17
-
18
- /**
19
- * Name of event parameter
20
- *
21
- * @var string
22
- */
23
- protected $_eventObject = 'terms';
24
-
25
- public function _construct()
26
- {
27
- $this->_init('wordpress/term');
28
- }
29
-
30
- /**
31
- * Flag that determines whether term_relationships has been joined
32
- *
33
- * @var bool
34
- */
35
- protected $_relationshipTableJoined = false;
36
-
37
- /**
38
- * Ensures that only posts and not pages are returned
39
- * WP stores posts and pages in the same DB table
40
- *
41
- */
42
- protected function _initSelect()
43
- {
44
- parent::_initSelect();
45
-
46
- $this->getSelect()->join(
47
- array('taxonomy' => $this->getTable('wordpress/term_taxonomy')),
48
- '`main_table`.`term_id` = `taxonomy`.`term_id`',
49
- array('term_taxonomy_id', 'taxonomy', 'description', 'count', 'parent')
50
- );
51
-
52
- // Reverse the order. This then matches the WP order
53
- if (Mage::getResourceSingleton('wordpress/term')->tableHasTermOrderField()) {
54
- $this->getSelect()->order('term_order ASC');
55
- }
56
-
57
- $this->getSelect()->order('term_id ASC');
58
-
59
- return $this;
60
- }
61
-
62
- /**
63
- * Set the collection by the name field
64
- *
65
- * @param string $dir = 'ASC'
66
- * @return $this
67
- **/
68
- public function setOrderByName($dir = 'ASC')
69
- {
70
- $this->getSelect()
71
- ->reset(Zend_Db_Select::ORDER)
72
- ->order('main_table.name ' . $dir);
73
-
74
- return $this;
75
- }
76
-
77
- /**
78
- * Add a slug filter to the collection
79
- *
80
- * @param string $slug
81
- * @return $this
82
- */
83
- public function addSlugFilter($slug)
84
- {
85
- return $this->addFieldToFilter('slug', $slug);
86
- }
87
-
88
- /**
89
- * Filter the collection by taxonomy
90
- *
91
- * @param string $taxonomy
92
- * @return $this
93
- */
94
- public function addTaxonomyFilter($taxonomy)
95
- {
96
- return $this->addFieldToFilter('taxonomy', $taxonomy);
97
- }
98
-
99
- /**
100
- * Filter the collection on the parent field
101
- *
102
- * @param int|Fishpig_Wordpress_Model_Term
103
- * @return $this
104
- */
105
- public function addParentFilter($parentId)
106
- {
107
- if (is_object($parentId)) {
108
- $parentId = $parentId->getId();
109
- }
110
-
111
- return $this->addFieldToFilter('parent', $parentId);
112
- }
113
-
114
- /**
115
- * See self::addParentFilter
116
- * This is kept in for backwards compatibility
117
- *
118
- * @return $this
119
- */
120
- public function addParentIdFilter($parentId)
121
- {
122
- return $this->addParentFilter($parentId);
123
- }
124
-
125
- /**
126
- * Join the relationship table
127
- * No values are added to the result, but this can be used to test whether term has
128
- * a particular object_id
129
- *
130
- * @return $this
131
- */
132
- protected function _joinRelationshipTable()
133
- {
134
- if ($this->_relationshipTableJoined === false) {
135
- $this->getSelect()
136
- ->distinct()
137
- ->joinLeft(
138
- array('relationship' => $this->getTable('wordpress/term_relationship')),
139
- '`taxonomy`.`term_taxonomy_id` = `relationship`.`term_taxonomy_id`',
140
- ''
141
- );
142
- }
143
-
144
- return $this;
145
- }
146
-
147
- /**
148
- * Filter the collection by object ID
149
- * To pass in multiple object ID's, pass:
150
- *
151
- * @param int|array $objectId
152
- * @return $this
153
- */
154
- public function addObjectIdFilter($objectId)
155
- {
156
- if (is_array($objectId)) {
157
- $objectId = array('IN' => $objectId);
158
- }
159
-
160
- return $this->_joinRelationshipTable()->addFieldToFilter('object_id', $objectId);
161
- }
162
-
163
- /**
164
- * See self::addObjectIdFilter
165
- *
166
- */
167
- public function addPostIdFilter($postId)
168
- {
169
- return $this->addObjectIdFilter($postId);
170
- }
171
-
172
- /**
173
- * Order the collection by the count field
174
- *
175
- * @param string $dir
176
- */
177
- public function addOrderByItemCount($dir = 'desc')
178
- {
179
- $this->getSelect()->order('taxonomy.count ' . $dir);
180
-
181
- return $this;
182
- }
183
-
184
- /**
185
- * Determine whether the term has objects associated with it
186
- *
187
- * @return $this
188
- */
189
- public function addHasObjectsFilter()
190
- {
191
- return $this->addFieldToFilter('count', array('gt' => 0));
192
- }
193
-
194
- /**
195
- * Filter the collection so that only tags in the cloud
196
- * are returned
197
- *
198
- */
199
- public function addCloudFilter($taxonomy)
200
- {
201
- $cloudIdsSelect = Mage::getResourceModel('wordpress/term_collection')
202
- ->addTaxonomyFilter($taxonomy)
203
- ->addOrderByItemCount()
204
- ->setPageSize(20)
205
- ->setCurPage(1)
206
- ->getSelect()
207
- ->setPart('columns', array())
208
- ->columns(array('main_table.term_id'));
209
-
210
- return $this->addTaxonomyFilter($taxonomy)
211
- ->addFieldToFilter('main_table.term_id', array('in' => new Zend_Db_Expr($cloudIdsSelect)));
212
- }
213
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/User.php DELETED
@@ -1,112 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_User extends Fishpig_Wordpress_Model_Resource_Abstract
10
- {
11
- public function _construct()
12
- {
13
- $this->_init('wordpress/user', 'ID');
14
- }
15
-
16
- /**
17
- * Load the WP User associated with the current logged in Customer
18
- *
19
- * @param Fishpig_Wordpress_Model_User $user
20
- * @return bool
21
- */
22
- public function loadCurrentLoggedInUser(Fishpig_Wordpress_Model_User $user)
23
- {
24
- $session = Mage::getSingleton('customer/session');
25
-
26
- if ($session->isLoggedIn()) {
27
- $user->loadByEmail($session->getCustomer()->getEmail());
28
-
29
- if ($user->getId() > 0) {
30
- return true;
31
- }
32
- }
33
-
34
- return false;
35
- }
36
-
37
- /**
38
- * Ensure the model has the necessary data attributes set
39
- *
40
- * @param Mage_Core_Model_Abstract $object
41
- * @return $this
42
- */
43
- protected function _beforeSave(Mage_Core_Model_Abstract $object)
44
- {
45
- if (!$object->getUserEmail()) {
46
- throw new Exception('Cannot save WordPress user without email address');
47
- }
48
-
49
- if (!$object->getUserRegistered()) {
50
- $object->setUserRegistered(now());
51
- }
52
-
53
- if (!$object->getUserStatus()) {
54
- $object->setUserStatus(0);
55
- }
56
-
57
- if (!$object->getRole()) {
58
- $object->setRole($object->getDefaultUserRole());
59
- }
60
-
61
- if (!$object->getUserLevel()) {
62
- $object->setUserLevel(0);
63
- }
64
-
65
- return parent::_beforeSave($object);
66
- }
67
-
68
- /**
69
- * Remove duplicate user accounts from WordPress that use the same email address
70
- *
71
- * @return $this
72
- */
73
- public function cleanDuplicates()
74
- {
75
- $collection = Mage::getResourceModel('wordpress/user_collection')->load();
76
- $byEmail = array();
77
-
78
- foreach($collection as $user) {
79
- $email = $user->getUserEmail();
80
-
81
- if (!isset($byEmail[$email])) {
82
- $byEmail[$email] = array();
83
- }
84
-
85
- $byEmail[$email] [] = (int)$user->getId();
86
- }
87
-
88
- $db = $this->_getWriteAdapter();
89
- $postTable = $this->getTable('wordpress/post');
90
-
91
- foreach($byEmail as $email => $users) {
92
- if (count($users) > 1) {
93
- $original = array_shift($users);
94
-
95
- $db->update($postTable, array('post_author' => $original), $db->quoteInto('post_author IN (?)', $users));
96
- $db->delete($this->getMainTable(), $db->quoteInto('ID IN (?)', $users));
97
- }
98
- }
99
-
100
- $select = $db->select()
101
- ->distinct()
102
- ->from($this->getTable('wordpress/user'), 'ID');
103
-
104
- $userIds = $db->fetchCol($select);
105
-
106
- if (count($userIds) > 0) {
107
- $db->delete($this->getTable('wordpress/user_meta'), $db->quoteInto('user_id NOT IN (?)', $userIds));
108
- }
109
-
110
- return $this;
111
- }
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Resource/User/Collection.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Resource_User_Collection extends Fishpig_Wordpress_Model_Resource_Collection_Abstract
10
- {
11
- /**
12
- * Name prefix of events that are dispatched by model
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_user_collection';
17
-
18
- /**
19
- * Name of event parameter
20
- *
21
- * @var string
22
- */
23
- protected $_eventObject = 'users';
24
-
25
- public function _construct()
26
- {
27
- $this->_init('wordpress/user');
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Sitemap/Sitemap.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- /**
10
- * Magento, if you're listening, you should have already added
11
- * the 2 variables below to this model (and every model!!)
12
- */
13
-
14
- class Fishpig_Wordpress_Model_Sitemap_Sitemap extends Mage_Sitemap_Model_Sitemap
15
- {
16
- /**
17
- * Event data
18
- *
19
- * @var string
20
- */
21
- protected $_eventPrefix = 'sitemap_sitemap';
22
- protected $_eventObject = 'sitemap';
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Autologin.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_System_Config_Backend_Autologin extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
10
- {
11
- /**
12
- * Set the config value
13
- * $value will usually be empty so reload config value with user ID
14
- *
15
- * @param string $value
16
- * @return $this
17
- */
18
- public function setValue($value)
19
- {
20
- if (!$value) {
21
- $value = Mage::getStoreConfig($this->_updatePath()->getPath());
22
- }
23
-
24
- return parent::setValue($value);
25
- }
26
-
27
- /**
28
- * Before saving the config data, update path
29
- * Also decide whether to encrypt value
30
- *
31
- * @return $this
32
- */
33
- protected function _beforeSave()
34
- {
35
- if ((string)$this->getValue()) {
36
- $this->_updatePath();
37
-
38
- return parent::_beforeSave();
39
- }
40
-
41
- return $this;
42
- }
43
-
44
- /**
45
- * After loading data, decide whether to decrypt
46
- * Should not decrypt empty string
47
- *
48
- * @return $this
49
- */
50
- protected function _afterLoad()
51
- {
52
- if ((string)$this->getValue()) {
53
- $originalValue = $this->getValue();
54
-
55
- parent::_afterLoad();
56
-
57
- if ($this->_isValidString($originalValue) && !$this->_isValidString($this->getValue())) {
58
- $this->setValue($originalValue);
59
- }
60
- }
61
-
62
- return $this;
63
- }
64
-
65
- /**
66
- * Modified to return $this
67
- *
68
- * @return $this
69
- */
70
- public function afterLoad()
71
- {
72
- parent::afterLoad();
73
-
74
- return $this;
75
- }
76
-
77
- /**
78
- * Update the internal path data value
79
- * This should include _{{user_id}} on the end
80
- *
81
- * @return $this
82
- */
83
- protected function _updatePath()
84
- {
85
- if (!preg_match('/_[0-9]+$/', $this->getPath())) {
86
- $this->setPath(
87
- $this->getPath() . '_' . Mage::getSingleton('admin/session')->getUser()->getId()
88
- );
89
- }
90
-
91
- return $this;
92
- }
93
-
94
- /**
95
- * Retrieve the username for the current Admin user
96
- *
97
- * @return string
98
- */
99
- public function getUsername()
100
- {
101
- return $this->setPath('wordpress/autologin/username')
102
- ->setValue('')
103
- ->afterLoad()
104
- ->getValue();
105
- }
106
-
107
- /**
108
- * Retrieve the password for the current Admin user
109
- *
110
- * @return string
111
- */
112
- public function getPassword()
113
- {
114
- return $this->setPath('wordpress/autologin/password')
115
- ->setValue('')
116
- ->afterLoad()
117
- ->getValue();
118
- }
119
-
120
- /**
121
- * Check whether $s is a valid string
122
- * Some Magento instances don't encrypt the string so when we decrypt
123
- * it breaks the string
124
- *
125
- * @param string $s
126
- * @return bool
127
- */
128
- protected function _isValidString($s)
129
- {
130
- return (bool)preg_match('//u', $s);
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Backend/Encrypted.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_System_Config_Backend_Encrypted extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
10
- {
11
- /**
12
- * Decrypt value after loading
13
- * If no value present, do not decrypt!
14
- */
15
- protected function _afterLoad()
16
- {
17
- $value = (string)$this->getValue();
18
-
19
- if ($value) {
20
- parent::_afterLoad();
21
- }
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Menu.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_System_Config_Source_Menu
10
- {
11
- protected $_options = null;
12
-
13
- public function toOptionArray()
14
- {
15
- if (is_null($this->_options)) {
16
- $this->_options = array(array(
17
- 'value' => '',
18
- 'label' => Mage::helper('adminhtml')->__('-- Please Select --')
19
- ));
20
-
21
- if (Mage::helper('wordpress/app')->getDbConnection()) {
22
- $menus = Mage::getResourceModel('wordpress/menu_collection')->load();
23
-
24
- foreach($menus as $menu) {
25
- $this->_options[] = array('value' => $menu->getId(), 'label' => $menu->getName());
26
- }
27
- }
28
- }
29
-
30
- return $this->_options;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/System/Config/Source/Social/Media/Service.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_System_Config_Source_Social_Media_Service
10
- {
11
- public function getOptions()
12
- {
13
- return array(
14
- Fishpig_Wordpress_Helper_Social::SERVICE_SHARETHIS => Mage::helper('wordpress')->__('ShareThis'),
15
- );
16
- }
17
-
18
- public function toOptionArray()
19
- {
20
- $options = array();
21
-
22
- foreach($this->getOptions() as $value => $label) {
23
- $options[] = array(
24
- 'value' => $value,
25
- 'label' => $label,
26
- );
27
- }
28
-
29
- return $options;
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Term.php DELETED
@@ -1,222 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Term extends Fishpig_Wordpress_Model_Abstract
10
- {
11
- /**
12
- * Event data
13
- *
14
- * @var string
15
- */
16
- protected $_eventPrefix = 'wordpress_term';
17
- protected $_eventObject = 'term';
18
-
19
- public function _construct()
20
- {
21
- $this->_init('wordpress/term');
22
- }
23
-
24
- /**
25
- * Get the taxonomy object for this term
26
- *
27
- * @return Fishpig_Wordpress_Model_Term_Taxonomy
28
- */
29
- public function getTaxonomyInstance()
30
- {
31
- return Mage::helper('wordpress/app')->getTaxonomy($this->getTaxonomy());
32
- }
33
-
34
- /**
35
- * Retrieve the taxonomy label
36
- *
37
- * @return string
38
- */
39
- public function getTaxonomyLabel()
40
- {
41
- if ($this->getTaxonomy()) {
42
- return ucwords(str_replace('_', ' ', $this->getTaxonomy()));
43
- }
44
-
45
- return false;
46
- }
47
-
48
- /**
49
- * Retrieve the parent term
50
- *
51
- * @reurn false|Fishpig_Wordpress_Model_Term
52
- */
53
- public function getParentTerm()
54
- {
55
- if (!$this->hasParentTerm()) {
56
- $this->setParentTerm(false);
57
-
58
- if ($this->getParentId()) {
59
- $parentTerm = Mage::getModel($this->getResourceName())->load($this->getParentId());
60
-
61
- if ($parentTerm->getId()) {
62
- $this->setParentTerm($parentTerm);
63
- }
64
- }
65
- }
66
-
67
- return $this->_getData('parent_term');
68
- }
69
-
70
- /**
71
- * Retrieve a collection of children terms
72
- *
73
- * @return Fishpig_Wordpress_Model_Mysql_Term_Collection
74
- */
75
- public function getChildrenTerms()
76
- {
77
- return $this->getCollection()->addParentFilter($this);
78
- }
79
-
80
- /**
81
- * Loads the posts belonging to this category
82
- *
83
- * @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
84
- */
85
- public function getPostCollection()
86
- {
87
- return parent::getPostCollection()
88
- ->addIsViewableFilter()
89
- ->addTermIdFilter($this->getChildIds(), $this->getTaxonomy());
90
- }
91
-
92
- /**
93
- * Retrieve the numbers of items that belong to this term
94
- *
95
- * @return int
96
- */
97
- public function getItemCount()
98
- {
99
- return $this->getCount();
100
- }
101
-
102
- /**
103
- * Retrieve the parent ID
104
- *
105
- * @return int|false
106
- */
107
- public function getParentId()
108
- {
109
- return $this->_getData('parent') ? $this->_getData('parent') : false;
110
- }
111
-
112
- /**
113
- * Retrieve the taxonomy type for this term
114
- *
115
- * @return string
116
- */
117
- public function getTaxonomyType()
118
- {
119
- return $this->getTaxonomy();
120
- }
121
-
122
- /**
123
- * Retrieve the URL for this term
124
- *
125
- * @return string
126
- */
127
- public function getUrl()
128
- {
129
- return Mage::helper('wordpress')->getUrl($this->getUri() . '/');
130
- }
131
-
132
- /**
133
- * Retrieve the URL for this term
134
- *
135
- * @return string
136
- */
137
- public function getUri()
138
- {
139
- if (!$this->hasUri()) {
140
- $this->setUri(
141
- $this->getTaxonomyInstance()->getUriById($this->getId())
142
- );
143
- }
144
-
145
- return $this->_getData('uri');
146
- }
147
-
148
- /**
149
- * Retrieve an image URL for the category
150
- * This uses the Category Images plugin (http://wordpress.org/plugins/categories-images/)
151
- *
152
- * @return false|string
153
- */
154
- public function getImageUrl()
155
- {
156
- return ($imageUrl = Mage::helper('wordpress')->getWpOption('z_taxonomy_image' . $this->getId()))
157
- ? $imageUrl
158
- : false;
159
- }
160
-
161
- /**
162
- * Get the children terms
163
- *
164
- * @deprecated - 3.2.0.0 / use self::getChildrenTerms
165
- */
166
- public function getChildrenCategories()
167
- {
168
- return $this->getChildrenTerms();
169
- }
170
-
171
- /**
172
- * Get the number of posts belonging to the term
173
- *
174
- * @return int
175
- */
176
- public function getPostCount()
177
- {
178
- return (int)$this->getCount();
179
- }
180
-
181
- /**
182
- * Get an array of all child ID's
183
- * This includes the ID's of children's children
184
- *
185
- * @return array
186
- */
187
- public function getChildIds()
188
- {
189
- if (!$this->hasChildIds()) {
190
- $this->setChildIds(
191
- $this->getResource()->getChildIds($this->getId())
192
- );
193
- }
194
-
195
- return $this->_getData('child_ids');
196
- }
197
-
198
- /**
199
- * Get the meta value using ACF if it's installed
200
- *
201
- * @param string $key
202
- * @return mixed
203
- **/
204
- public function getMetaValue($key)
205
- {
206
- $ikey = '__acf_meta_' . $key;
207
-
208
- if ($this->hasData($ikey)) {
209
- return $this->_getData($ikey);
210
- }
211
-
212
- if (!Mage::helper('wordpress')->isAddonInstalled('ACF')) {
213
- $this->setData($ikey, null);
214
-
215
- return null;
216
- }
217
-
218
- $this->setData($ikey, Mage::helper('wp_addon_acf')->getTermValue($key, $this));
219
-
220
- return $this->_getData($ikey);
221
- }
222
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/Term/Taxonomy.php DELETED
@@ -1,132 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_Term_Taxonomy extends Varien_Object
10
- {
11
- /**
12
- * Get the URI's that apply to $uri
13
- *
14
- * @param string $uri = ''
15
- * @return array|false
16
- */
17
- public function getUris($uri = '')
18
- {
19
- if ($uri && $this->getSlug() && strpos($uri, $this->getSlug()) === false) {
20
- return false;
21
- }
22
-
23
- return $this->getAllUris();
24
- }
25
-
26
- /**
27
- * Get all of the URI's for this taxonomy
28
- *
29
- * @return array|false
30
- */
31
- public function getAllUris()
32
- {
33
- if ($this->hasAllUris()) {
34
- return $this->_getData('all_uris');
35
- }
36
-
37
- $this->setAllUris(false);
38
-
39
- $helper = Mage::helper('wordpress/app');
40
- $db = $helper->getDbConnection();
41
-
42
- $select = $db->select()
43
- ->from(array('term' => $helper->getTableName('wordpress/term')), array(
44
- 'id' => 'term_id',
45
- 'url_key' => 'slug',new Zend_Db_Expr("TRIM(LEADING '/' FROM CONCAT('" . rtrim($this->getSlug(), '/') . "/', slug))"),
46
- ))
47
- ->join(
48
- array('tax' => $helper->getTableName('wordpress/term_taxonomy')),
49
- $db->quoteInto("tax.term_id = term.term_id AND tax.taxonomy = ?", $this->getTaxonomyType()),
50
- 'parent'
51
- );
52
-
53
- if ($results = $db->fetchAll($select)) {
54
- if ((bool)Mage::getConfig()->getNode('wordpress/legacy/disable_term_hierarchy')) {
55
- foreach($results as $key => $result) {
56
- $results[$key]['parent'] = null;
57
- }
58
- }
59
-
60
- $this->setAllUris(Mage::helper('wordpress/router')->generateRoutesFromArray($results, $this->getSlug()));
61
- }
62
-
63
- return $this->_getData('all_uris');
64
- }
65
-
66
- /**
67
- * Retrieve the URI for $term
68
- *
69
- * @param Fishpig_Wordpress_Model_Term $term
70
- * @return false|string
71
- */
72
- public function getUriById($id, $includePrefix = true)
73
- {
74
- if (($uris = $this->getAllUris()) !== false) {
75
- if (isset($uris[$id])) {
76
- $uri = $uris[$id];
77
-
78
- if (!$includePrefix && $this->getSlug() && strpos($uri, $this->getSlug() . '/') === 0) {
79
- $uri = substr($uri, strlen($this->getSlug())+1);
80
- }
81
-
82
- return $uri;
83
- }
84
- }
85
-
86
- return false;
87
- }
88
-
89
- /**
90
- * Determine whether the taxonomy uses a hierarchy in it's link
91
- *
92
- * @return bool
93
- */
94
- public function isHierarchical()
95
- {
96
- return (int)$this->getData('hierarchical') === 1;
97
- }
98
-
99
- /**
100
- * Get the taxonomy slug
101
- *
102
- * @return string
103
- */
104
- public function getSlug()
105
- {
106
- return trim($this->getData('rewrite/slug'), '/');
107
- }
108
-
109
- public function setSlug($slug)
110
- {
111
- if (!isset($this->_data['rewrite'])) {
112
- $this->_data['rewrite'] = array();
113
- }
114
-
115
- $this->_data['rewrite']['slug'] = $slug;
116
-
117
- return $this;
118
- }
119
-
120
- /**
121
- * Get a collection of terms that belong this taxonomy and $post
122
- *
123
- * @param Fishpig_Wordpress_Model_Post $post
124
- * @return Fishpig_Wordpress_Model_Resource_Post_Collection
125
- */
126
- public function getPostTermsCollection(Fishpig_Wordpress_Model_Post $post)
127
- {
128
- return Mage::getResourceModel('wordpress/term_collection')
129
- ->addTaxonomyFilter($this->getTaxonomyType())
130
- ->addPostIdFilter($post->getId());
131
- }
132
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model app/code/community/Fishpig/Wordpress/Model/User.php DELETED
@@ -1,267 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Model_User extends Fishpig_Wordpress_Model_Abstract
10
- {
11
- /**
12
- * Entity meta infromation
13
- *
14
- * @var string
15
- */
16
- protected $_metaTable = 'wordpress/user_meta';
17
- protected $_metaTableObjectField = 'user_id';
18
- protected $_metaHasPrefix = true;
19
-
20
- /**
21
- * Event information
22
- *
23
- * @var string
24
- */
25
- protected $_eventPrefix = 'wordpress_user';
26
- protected $_eventObject = 'user';
27
-
28
- /**
29
- * Retrieve the column name of the primary key fields
30
- *
31
- * @return string
32
- */
33
- public function getMetaPrimaryKeyField()
34
- {
35
- return 'umeta_id';
36
- }
37
-
38
- public function _construct()
39
- {
40
- $this->_init('wordpress/user');
41
- }
42
-
43
- /**
44
- * Load a user by an email address
45
- *
46
- * @param string $email
47
- * @return $this
48
- */
49
- public function loadByEmail($email)
50
- {
51
- return $this->load($email, 'user_email');
52
- }
53
-
54
- /**
55
- * Get the URL for this user
56
- *
57
- * @return string
58
- */
59
- public function getUrl()
60
- {
61
- if (!$this->hasUrl()) {
62
- $this->setUrl(Mage::helper('wordpress')->getUrl('author/' . urlencode($this->getUserNicename())) . '/');
63
- }
64
-
65
- return $this->_getData('url');
66
- }
67
-
68
- /**
69
- * Load the WordPress user model associated with the current logged in customer
70
- *
71
- * @return Fishpig_Wordpress_Model_User
72
- */
73
- public function loadCurrentLoggedInUser()
74
- {
75
- return $this->getResource()->loadCurrentLoggedInUser($this);
76
- }
77
-
78
- /**
79
- * Retrieve the table prefix
80
- * This is also used to prefix some fields (roles)
81
- *
82
- * @return string
83
- */
84
- public function getTablePrefix()
85
- {
86
- return Mage::helper('wordpress/app')->getTablePrefix();
87
- }
88
-
89
- /**
90
- * Retrieve the user's role
91
- *
92
- * @return false|string
93
- */
94
- public function getRole()
95
- {
96
- if ($roles = $this->getMetaValue($this->getTablePrefix() . 'capabilities')) {
97
- foreach(unserialize($roles) as $role => $junk) {
98
- return $role;
99
- }
100
- }
101
-
102
- return false;
103
- }
104
-
105
- /**
106
- * Set the user's role
107
- *
108
- * @param string $role
109
- * @return $this
110
- */
111
- public function setRole($role)
112
- {
113
- $this->setMetaValue($this->getTablePrefix() . 'capabilities', serialize(array($role => '1')));
114
-
115
- return $this;
116
- }
117
-
118
- /**
119
- * Retrieve the user level
120
- *
121
- * @return int
122
- */
123
- public function getUserLevel()
124
- {
125
- return $this->getMetaValue($this->getTablePrefix() . 'user_level');
126
- }
127
-
128
- /**
129
- * Set the user level
130
- *
131
- * @param int $level
132
- * @return $this
133
- */
134
- public function setUserLevel($level)
135
- {
136
- $this->setMetaValue($this->getTablePrefix() . 'user_level', $level);
137
- return $this;
138
- }
139
-
140
- /**
141
- * Retrieve the users first name
142
- *
143
- * @return string
144
- */
145
- public function getFirstName()
146
- {
147
- return $this->getMetaValue('first_name');
148
- }
149
-
150
- /**
151
- * Set the users first name
152
- *
153
- * @param string $name
154
- * @return $this
155
- */
156
- public function setFirstName($name)
157
- {
158
- $this->setMetaValue('first_name', $name);
159
- return $this;
160
- }
161
-
162
- /**
163
- * Retrieve the users last name
164
- *
165
- * @return string
166
- */
167
- public function getLastName()
168
- {
169
- return $this->getMetaValue('last_name');
170
- }
171
-
172
- /**
173
- * Set the users last name
174
- *
175
- * @param string $name
176
- * @return $this
177
- */
178
- public function setLastName($name)
179
- {
180
- $this->setMetaValue('last_name', $name);
181
- return $this;
182
- }
183
-
184
- /**
185
- * Retrieve the user's nickname
186
- *
187
- * @return string
188
- */
189
- public function getNickname()
190
- {
191
- return $this->getMetaValue('nickname');
192
- }
193
-
194
- /**
195
- * Set the user's nickname
196
- *
197
- * @param string $nickname
198
- * @return $this
199
- */
200
- public function setNickname($nickname)
201
- {
202
- $this->setMetaValue('nickname', $nickname);
203
- return $this;
204
- }
205
-
206
- /**
207
- * Retrieve the URL for Gravatar
208
- *
209
- * @return string
210
- */
211
- public function getGravatarUrl($size = 50)
212
- {
213
- return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($this->getUserEmail()))) . "?d=" . urlencode( $this->_getDefaultGravatarImage() ) . "&s=" . $size;
214
- }
215
-
216
- /**
217
- * Retrieve the URL to the default gravatar image
218
- *
219
- * @return string
220
- */
221
- protected function _getDefaultGravatarImage()
222
- {
223
- return '';
224
- }
225
-
226
- /**
227
- * Retrieve the user's photo
228
- * The UserPhoto plugin must be installed in WordPress
229
- *
230
- * @param bool $thumb
231
- * @return null|string
232
- */
233
- public function getUserPhoto($thumb = false)
234
- {
235
- $dataKey = $thumb ? 'userphoto_thumb_file' : 'userphoto_image_file';
236
-
237
- if (!$this->hasData($dataKey)) {
238
- if ($photo = $this->getCustomField($dataKey)) {
239
- $this->setData($dataKey, Mage::helper('wordpress')->getFileUploadUrl() . 'userphoto/' . $photo);
240
- }
241
- else if (Mage::helper('wordpress')->getWpOption('userphoto_use_avatar_fallback')) {
242
- if ($thumb) {
243
- $this->setData($dataKey, $this->getGravatarUrl(Mage::helper('wordpress')->getWpOption('userphoto_thumb_dimension')));
244
- }
245
- else {
246
- $this->setData($dataKey, $this->getGravatarUrl(Mage::helper('wordpress')->getWpOption('userphoto_maximum_dimension')));
247
- }
248
- }
249
- }
250
-
251
- return $this->_getData($dataKey);
252
- }
253
-
254
- /**
255
- * Retrieve the default user role from the WordPress Database
256
- *
257
- * @return string
258
- */
259
- public function getDefaultUserRole()
260
- {
261
- if (($role = trim(Mage::helper('wordpress')->getWpOption('default_role', 'subscriber'))) !== '') {
262
- return $role;
263
- }
264
-
265
- return 'subscriber';
266
- }
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/change-log.txt app/code/community/Fishpig/Wordpress/change-log.txt app/code/community/Fishpig/Wordpress/change-log.txt DELETED
@@ -1,256 +0,0 @@
1
- /**
2
- * @category Fishpig
3
- * @package Fishpig_Wordpress
4
- * @url http://fishpig.co.uk/magento/wordpress-integration/
5
- * @author Ben Tideswell <ben@fishpig.co.uk>
6
- */
7
-
8
- ??/11/2016 - 4.2.0.29
9
- - Added fix for comments on custom post types.
10
-
11
- 31/10/2016 - 4.2.0.28
12
- - Fixed issue that stopped non 'post' post types from working.
13
-
14
- 26/10/2016 - 4.2.0.25
15
- - Fixed pager issue that affected a small number of installs.
16
- - Fixed preview issue for posts when using Root. Requires Root upgrade to latest version.
17
-
18
- 29/09/2016 - 4.2.0.23
19
- - Added support for recurring events in The Events Calendar Pro 1.1.0.18.
20
-
21
- 09/09/2016 - 4.2.0.21
22
- - Fixed issue that broke some add-on integrations.
23
-
24
- 01/09/2016 - 4.2.0.20
25
- - Added support for %%page%% in Yoast SEO title and metas.
26
- - Added config options to include jQuery and underscore.js if required by an add-on extension. These options can be found in System > Configuration > WordPress > Misc.
27
-
28
- 13/07/2016 - 4.2.0.19
29
- - Fixed DB issue with Root installed.
30
-
31
- 23/06/2016 - 4.2.0.17
32
- - Fixed title html entity issue
33
-
34
- 07/06/2016 - 4.2.0.16
35
- - API fix. You also need to update Root (if you have this installed).
36
-
37
- 24/05/2016 - 4.2.0.14
38
- - Fixed issue where disabling Open Graph tags in Yoast SEO did not disable OG tags. This now does disable them.
39
-
40
- 24/05/2016 - 4.2.0.12
41
- - Fixed XML sitemap issue so that all XML sitemaps are now created when generating via the CRON.
42
-
43
- 23/05/2016 - 4.2.0.11
44
- - Added wordpress/shortcode_product block for product shortcodes. This fixes the issue where prices don't display.
45
-
46
- 19/05/2016 - 4.2.0.10
47
- - Fixed issue with title separator in Yoast SEO plugin.
48
-
49
- 11/05/2016 - 4.2.0.9
50
- - Fixed issue that added Site name to the end of a page title set via Yoast.
51
-
52
- 05/05/2016 - 4.2.0.8
53
- - Fixed issue with primary category.
54
-
55
- 05/05/2016 - 4.2.0.7
56
- - Fixed empty post view page issue.
57
-
58
- 04/05/2016 - 4.2.0.6
59
- - Fixed issue that stopped custom template being set for post view pages. To fix, ensure template="wordpress/post/view.phtml" is removed from wordpress.xml.
60
-
61
- 27/04/2016 - 4.2.0.4
62
- - Improved category selection for Post permalinks. By default, the category with the lowest ID will be used. If Yoast SEO is installed, the lowest category alphabetically will be used. If you select a Primary Category using Yoast SEO, this will be used on a per post basis.
63
-
64
- 18/04/2016 - 4.2.0.3
65
- - Fixed XML Sitemap issue when running via the CRON.
66
-
67
- 31/03/2016 - 4.2.0.2
68
- - Fixed issue where underscore.js wasn't included when required.
69
-
70
- 16/03/2016 - 4.2.0.0
71
- - Added new add-on integration system that allows for better integration. You can now use supported shortcodes anywhere around your Magento site using <?php echo Mage::helper('wordpress/filter')->process('[contact-form-7 id="1"]') ?>. You will need to change the shortcode to match your shortcode. Only supported shortcodes will work. You may need to purchase an add-on extension to get specific shortcodes working.
72
-
73
- 02/03/2016 - 4.1.2.11
74
- - Improved the auto-paragraph function (wpautop).
75
-
76
- 19/02/2016 - 4.1.2.10
77
- - Fixed pagination issue when using Integrated Search
78
- - Improved $post->getPostExcerpt() to accept an integer parameter that limits the number of words returned. echo $post->getPostExcerpt(50) will limit the excerpt to 50 words.
79
-
80
- 27/01/2016 - 4.1.2.9
81
- - Added the shortcode params to the block for the product shortcode. This means you can set custom values such as [product id="4" type="custom"] and then in the template you can use $this->getParams()->getType() to get the type you set. This allows you to customise the template based on what's set in the shortcode.
82
-
83
- 19/01/2016 - 4.1.2.8
84
- - Improved wpautop function.
85
-
86
- 19/01/2016 - 4.1.2.7
87
- - Added before/after RSS entry text via Yoast SEO.
88
-
89
- 16/01/2016 - 4.1.2.6
90
- - Bug fix for issue introduced in version 4.1.2.4 where if a term had no child term's, no posts would be displayed.
91
-
92
- 15/01/2016 - 4.1.2.4
93
- - Fixed issue so that posts that belong to child categories show up in parent category
94
- - Fix for Custom Sidebars
95
-
96
- 05/01/2016 - 4.1.2.3
97
- - Fixed issue with permalinks being encoded incorrectly.
98
-
99
- 04/01/2016 - 4.1.2.2
100
- - Fixed menu caching issue.
101
- - Added support for PHP 7.
102
-
103
- 14/12/2015 - 4.1.2.1
104
- - Fixed version number in config.xml
105
- - Fixed pass by reference error
106
-
107
- 10/12/2015 - 4.1.1.33
108
- - Added custom taxonomies to associated category list.
109
- - Improved Fishpig_Wordpress_Helper_Abstract::getDefaultStore() method
110
-
111
- 09/12/2015 - 4.1.1.31
112
- - Fix for custom post type archive pages not showing up.
113
-
114
- 25/11/2015 - 4.1.1.28
115
- - Fixed issue that stopped setting a WordPress page template from the WordPress Admin from working. You can use the page template feature to set a 1 column layout for Page (post type with post_type of 'page').
116
-
117
- 13/11/2015 - 4.1.1.27
118
- - Fixed issue with incorrect URLs for posts
119
-
120
- 06/11/2015 - 4.1.1.25
121
- - Improve jQuery inclusion by add-ons.
122
-
123
- 04/11/2015 - 4.1.1.23
124
- - Fix for URLs in The Events Calendar
125
-
126
- 02/11/2015 - 4.1.1.21
127
- - Fixed YouTube shortcode includes.
128
-
129
- 02/11/2015 - 4.1.1.20
130
- - Added support for '.html' in permalink strings for custom post types when using the WP Permastructure plugin. This requires the Post Types and Taxonomies add-on extension (http://fishpig.co.uk/magento/wordpress-integration/post-types-taxonomies/).
131
- - Added support for custom taxonomies in the breadcrumbs.
132
-
133
- 02/11/2015 - 4.1.1.19
134
- - Updated WPSeo to work with the Tribe Events Calendar plugin integration.
135
-
136
- 29/10/2015 - 4.1.1.18
137
- - Added support for the WP Permastructure plugin. This requires the Post Types and Taxonomies add-on (http://fishpig.co.uk/magento/wordpress-integration/post-types-taxonomies/).
138
-
139
- 14/10/2015 - 4.1.1.14
140
- - Added support for Spotify URLs (eg. http://open.spotify.com/track/4bz7uB4edifWKJXSDxwHcs) and Spotify codes (eg. spotify:track:2TpxZ7JUBn3uw46aR7qd6V). Simply add the URL or code to your post content field on it's own line and this will be converted into a Spotify include/iframe.
141
-
142
- 14/10/2015 - 4.1.1.12
143
- - Fixed issue that broke RSS feeds for custom post type comments.
144
- - Fixed issue that broke RSS feeds when a blog post author didn't have an email address set.
145
- - Fixed issue that stopped the pager working. If you are still experiencing this issue, find wordpress.xml in your custom theme's layout directory and delete this file. This will allow the updated version in base/default to be used. For future reference, you should try not to edit wordpress.xml and instead, make all changes via a local.xml file in your custom theme's layout directory. This will allow you to avoid common layout issues such as these and will make upgrading the extension much easier.
146
-
147
- 13/10/2015 - 4.1.1.11
148
- - Reordered layout handles so that more specific layout handles take precedence over simple layout handles.
149
-
150
- 06/10/2015 - 4.1.1.8
151
- - Fixed issue with term_order field in term collections. Field is only added to order if it exists in the database.
152
-
153
- 05/10/2015 - 4.1.1.7
154
- - Added 'term_order' to ORDER BY for term collections.
155
-
156
- 05/10/2015 - 4.1.1.6
157
- - Improved auto HTML formatting, especially when using Visual Composer.
158
-
159
- 02/10/2015 - 4.1.1.5
160
- - Added fix for using WordPress as homepage. Fixed issue that caused WP Page and post list to display.
161
-
162
- 24/09/2015 - 4.1.1.4
163
- - Fixed issue with category slugs in post permalinks
164
- - Fixed issue with YouTube shortcodes
165
-
166
- 22/09/2015 - 4.1.1.2
167
- - Fixed issue with trailing slash not appearing in page URLs when not using the Post Types & Taxonomies add-on extension.
168
-
169
- 18/09/2015 - 4.1.1.1
170
- - Added fix for custom sidebars with categories and other terms
171
- - Fixed escaping slashes issue in social helper
172
-
173
- 12/09/2015 - 4.1.0.5
174
- - Added fix for sticky posts so that sticky posts always come first.
175
- - Added fix for custom sidebars with categories and other terms
176
-
177
- 10/09/2015 - 4.1.0.2
178
- - Fixed issue that could cause a double '/' in pager URLs.
179
- - Fixed issue that stopped custom post view templates (defined in the XML) from working.
180
-
181
- 08/09/2015 - 4.1.0.1
182
- - Fixed issue regarding automatic template selection. You can now create the following templates for custom post types that will be used automatically. For the post list/archive view create wordpress/post/list/renderer/posttype.phtml (changing posttype for the name of your post type) and for the single post view, you can create wordpress/post/view/posttype.phtml. These paths are relative to the template directory of your custom theme.
183
-
184
- 04/09/2015 - 4.1.0.0
185
- - Added licensing to the extension.
186
-
187
- 01/09/2015 - 4.0.0.40
188
- - Fixed an issue that caused a conflict with the m2e extension.
189
-
190
- 14/08/2015 - 4.0.0.39
191
- - Fixed issue that triggered a PHP fatal error (Fatal error: Call to a member function isHierarchical() on a non-object) when previewing a post.
192
- - Fixed Twitter Card image. The featured image is now used at the Twitter Card image.
193
-
194
- 12/08/2015 - 4.0.0.38
195
- - Fix for the associations system that shows the correct blog posts when viewing a store that is associated with a blog that is not the default blog.
196
-
197
- 10/08/2015 - 4.0.0.37
198
- - Another ACL fix for the auto-login system
199
-
200
- 14/07/2015 - 4.0.0.36
201
- - Fixed issue that caused 'Warning: session_start(): Cannot send session cache limiter - headers already sent ' error message.
202
-
203
- 13/07/2015 - 4.0.0.35
204
- - Added some legacy references to the Page model to make upgrading slightly easier.
205
-
206
- 09/07/2015 - 4.0.0.34
207
- - This update fixes the ACL issue present when using Magento 1.9.2.0. If you get an 'Access Denied' message when viewing the SmartTabs admin page (even after logging out and logging back in) and are using Magento 1.9.2.0, upgrading to this version will fix that issue.
208
-
209
- 26/06/2015 - 4.0.0.29
210
- - Fixed getConnection() issue in associated products and categories
211
-
212
- 24/06/2015 - 4.0.0.24
213
- - Minor bug fixes for Root compatibility
214
-
215
- 19/06/2015 - 4.0.0.23
216
- - Fixed WordPress menu issue
217
-
218
- 16/06/2015 - 4.0.0.18
219
- - Fixed issue with category and tag prefixes
220
-
221
- 15/06/2015 - 4.0.0.17
222
- - Added automatic setting of custom templates for post archive pages. Simply create a file at wordpress/post/list/renderer/%postyype%.phtml and it will be used automatically.
223
-
224
- 15/06/2015 - 4.0.0.16
225
- - Minor bug fixes
226
-
227
- 13/06/2015 - 4.0.0.10
228
- - Added support for the Post Types Order plugin
229
-
230
- 12/06/2015 - 4.0.0.9
231
- - Fixed issue that broke Multisite
232
-
233
- 12/06/2015 - 4.0.0.8
234
- - Fixed URL's for 'page' post type
235
-
236
- 12/06/2015 - 4.0.0.7
237
- - Fixed URL's for 'post' post type
238
-
239
- 11/06/2015 - 4.0.0.6
240
- - Added improvements to post types that have hierarchies
241
-
242
- 11/06/2015 - 4.0.0.4
243
- - Fixed issue when using default permalinks
244
-
245
- 10/06/2015 - 4.0.0.3
246
- - Fixed issue with sub-categories not displaying in sidebar widget
247
- - Fixed WordPress SEO issue
248
-
249
- 09/06/2015 - 4.0.0.2
250
- - Fixed XML sitemap generation error
251
-
252
- 09/06/2015 - 4.0.0.0
253
- - Game on! Big changes!
254
- - The Page model has been removed and is now served via the Post model.
255
- - The Post_Category and Post_Tag models have been removed and can be accessed via the Term model
256
- - For more information, please see http://fishpig.co.uk/magento/wordpress-integration/upgrading-to-version-4/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/Adminhtml/Wordpress/AssociationsController.php DELETED
@@ -1,244 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Adminhtml_Wordpress_AssociationsController extends Mage_Adminhtml_Controller_Action
10
- {
11
- /**
12
- * Determine ACL permissions
13
- *
14
- * @return bool
15
- */
16
- protected function _isAllowed()
17
- {
18
- return true;
19
- }
20
-
21
- /**
22
- * Display the initial grid
23
- *
24
- */
25
- public function gridAction()
26
- {
27
- $this->_performAssociationAction();
28
- }
29
-
30
- /**
31
- * Display the grid after a refresh via AJAX
32
- *
33
- */
34
- public function gridRefreshAction()
35
- {
36
- $this->_performAssociationAction('_grid');
37
- }
38
-
39
- /**
40
- * This method actually handles loading the layout
41
- * and displaying the grid
42
- * $handlePostfix allows you to specify a postfix for the layout handle
43
- *
44
- * @param string $handlePostfix = ''
45
- * @return void
46
- */
47
- protected function _performAssociationAction($handlePostfix = '')
48
- {
49
- try {
50
- if (!$this->_isSingleStoreMode() && $this->getStoreId() === false) {
51
- $this->getResponse()
52
- ->setBody('<p style="font-size: 18px; margin-top: 40px; text-align: center;">Please select a store using the Store View selector.</p>');
53
-
54
- return false;
55
- }
56
- if ($this->_initObject() === false) {
57
- return $this->_forward('noRoute');
58
- }
59
-
60
- /*
61
- $storeIds = $this->_initObject()->getStoreId();
62
-
63
- if (count($storeIds) === 1) {
64
- $appEmulation = Mage::getSingleton('core/app_emulation');
65
- $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation(array_shift($storeIds));
66
- }
67
- */
68
-
69
- if (Mage::helper('wordpress/app')->getDbConnection() === false) {
70
- return $this->_forward('noWordPressDatabase');;
71
- }
72
-
73
- # $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
74
-
75
- $handle = 'adminhtml_wordpress_association_' . $this->_getMagentoEntity() . '_' . $this->_getWpEntity() . $handlePostfix;
76
-
77
- $this->loadLayout($handle);
78
-
79
- $this->getLayout()->getUpdate()
80
- ->removeHandle('adminhtml_wordpress_associations_grid')
81
- ->removeHandle('STORE_admin')
82
- ->removeHandle('THEME_adminhtml_default_default');
83
-
84
- $this->renderLayout();
85
- }
86
- catch (Exception $e) {
87
- $this->getResponse()->setBody(
88
- sprintf('<h1>%s</h1><pre>%s</pre>', $e->getMessage(), $e->getTraceAsString())
89
- );
90
- }
91
- }
92
-
93
- /**
94
- * Retrieve the current association type
95
- *
96
- * return false|string
97
- */
98
- public function getAssociationType()
99
- {
100
- return $this->getRequest()->getParam('associations_type', false);
101
- }
102
-
103
- /**
104
- * Retrieve the Magento entity type
105
- *
106
- * @return string
107
- */
108
- protected function _getMagentoEntity()
109
- {
110
- if (($type = $this->getAssociationType()) !== false) {
111
- return substr($type, 0, strpos($type, '/'));
112
- }
113
-
114
- return false;
115
- }
116
-
117
- /**
118
- * Retrieve the WordPress entity type
119
- *
120
- * @return string
121
- */
122
- protected function _getWpEntity()
123
- {
124
- if (($type = $this->getAssociationType()) !== false) {
125
- return substr($type, strpos($type, '/')+1);
126
- }
127
-
128
- return false;
129
- }
130
-
131
- /**
132
- * Determine whether only 1 store exists
133
- *
134
- * @return bool
135
- */
136
- protected function _isSingleStoreMode()
137
- {
138
- return Mage::app()->isSingleStoreMode() || Mage::helper('wordpress')->forceSingleStore();
139
- }
140
-
141
- /**
142
- * Retrieve the current store ID
143
- *
144
- * @return int
145
- */
146
- public function getStoreId()
147
- {
148
- if ($this->_getMagentoEntity() === 'cms_page') {
149
- return 0;
150
- }
151
-
152
- if (!$this->_isSingleStoreMode()) {
153
- return $this->getRequest()->getParam('store', false);
154
- }
155
-
156
- return Mage::helper('wordpress')->getDefaultStore()->getId();
157
- }
158
-
159
- /**
160
- * Initialize the Magento object
161
- *
162
- * @return Mage_Core_Model_Abstract|false
163
- */
164
- protected function _initObject()
165
- {
166
- if ($this->_getMagentoEntity() === 'product') {
167
- return $this->_initProduct();
168
- }
169
- else if ($this->_getMagentoEntity() === 'category') {
170
- return $this->_initCategory();
171
- }
172
- else if ($this->_getMagentoEntity() === 'cms_page') {
173
- return $this->_initCmsPage();
174
- }
175
-
176
- return false;
177
- }
178
-
179
- /**
180
- * Initialise the product model
181
- * This should only be called via AJAX actions
182
- *
183
- * @return false|Mage_Catalog_Model_Product
184
- */
185
- protected function _initProduct()
186
- {
187
- if (!Mage::registry('product')) {
188
- if ($productId = $this->getRequest()->getParam('id')) {
189
- $product = Mage::getModel('catalog/product')->load($productId);
190
-
191
- if ($product->getId()) {
192
- Mage::register('product', $product);
193
- return $product;
194
- }
195
- }
196
- }
197
-
198
- return false;
199
- }
200
-
201
- /**
202
- * Initialise the category model
203
- * This should only be called via AJAX actions
204
- *
205
- * @return false|Mage_Catalog_Model_Category
206
- */
207
- protected function _initCategory()
208
- {
209
- if (!Mage::registry('category')) {
210
- if ($categoryId = $this->getRequest()->getParam('id')) {
211
- $category = Mage::getModel('catalog/category')->load($categoryId);
212
-
213
- if ($category->getId()) {
214
- Mage::register('category', $category);
215
- return $category;
216
- }
217
- }
218
- }
219
-
220
- return false;
221
- }
222
-
223
- /**
224
- * Initialise the category model
225
- * This should only be called via AJAX actions
226
- *
227
- * @return false|Mage_Catalog_Model_Category
228
- */
229
- protected function _initCmsPage()
230
- {
231
- if (!Mage::registry('cms_page')) {
232
- if ($pageId = $this->getRequest()->getParam('id')) {
233
- $page = Mage::getModel('cms/page')->load($pageId);
234
-
235
- if ($page->getId()) {
236
- Mage::register('cms_page', $page);
237
- return $page;
238
- }
239
- }
240
- }
241
-
242
- return false;
243
- }
244
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/Adminhtml/WordpressController.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_Adminhtml_WordpressController extends Mage_Adminhtml_Controller_Action
10
- {
11
- /**
12
- * URL to get release information for extension
13
- *
14
- * @const string
15
- */
16
- const URL_RELEASES = 'http://connect20.magentocommerce.com/community/Fishpig_Wordpress_Integration/releases.xml';
17
-
18
- /**
19
- * Attempt to login to the WordPress Admin action
20
- *
21
- */
22
- public function loginAction()
23
- {
24
- $autoLogin = Mage::getSingleton('wordpress/system_config_backend_autologin');
25
-
26
- $username = $autoLogin->getUsername();
27
- $password = $autoLogin->getPassword();
28
-
29
- try {
30
- if (!$username || !$password) {
31
- throw new Exception($this->__('WordPress Admin details not set.'));
32
- }
33
-
34
- Mage::helper('wordpress/system')->loginToWordPress($username, $password, Mage::helper('wordpress')->getAdminUrl());
35
- exit;
36
-
37
- $this->_redirectUrl(Mage::helper('wordpress')->getAdminUrl('index.php'));
38
- }
39
- catch (Exception $e) {
40
- Mage::helper('wordpress')->log($e);
41
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
42
-
43
- $this->_redirect('adminhtml/system_config/edit', array('section' => 'wordpress'));
44
- }
45
- }
46
-
47
- /**
48
- * Check for the latest WordPress versions
49
- *
50
- */
51
- public function checkVersionAction()
52
- {
53
- $current = Mage::helper('wordpress/system')->getExtensionVersion();
54
- $cacheKey = 'wordpress_integration_update' . str_replace('.', '_', $current);
55
-
56
- try {
57
- if (($latest = Mage::app()->getCache()->load($cacheKey)) === false) {
58
- $response = Mage::helper('wordpress/system')->makeHttpGetRequest(
59
- self::URL_RELEASES
60
- );
61
-
62
- if (strpos($response, '<?xml') === false) {
63
- throw new Exception('Invalid response');
64
- }
65
-
66
- $response = trim(substr($response, strpos($response, '<?xml')));
67
- $xml = simplexml_load_string($response);
68
- $latest = false;
69
-
70
- foreach($xml->r as $release) {
71
- if ((string)$release->s === 'stable') {
72
- if (!$latest || version_compare($release->v, $latest, '>=')) {
73
- $latest = (string)$release->v;
74
- }
75
- }
76
- }
77
-
78
- Mage::app()->getCache()->save(
79
- $latest,
80
- $cacheKey,
81
- array('WP_UPDATE'),
82
- ((60*60)*24)*7
83
- );
84
- }
85
-
86
- $this->getResponse()
87
- ->setHeader('Content-Type', 'application/json; charset=UTF-8')
88
- ->setBody(
89
- json_encode(
90
- array('latest_version' => $latest)
91
- )
92
- );
93
- }
94
- catch (Exception $e) {
95
- Mage::helper('wordpress')->log($e);
96
- }
97
- }
98
-
99
- /**
100
- * Determine ACL permissions
101
- *
102
- * @return bool
103
- */
104
- protected function _isAllowed()
105
- {
106
- return true;
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/AjaxController.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_AjaxController extends Mage_Core_Controller_Front_Action
10
- {
11
- /**
12
- * Allow retireval of layout handles via ajax
13
- *
14
- * @return void
15
- */
16
- public function handleAction()
17
- {
18
- if (($handle = trim($this->getRequest()->getParam('handle'))) === '') {
19
- return $this->_forward('noRoute');
20
- }
21
-
22
- $this->loadLayout('wordpress_ajax_' . $handle);
23
- $this->renderLayout();
24
- }
25
-
26
- /**
27
- * Allow retireval of layout blocks via ajax
28
- *
29
- * @return void
30
- */
31
- public function blockAction()
32
- {
33
- if (($name = trim($this->getRequest()->getParam('block'))) === '') {
34
- return $this->_forward('noRoute');
35
- }
36
-
37
- $block = Mage::getSingleton('core/layout')->createBlock('wordpress/' . $name);
38
-
39
- if (!$block) {
40
- return $this->_forward('noRoute');
41
- }
42
-
43
- if ($params = $this->getRequest()->getParams()) {
44
- foreach($params as $key => $value) {
45
- if ($key === 'template') {
46
- $block->setTemplate($value);
47
- }
48
- else {
49
- $block->setData($key, $value);
50
- }
51
- }
52
- }
53
-
54
- $this->getResponse()->setBody($block->toHtml());
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/ArchiveController.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_ArchiveController extends Fishpig_Wordpress_Controller_Abstract
10
- {
11
- /**
12
- * Set the feed blocks
13
- *
14
- * @var string
15
- */
16
- protected $_feedBlock = 'archive_view';
17
-
18
- /**
19
- * Used to do things en-masse
20
- * eg. include canonical URL
21
- *
22
- * @return false|Fishpig_Wordpress_Model_Archive
23
- */
24
- public function getEntityObject()
25
- {
26
- return $this->_initArchive();
27
- }
28
-
29
- /**
30
- * Display the archive and list the posts
31
- *
32
- */
33
- public function viewAction()
34
- {
35
- $archive = Mage::registry('wordpress_archive');
36
-
37
- $this->_addCustomLayoutHandles(array(
38
- 'wordpress_post_list',
39
- 'wordpress_archive_view',
40
- ));
41
-
42
- $this->_initLayout();
43
-
44
- $this->_title($archive->getName());
45
- $this->addCrumb('archive_label', array('label' => $this->__('Archives')));
46
- $this->addCrumb('archive', array('label' => $archive->getName()));
47
-
48
- $this->renderLayout();
49
- }
50
-
51
- /**
52
- * Loads an archive model based on the URI
53
- *
54
- * @return false|Fishpig_Wordpress_Model_Archive
55
- */
56
- protected function _initArchive()
57
- {
58
- if (($archive = Mage::registry('wordpress_archive')) !== null) {
59
- return $archive;
60
- }
61
-
62
- $date = trim(implode('/', array(
63
- $this->getRequest()->getParam('year'),
64
- $this->getRequest()->getParam('month'),
65
- $this->getRequest()->getParam('day'),
66
- )), '/');
67
-
68
-
69
- if ($archive = Mage::getModel('wordpress/archive')->load($date)) {
70
- if ($archive->hasPosts()) {
71
- Mage::register('wordpress_archive', $archive);
72
-
73
- return $archive;
74
- }
75
- }
76
-
77
- return false;
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/AuthorController.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_AuthorController extends Fishpig_Wordpress_Controller_Abstract
10
- {
11
- /**
12
- * Used to do things en-masse
13
- * eg. include canonical URL
14
- *
15
- * @return false|Fishpig_Wordpress_Model_Post_Category
16
- */
17
- public function getEntityObject()
18
- {
19
- return $this->_initAuthor();
20
- }
21
-
22
- /**
23
- * Display the author page and list posts
24
- *
25
- */
26
- public function viewAction()
27
- {
28
- $author = $this->_initAuthor();
29
-
30
- $this->_addCustomLayoutHandles(array(
31
- 'wordpress_post_list',
32
- 'wordpress_author_view',
33
- 'wordpress_author_view_' . $author->getId(),
34
- ));
35
-
36
- $this->_initLayout();
37
-
38
- $this->_title($author->getDisplayName());
39
- $this->addCrumb('author_nolink', array('label' => $this->__('Author')));
40
- $this->addCrumb('author', array('link' => $author->getUrl(), 'label' => $author->getDisplayName()));
41
-
42
- $this->renderLayout();
43
- }
44
-
45
- /**
46
- * Display the author bio
47
- *
48
- * @return void
49
- */
50
- public function bioAction()
51
- {
52
- $author = $this->_initAuthor();
53
-
54
- $this->_addCustomLayoutHandles(array(
55
- 'wordpress_author_bio',
56
- 'wordpress_author_bio_' . $author->getId(),
57
- ));
58
-
59
- $this->_initLayout();
60
-
61
- $this->_title($author->getDisplayName());
62
- $this->addCrumb('author_nolink', array('label' => $this->__('Author')));
63
- $this->addCrumb('author', array('link' => $author->getUrl(), 'label' => $author->getDisplayName()));
64
-
65
- $this->renderLayout();
66
- }
67
-
68
- /**
69
- * Load user based on URI
70
- *
71
- * @return false|Fishpig_Wordpress_Model_User
72
- */
73
- protected function _initAuthor()
74
- {
75
- if (($author = Mage::registry('wordpress_author')) !== null) {
76
- return $author;
77
- }
78
-
79
- $author = Mage::getModel('wordpress/user')->load($this->getRequest()->getParam('author'), 'user_nicename');
80
-
81
- if ($author->getId()) {
82
- Mage::register('wordpress_author', $author);
83
-
84
- return $author;
85
- }
86
-
87
- return false;
88
- }
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/IndexController.php DELETED
@@ -1,156 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_IndexController extends Fishpig_Wordpress_Controller_Abstract
10
- {
11
- /**
12
- * Set the feed blocks
13
- *
14
- * @var string
15
- */
16
- protected $_feedBlock = 'homepage';
17
-
18
- /**
19
- * Used to do things en-masse
20
- * eg. include canonical URL
21
- *
22
- * @return Varien_Object|Fishpig_Wordpress_Model_Page
23
- */
24
- public function getEntityObject()
25
- {
26
- if (Mage::registry('wordpress_post')) {
27
- return Mage::registry('wordpress_post');
28
- }
29
-
30
- return new Varien_Object(array(
31
- 'url' => Mage::helper('wordpress')->getUrl(),
32
- ));
33
- }
34
-
35
- /**
36
- * Display the blog homepage
37
- *
38
- * @return void
39
- */
40
- public function indexAction()
41
- {
42
- /**
43
- * If configured to display page as homepage,
44
- * forward to post controller and set request variables
45
- **/
46
- if (($post = Mage::registry('wordpress_post')) === null) {
47
- if (($postId = Mage::helper('wordpress/router')->getHomepagePageId()) !== false) {
48
- $this->getRequest()
49
- ->setParam('id', $postId)
50
- ->setParam('post_type', 'page')
51
- ->setParam('is_homepage', 1);
52
-
53
- return $this->_forward('view', 'post');
54
- }
55
- }
56
-
57
- $this->_addCustomLayoutHandles(array(
58
- 'wordpress_post_list',
59
- 'wordpress_homepage',
60
- 'wordpress_frontpage',
61
- ));
62
-
63
- $this->_initLayout();
64
- $this->renderLayout();
65
- }
66
-
67
- /**
68
- * Display the blog robots.txt file
69
- *
70
- * @return void
71
- */
72
- public function robotsAction()
73
- {
74
- if (($path = Mage::helper('wordpress')->getWordPressPath()) !== false) {
75
- $robotsFile = $path . 'robots.txt';
76
-
77
- if (is_file($robotsFile) && is_readable($robotsFile)) {
78
- if ($robotsTxt = file_get_contents($robotsFile)) {
79
- $this->getResponse()->setHeader('Content-Type', 'text/plain;charset=utf8');
80
- $this->getResponse()->setBody($robotsTxt);
81
- }
82
- }
83
- }
84
-
85
- if (!$this->getResponse()->getBody()) {
86
- $this->_forward('noRoute');
87
- }
88
- }
89
-
90
- /**
91
- * Redirect the user to the WordPress Admin
92
- *
93
- * @return void
94
- */
95
- public function wpAdminAction()
96
- {
97
- return $this->_redirectTo(Mage::helper('wordpress')->getAdminUrl());
98
- }
99
-
100
- /**
101
- * Forward requests to the WordPress installation
102
- *
103
- * @return void
104
- */
105
- public function forwardAction()
106
- {
107
- return $this->_forwardToWordPress('index.php?' . $_SERVER['QUERY_STRING']);
108
- }
109
-
110
- /**
111
- * Forward requests for images
112
- *
113
- * @return void
114
- */
115
- public function forwardFileAction()
116
- {
117
- return $this->_forwardToWordPress(Mage::helper('wordpress/router')->getBlogUri());
118
- }
119
-
120
- /**
121
- * Validate the new blog user
122
- *
123
- * @return void
124
- */
125
- public function newBlogUserAction()
126
- {
127
- }
128
-
129
- /**
130
- * Set the post password and redirect to the referring page
131
- *
132
- * @return void
133
- */
134
- public function applyPostPasswordAction()
135
- {
136
- Mage::getSingleton('core/session')->setPostPassword($this->getRequest()->getPost('post_password'));
137
-
138
- if ($redirectTo = $this->getRequest()->getPost('redirect_to')) {
139
- $this->_redirectUrl($redirectTo);
140
- }
141
- else {
142
- $this->_redirectReferer();
143
- }
144
- }
145
-
146
- /**
147
- * Forces a redirect to the given URL
148
- *
149
- * @param string $url
150
- * @return bool
151
- */
152
- protected function _redirectTo($url)
153
- {
154
- return $this->getResponse()->setRedirect($url)->sendResponse();
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/PostController.php DELETED
@@ -1,306 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
- class Fishpig_Wordpress_PostController extends Fishpig_Wordpress_Controller_Abstract
9
- {
10
- protected $_isPreview = null;
11
-
12
- /**
13
- * Used to do things en-masse
14
- * eg. include canonical URL
15
- *
16
- * @return false|Mage_Core_Model_Abstract
17
- */
18
- public function getEntityObject()
19
- {
20
- return $this->_initPost();
21
- }
22
-
23
- protected function _isPreview()
24
- {
25
- if ($this->_isPreview === null) {
26
- $this->_isPreview = (int)$this->getRequest()->getParam('preview_id') > 0
27
- || $this->getRequest()->getParam('preview', false) !== false
28
- || $this->getRequest()->getActionName() === 'preview';
29
- }
30
-
31
- return $this->_isPreview;
32
- }
33
-
34
- /**
35
- * Display appropriate message for posted comment
36
- *
37
- * @return $this
38
- */
39
- public function preDispatch()
40
- {
41
- parent::preDispatch();
42
-
43
- $this->_handlePostedComment();
44
-
45
- $post = $this->getEntityObject();
46
-
47
- if ($post->isBlogListingPage()) {
48
- return $this->_forward('index', 'index', 'wordpress');
49
- }
50
-
51
- return $this;
52
- }
53
-
54
- public function previewAction()
55
- {
56
- return $this->_forward('view');
57
- }
58
-
59
- /**
60
- * Display the post view page
61
- *
62
- */
63
- public function viewAction()
64
- {
65
- $post = $this->getEntityObject();
66
-
67
- $layoutHandles = array(
68
- 'wordpress_post_view',
69
- 'wordpress_' . $post->getPostType() . '_view',
70
- );
71
-
72
- $isHomepage = (bool)$this->getRequest()->getParam('is_homepage');
73
-
74
- if ($post->isHomepagePage() && !$isHomepage) {
75
- if (Mage::getUrl('', array('_current' => true, '_use_rewrite' => true)) !== Mage::helper('wordpress')->getUrl()) {
76
- return $this->_redirectUrl(Mage::helper('wordpress')->getUrl());
77
- }
78
- }
79
-
80
- if ($post->getTypeInstance()->isHierarchical()) {
81
- $buffer = $post->getParentPost();
82
-
83
- while ($buffer) {
84
- $layoutHandles[] = 'wordpress_' . $post->getPostType() . '_view_parent_' . $buffer->getId();
85
-
86
- // Legacy
87
- if ($post->isType('page')) {
88
- $layoutHandles[] = 'wordpress_' . $post->getPostType() . '_parent_' . $buffer->getId();
89
- }
90
-
91
- $buffer = $buffer->getParentPost();
92
- }
93
- }
94
-
95
- // Add the layout handle for the post type and ID
96
- $layoutHandles[] = 'wordpress_' . $post->getPostType() . '_view_' . $post->getId();
97
-
98
- if ($post->isHomepagePage() && $isHomepage) {
99
- $layoutHandles[] = 'wordpress_frontpage';
100
- }
101
-
102
- $this->_addCustomLayoutHandles($layoutHandles);
103
- $this->_initLayout();
104
- $this->_title(strip_tags($post->getPostTitle()));
105
-
106
- if (($headBlock = $this->getLayout()->getBlock('head')) !== false) {
107
- $headBlock->addItem(
108
- 'link_rel',
109
- $post->getCommentFeedUrl(),
110
- sprintf('rel="alternate" type="application/rss+xml" title="%s &raquo; %s Comments Feed"',
111
- Mage::helper('wordpress')->getWpOption('blogname'),
112
- $post->getPostTitle()
113
- )
114
- );
115
-
116
- if (Mage::helper('wordpress')->getWpOption('default_ping_status') === 'open' && $post->getPingStatus() == 'open') {
117
- $headBlock->addItem('link_rel', Mage::helper('wordpress')->getBaseUrl() . 'xmlrpc.php', 'rel="pingback"');
118
- }
119
- }
120
-
121
- if ($post->getTypeInstance()->hasArchive()) {
122
- $this->addCrumb($post->getPostType() . '_archive', array('label' => $post->getTypeInstance()->getName(), 'link' => $post->getTypeInstance()->getArchiveUrl()));
123
- }
124
-
125
- if ($isHomepage) {
126
- $post->setCanonicalUrl(Mage::helper('wordpress')->getUrl());
127
-
128
- if (Mage::helper('wordpress')->getBlogRoute() === '') {
129
- $this->_crumbs = array();
130
- }
131
- else {
132
- array_pop($this->_crumbs);
133
- }
134
- }
135
- else if ($post->getTypeInstance()->isHierarchical()) {
136
- $posts = array();
137
- $buffer = $post;
138
-
139
- while ($buffer) {
140
- $this->_title(strip_tags($buffer->getPostTitle()));
141
- $posts[] = $buffer;
142
- $buffer = $buffer->getParentPost();
143
- }
144
-
145
- $posts = array_reverse($posts);
146
-
147
- // Remove current post from end array
148
- array_pop($posts);
149
-
150
- foreach($posts as $buffer) {
151
- $this->addCrumb('post_' . $buffer->getId(), array('label' => $buffer->getPostTitle(), 'link' => $buffer->getUrl()));
152
- }
153
- }
154
- else if ($taxonomy = $post->getTypeInstance()->getAnySupportedTaxonomy('category')) {
155
- if ($term = $post->getParentTerm($taxonomy->getTaxonomyType())) {
156
- $terms = array();
157
-
158
- while($term) {
159
- array_unshift($terms, $term);
160
- $term = $term->getParentTerm();
161
- }
162
-
163
- foreach($terms as $term) {
164
- $this->addCrumb('post_' . $term->getTaxonomyType() . '_' . $term->getId(), array('label' => $term->getName(), 'link' => $term->getUrl()));
165
- }
166
- }
167
- }
168
-
169
- if (!$isHomepage) {
170
- $this->addCrumb('post', array('label' => $post->getPostTitle()));
171
- }
172
-
173
- // Revisions don't have the template meta, grab it from parent
174
- if ($post->getPostType() === 'revision' && ($parent = $post->getParentPost())) {
175
- $template = $parent->getMetaValue('_wp_page_template');
176
- }
177
- else {
178
- $template = $post->getMetaValue('_wp_page_template');
179
- }
180
-
181
- if (strpos($template, 'full-width') !== false) {
182
- if ($root = $this->getLayout()->getBlock('root')) {
183
- $root->setTemplate('page/1column.phtml');
184
- }
185
- }
186
-
187
- if ($rootBlock = $this->getLayout()->getBlock('root')) {
188
- $rootBlock->addBodyClass('wordpress-' . $post->getPostType() . '-' . $post->getId());
189
- }
190
-
191
- $this->renderLayout();
192
- }
193
-
194
- /**
195
- * Display the appropriate message for a posted comment
196
- *
197
- * @return $this
198
- */
199
- protected function _handlePostedComment()
200
- {
201
- $commentId = $this->getRequest()->getParam('comment');
202
-
203
- if ($commentId && $this->getRequest()->getActionName() === 'view') {
204
- $comment = Mage::getModel('wordpress/post_comment')->load($commentId);
205
-
206
- if ($comment->getId() && $comment->getPost()->getId() === $this->getEntityObject()->getId()) {
207
- if ($comment->isApproved()) {
208
- header('Location: ' . $comment->getUrl());
209
- exit;
210
- }
211
- else {
212
- Mage::getSingleton('core/session')->addSuccess($this->__('Your comment is awaiting moderation.'));
213
- }
214
- }
215
- }
216
-
217
- return $this;
218
- }
219
-
220
- /**
221
- * Initialise the post model
222
- * Provides redirects for Guid links when using permalinks
223
- *
224
- * @return false|Fishpig_Wordpress_Model_Post
225
- */
226
- protected function _initPost()
227
- {
228
- if (($post = Mage::registry('wordpress_post')) !== null) {
229
- $previewId = $this->getRequest()->getParam('preview_id');
230
-
231
- if ($previewId === $post->getId()) {
232
- $posts = Mage::getResourceModel('wordpress/post_collection')
233
- ->addFieldToFilter('post_parent', $post->getId())
234
- ->addPostTypeFilter('revision')
235
- ->setPageSize(1)
236
- ->setOrder('post_modified', 'desc')
237
- ->load();
238
-
239
- if (count($posts) > 0) {
240
- $post = $posts->getFirstItem();
241
-
242
- Mage::unregister('wordpress_post');
243
- Mage::register('wordpress_post', $post);
244
-
245
- return $post;
246
- }
247
- }
248
-
249
- return $post;
250
- }
251
-
252
- $isPreview = $this->_isPreview();
253
-
254
- if ($postId = $this->getRequest()->getParam('p')) {
255
- $post = Mage::getModel('wordpress/post')->load($postId);
256
-
257
- if ($post->getId()) {
258
- if ($isPreview || $post->getTypeInstance() && $post->getTypeInstance()->useGuidLinks()) {
259
- Mage::register('wordpress_post', $post);
260
-
261
- return $post;
262
- }
263
-
264
- if ($post->canBeViewed()) {
265
- $this->_redirectUrl($post->getUrl());
266
- $this->getResponse()->sendHeaders();
267
- exit;
268
- }
269
- }
270
- }
271
- else if ($postId = $this->getRequest()->getParam('id')) {
272
- $post = Mage::getModel('wordpress/post')
273
- ->setPostType($this->getRequest()->getParam('post_type', '*'))
274
- ->load($postId);
275
-
276
- if ($post->getId() && ($post->canBeViewed() || $isPreview)) {
277
- Mage::register('wordpress_post', $post);
278
-
279
- return $post;
280
- }
281
- }
282
- else if (($pageId = $this->getRequest()->getParam('page_id')) && $isPreview) {
283
- $post = Mage::getModel('wordpress/post')
284
- ->setPostType('page')
285
- ->load($pageId);
286
-
287
- if ($post->getId()) {
288
- Mage::register('wordpress_post', $post);
289
-
290
- return $post;
291
- }
292
- }
293
-
294
- return false;
295
- }
296
-
297
- /**
298
- * Display the comments feed
299
- *
300
- * @return void
301
- */
302
- public function feedAction()
303
- {
304
- return $this->commentsFeedAction();
305
- }
306
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/SearchController.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_SearchController extends Fishpig_Wordpress_Controller_Abstract
10
- {
11
- /**
12
- * If Integrated search is installed, redirect if enabled
13
- *
14
- * @return $this
15
- */
16
- public function preDispatch()
17
- {
18
- if ($this->getRequest()->getParam('redirect_broken_url')) {
19
- $this->getResponse()
20
- ->setRedirect(Mage::helper('wordpress')->getUrl('search/' . $this->getRequest()->getParam('s') . '/'))
21
- ->sendResponse();
22
-
23
- $this->getRequest()->setDispatched( true );
24
- }
25
- else if (Mage::helper('wordpress')->isAddonInstalled('IntegratedSearch') && Mage::getStoreConfigFlag('wordpress/integratedsearch/blog')) {
26
- $this->_forceForwardViaException('index', 'result', 'catalogsearch', array(
27
- 'q' => $this->getRequest()->getParam('s'),
28
- ));
29
- }
30
-
31
- return parent::preDispatch();
32
- }
33
-
34
- /**
35
- *
36
- *
37
- */
38
- public function indexAction()
39
- {
40
- $this->_addCustomLayoutHandles(array(
41
- 'wordpress_post_list',
42
- 'wordpress_search_index',
43
- ));
44
-
45
- $this->_initLayout();
46
-
47
- $helper = $this->getRouterHelper();
48
-
49
- $searchTerm = Mage::helper('wordpress')->escapeHtml($helper->getSearchTerm());
50
-
51
- $this->_title($this->__("Search results for: '%s'", $searchTerm));
52
-
53
- $this->addCrumb('search_label', array('link' => '', 'label' => $this->__('Search')));
54
- $this->addCrumb('search_value', array('link' => '', 'label' => $searchTerm));
55
-
56
- $this->renderLayout();
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers app/code/community/Fishpig/Wordpress/controllers/TermController.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- class Fishpig_Wordpress_TermController extends Fishpig_Wordpress_Controller_Abstract
10
- {
11
- /**
12
- * Blocks used to generate RSS feed items
13
- *
14
- * @var string
15
- */
16
- protected $_feedBlock = 'term_view';
17
-
18
- /**
19
- * Used to do things en-masse
20
- * eg. include canonical URL
21
- *
22
- * @return false|Fishpig_Wordpress_Model_Term
23
- */
24
- public function getEntityObject()
25
- {
26
- return $this->_initTerm();
27
- }
28
-
29
- /**
30
- * Ensure that the term loaded isn't a default term
31
- * Default terms (post_category, tag etc) have their own controller
32
- *
33
- * @return $this|false
34
- */
35
- public function preDispatch()
36
- {
37
- parent::preDispatch();
38
-
39
- $term = $this->_initTerm();
40
-
41
- return $this;
42
- }
43
-
44
- /**
45
- * Display the term page and list associated posts
46
- *
47
- */
48
- public function viewAction()
49
- {
50
- $term = Mage::registry('wordpress_term');
51
-
52
- $this->_addCustomLayoutHandles(array(
53
- 'wordpress_post_list',
54
- 'wordpress_term_view',
55
- 'wordpress_post_' . $term->getTaxonomyType() . '_view', // Legacy
56
- 'wordpress_' . $term->getTaxonomyType() . '_view',
57
- 'wordpress_' . $term->getTaxonomyType() . '_' . $term->getId(), // Legacy
58
- 'wordpress_' . $term->getTaxonomyType() . '_view_' . $term->getId(),
59
- ));
60
-
61
- $this->_initLayout();
62
-
63
- $tree = array($term);
64
- $buffer = $term;
65
-
66
- while($buffer = $buffer->getParentTerm()) {
67
- array_unshift($tree, $buffer);
68
- }
69
-
70
- while($branch = array_shift($tree)) {
71
- $this->addCrumb('term_' . $branch->getId(), array(
72
- 'link' => ($tree ? $branch->getUrl() : null),
73
- 'label' => $branch->getName())
74
- );
75
-
76
- $this->_title($branch->getName());
77
- }
78
-
79
- $this->renderLayout();
80
- }
81
-
82
-
83
- /**
84
- * Initialise the term model
85
- *
86
- * @return false|Fishpig_Wordpress_Model_Term
87
- */
88
- protected function _initTerm()
89
- {
90
- if (($term = Mage::registry('wordpress_term')) !== null) {
91
- return $term;
92
- }
93
-
94
- $term = Mage::getModel('wordpress/term')
95
- ->setTaxonomy($this->getRequest()->getParam('taxonomy'))
96
- ->load($this->getRequest()->getParam('id'));
97
-
98
- if (!$term->getId()) {
99
- return false;
100
- }
101
-
102
- Mage::register('wordpress_term', $term);
103
-
104
- return $term;
105
- }
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/controllers/PostController.php CHANGED
@@ -268,17 +268,6 @@ class Fishpig_Wordpress_PostController extends Fishpig_Wordpress_Controller_Abst
268
  }
269
  }
270
  }
271
- else if ($postId = $this->getRequest()->getParam('id')) {
272
- $post = Mage::getModel('wordpress/post')
273
- ->setPostType($this->getRequest()->getParam('post_type', '*'))
274
- ->load($postId);
275
-
276
- if ($post->getId() && ($post->canBeViewed() || $isPreview)) {
277
- Mage::register('wordpress_post', $post);
278
-
279
- return $post;
280
- }
281
- }
282
  else if (($pageId = $this->getRequest()->getParam('page_id')) && $isPreview) {
283
  $post = Mage::getModel('wordpress/post')
284
  ->setPostType('page')
@@ -290,6 +279,17 @@ class Fishpig_Wordpress_PostController extends Fishpig_Wordpress_Controller_Abst
290
  return $post;
291
  }
292
  }
 
 
 
 
 
 
 
 
 
 
 
293
 
294
  return false;
295
  }
268
  }
269
  }
270
  }
 
 
 
 
 
 
 
 
 
 
 
271
  else if (($pageId = $this->getRequest()->getParam('page_id')) && $isPreview) {
272
  $post = Mage::getModel('wordpress/post')
273
  ->setPostType('page')
279
  return $post;
280
  }
281
  }
282
+ else if ($postId = $this->getRequest()->getParam('id')) {
283
+ $post = Mage::getModel('wordpress/post')
284
+ ->setPostType($this->getRequest()->getParam('post_type', '*'))
285
+ ->load($postId);
286
+
287
+ if ($post->getId() && ($post->canBeViewed() || $isPreview)) {
288
+ Mage::register('wordpress_post', $post);
289
+
290
+ return $post;
291
+ }
292
+ }
293
 
294
  return false;
295
  }
app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/adminhtml.xml DELETED
@@ -1,56 +0,0 @@
1
- <?xml version="1.0"?>
2
- <adminhtml>
3
- <menu>
4
- <wordpress module="wordpress" translate="title">
5
- <title>WordPress</title>
6
- <sort_order>89</sort_order>
7
- <action>adminhtml/system_config/edit/section/wordpress</action>
8
- <children>
9
- <login>
10
- <title><![CDATA[WordPress &raquo;]]></title>
11
- <sort_order>6</sort_order>
12
- <action>adminhtml/wordpress/login</action>
13
- </login>
14
- <configuration>
15
- <title>Settings</title>
16
- <sort_order>100</sort_order>
17
- <action>adminhtml/system_config/edit/section/wordpress</action>
18
- </configuration>
19
- </children>
20
- </wordpress>
21
- </menu>
22
- <acl>
23
- <resources>
24
- <admin>
25
- <children>
26
- <system>
27
- <children>
28
- <config>
29
- <children>
30
- <wordpress translate="title" module="wordpress">
31
- <title>Magento WordPress Integration</title>
32
- <sort_order>800</sort_order>
33
- </wordpress>
34
- </children>
35
- </config>
36
- </children>
37
- </system>
38
- <wordpress translate="title" module="wordpress">
39
- <title>WordPress</title>
40
- <sort_order>800</sort_order>
41
- <children>
42
- <login translate="title">
43
- <title>WordPress Auto-Login</title>
44
- <sort_order>800</sort_order>
45
- </login>
46
- <configuration>
47
- <title>Settings</title>
48
- <sort_order>801</sort_order>
49
- </configuration>
50
- </children>
51
- </wordpress>
52
- </children>
53
- </admin>
54
- </resources>
55
- </acl>
56
- </adminhtml>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/config.xml DELETED
@@ -1,314 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Fishpig_Wordpress>
5
- <version>4.2.1.0</version>
6
- </Fishpig_Wordpress>
7
- </modules>
8
- <global>
9
- <events>
10
- <controller_front_init_before>
11
- <observers>
12
- <wordpress>
13
- <type>singleton</type>
14
- <class>Fishpig_Wordpress_Controller_Router</class>
15
- <method>initControllerBeforeObserver</method>
16
- </wordpress>
17
- </observers>
18
- </controller_front_init_before>
19
- <controller_front_init_routers>
20
- <observers>
21
- <wordpress>
22
- <type>singleton</type>
23
- <class>Fishpig_Wordpress_Controller_Router</class>
24
- <method>initControllerObserver</method>
25
- </wordpress>
26
- </observers>
27
- </controller_front_init_routers>
28
- <sitemap_sitemap_save_before>
29
- <observers>
30
- <wordpress>
31
- <type>singleton</type>
32
- <class>wordpress/observer</class>
33
- <method>injectXmlSitemapLinksObserver</method>
34
- </wordpress>
35
- </observers>
36
- </sitemap_sitemap_save_before>
37
- </events>
38
- <blocks>
39
- <wordpress>
40
- <class>Fishpig_Wordpress_Block</class>
41
- </wordpress>
42
- </blocks>
43
- <models>
44
- <wordpress>
45
- <class>Fishpig_Wordpress_Model</class>
46
- <resourceModel>wordpress_resource</resourceModel>
47
- </wordpress>
48
- <wordpress_resource>
49
- <class>Fishpig_Wordpress_Model_Resource</class>
50
- <entities>
51
- <!-- Magento Tables -->
52
- <association><table>wordpress_association</table></association>
53
- <association_type><table>wordpress_association_type</table></association_type>
54
- <!-- WordPress tables -->
55
- <post><table>posts</table></post>
56
- <post_meta><table>postmeta</table></post_meta>
57
- <post_comment><table>comments</table></post_comment>
58
- <post_comment_meta><table>commentmeta</table></post_comment_meta>
59
- <post_category><table>terms</table></post_category>
60
- <post_tag><table>terms</table></post_tag>
61
- <term><table>terms</table></term>
62
- <term_relationship><table>term_relationships</table></term_relationship>
63
- <term_taxonomy><table>term_taxonomy</table></term_taxonomy>
64
- <option><table>options</table></option>
65
- <menu><table>terms</table></menu>
66
- <menu_item><table>posts</table></menu_item>
67
- <user_meta><table>usermeta</table></user_meta>
68
- <user><table>users</table></user>
69
- <image><table>posts</table></image>
70
- </entities>
71
- </wordpress_resource>
72
- <sitemap>
73
- <rewrite>
74
- <sitemap>Fishpig_Wordpress_Model_Sitemap_Sitemap</sitemap>
75
- </rewrite>
76
- </sitemap>
77
- </models>
78
- <helpers>
79
- <wordpress>
80
- <class>Fishpig_Wordpress_Helper</class>
81
- </wordpress>
82
- </helpers>
83
- <resources>
84
- <wordpress_read>
85
- <connection>
86
- <use>wordpress</use>
87
- </connection>
88
- </wordpress_read>
89
- <wordpress_write>
90
- <connection>
91
- <use>wordpress</use>
92
- </connection>
93
- </wordpress_write>
94
- <wordpress_setup>
95
- <setup>
96
- <module>Fishpig_Wordpress</module>
97
- <class>Fishpig_Wordpress_Model_Resource_Setup</class>
98
- </setup>
99
- </wordpress_setup>
100
- </resources>
101
- </global>
102
- <frontend>
103
- <events>
104
- <page_block_html_topmenu_gethtml_before>
105
- <observers>
106
- <wordpress>
107
- <type>singleton</type>
108
- <class>wordpress/observer</class>
109
- <method>injectTopmenuLinksObserver</method>
110
- </wordpress>
111
- </observers>
112
- </page_block_html_topmenu_gethtml_before>
113
- <controller_front_send_response_before>
114
- <observers>
115
- <wordpress>
116
- <type>singleton</type>
117
- <class>wordpress/observer</class>
118
- <method>injectWordPressContentObserver</method>
119
- </wordpress>
120
- </observers>
121
- </controller_front_send_response_before>
122
- </events>
123
- <translate>
124
- <modules>
125
- <Fishpig_Wordpress>
126
- <files>
127
- <default>Fishpig_Wordpress.csv</default>
128
- </files>
129
- </Fishpig_Wordpress>
130
- </modules>
131
- </translate>
132
- <layout>
133
- <updates>
134
- <wordpress>
135
- <file>wordpress.xml</file>
136
- </wordpress>
137
- <wordpress_local>
138
- <file>wordpresslocal.xml</file>
139
- </wordpress_local>
140
- </updates>
141
- </layout>
142
- <routers>
143
- <wordpress>
144
- <use>standard</use>
145
- <args>
146
- <module>Fishpig_Wordpress</module>
147
- <frontName>wordpress</frontName>
148
- </args>
149
- </wordpress>
150
- </routers>
151
- </frontend>
152
- <adminhtml>
153
- <translate>
154
- <modules>
155
- <Fishpig_Wordpress>
156
- <files>
157
- <default>Fishpig_Wordpress.csv</default>
158
- </files>
159
- </Fishpig_Wordpress>
160
- </modules>
161
- </translate>
162
- <layout>
163
- <updates>
164
- <wordpress>
165
- <file>wordpress.xml</file>
166
- </wordpress>
167
- </updates>
168
- </layout>
169
- <events>
170
- <catalog_category_save_after>
171
- <observers>
172
- <wp_associations>
173
- <type>singleton</type>
174
- <class>wordpress/observer</class>
175
- <method>saveAssociationsObserver</method>
176
- </wp_associations>
177
- </observers>
178
- </catalog_category_save_after>
179
- <catalog_product_save_after>
180
- <observers>
181
- <wp_associations>
182
- <type>singleton</type>
183
- <class>wordpress/observer</class>
184
- <method>saveAssociationsObserver</method>
185
- </wp_associations>
186
- </observers>
187
- </catalog_product_save_after>
188
- <cms_page_save_after>
189
- <observers>
190
- <wp_associations>
191
- <type>singleton</type>
192
- <class>wordpress/observer</class>
193
- <method>saveAssociationsObserver</method>
194
- </wp_associations>
195
- </observers>
196
- </cms_page_save_after>
197
- <adminhtml_block_system_config_init_tab_sections_before>
198
- <observers>
199
- <wp_associations>
200
- <type>singleton</type>
201
- <class>wordpress/observer</class>
202
- <method>initWordpressConfigObserver</method>
203
- </wp_associations>
204
- </observers>
205
- </adminhtml_block_system_config_init_tab_sections_before>
206
- </events>
207
- </adminhtml>
208
- <admin>
209
- <routers>
210
- <adminhtml>
211
- <args>
212
- <modules>
213
- <wordpress before="Mage_Adminhtml">Fishpig_Wordpress_Adminhtml</wordpress>
214
- </modules>
215
- </args>
216
- </adminhtml>
217
- </routers>
218
- </admin>
219
- <default>
220
- <wordpress>
221
- <module>
222
- <enabled>1</enabled>
223
- <check_for_updates>1</check_for_updates>
224
- </module>
225
- <database>
226
- <is_shared>1</is_shared>
227
- <charset>utf8</charset>
228
- <table_prefix>wp_</table_prefix>
229
- </database>
230
- <integration>
231
- <full>1</full>
232
- <route>blog</route>
233
- <path>wp</path>
234
- <remove_trailing_slash>1</remove_trailing_slash>
235
- </integration>
236
- <toplink>
237
- <enabled>1</enabled>
238
- <label>Blog</label>
239
- <position>100</position>
240
- </toplink>
241
- <misc>
242
- <include_css>1</include_css>
243
- <autop>1</autop>
244
- </misc>
245
- </wordpress>
246
- <web>
247
- <routers>
248
- <wordpress_addon>
249
- <area>frontend</area>
250
- <class>Fishpig_Wordpress_Controller_Router_Addon</class>
251
- </wordpress_addon>
252
- </routers>
253
- </web>
254
- </default>
255
- <wordpress>
256
- <database>
257
- <before_connect>
258
- <tables>
259
- <post><table>posts</table></post>
260
- <post_meta><table>postmeta</table></post_meta>
261
- <page_meta><table>postmeta</table></page_meta>
262
- <post_comment><table>comments</table></post_comment>
263
- <post_comment_meta><table>commentmeta</table></post_comment_meta>
264
- <post_category><table>terms</table></post_category>
265
- <post_tag><table>terms</table></post_tag>
266
- <option><table>options</table></option>
267
- <term><table>terms</table></term>
268
- <term_relationship><table>term_relationships</table></term_relationship>
269
- <term_taxonomy><table>term_taxonomy</table></term_taxonomy>
270
- <menu><table>terms</table></menu>
271
- <menu_item><table>posts</table></menu_item>
272
- <user><table>users</table></user>
273
- <user_meta><table>usermeta</table></user_meta>
274
- <image><table>posts</table></image>
275
- </tables>
276
- </before_connect>
277
- </database>
278
- <sidebar>
279
- <widgets>
280
- <search><block>sidebar_widget_search</block></search>
281
- <pages><block>sidebar_widget_pages</block><template>wordpress/sidebar/widget/pages.phtml</template></pages>
282
- <recent-posts><block>sidebar_widget_posts</block><template>wordpress/sidebar/widget/posts.phtml</template></recent-posts>
283
- <recent-comments><block>sidebar_widget_comments</block><template>wordpress/sidebar/widget/comments.phtml</template></recent-comments>
284
- <archives><block>sidebar_widget_archives</block><template>wordpress/sidebar/widget/archives.phtml</template></archives>
285
- <categories><block>sidebar_widget_categories</block><template>wordpress/sidebar/widget/categories.phtml</template></categories>
286
- <tag_cloud><block>sidebar_widget_tagcloud</block><template>wordpress/sidebar/widget/tagcloud.phtml</template></tag_cloud>
287
- <text><block>sidebar_widget_text</block><template>wordpress/sidebar/widget/text.phtml</template></text>
288
- <meta><block>sidebar_widget_meta</block><template>wordpress/sidebar/widget/meta.phtml</template></meta>
289
- <rss><block>sidebar_widget_rss</block><template>wordpress/sidebar/widget/rss.phtml</template></rss>
290
- <nav_menu><block>sidebar_widget_menu</block><template>wordpress/sidebar/widget/menu.phtml</template></nav_menu>
291
- <calendar><block>sidebar_widget_calendar</block></calendar>
292
- <categoryposts><block>sidebar_widget_posts</block><template>wordpress/sidebar/widget/categoryposts.phtml</template></categoryposts>
293
- <widget_sp_image><block>sidebar_widget_image</block></widget_sp_image>
294
- <lc_taxonomy><block>sidebar_widget_taxonomy</block><template>wordpress/sidebar/widget/taxonomy.phtml</template></lc_taxonomy>
295
- </widgets>
296
- </sidebar>
297
- <core>
298
- <globals>
299
- <post />
300
- </globals>
301
- </core>
302
- </wordpress>
303
- <fishpig>
304
- <injection>
305
- <Fishpig_Magento_Block_Adminhtml_Extend>
306
- <Fishpig_Wordpress>
307
- <Block_Adminhtml_Extend>
308
- <ignore />
309
- </Block_Adminhtml_Extend>
310
- </Fishpig_Wordpress>
311
- </Fishpig_Magento_Block_Adminhtml_Extend>
312
- </injection>
313
- </fishpig>
314
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/fishpig.xml DELETED
@@ -1,2 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config><fishpig><extensions><Fishpig_Wordpress_Addon_ContactForm7><new_version>1.6.0.18</new_version><id>contact-form-7</id><name>Contact Form 7</name><url>http://fishpig.co.uk/magento/wordpress-integration/contact-form-7/</url></Fishpig_Wordpress_Addon_ContactForm7><Fishpig_Wordpress_Addon_GravityForms><new_version>1.1.0.18</new_version><id>gravity-forms</id><name>Gravity Forms</name><url>http://fishpig.co.uk/magento/wordpress-integration/gravity-forms/</url></Fishpig_Wordpress_Addon_GravityForms><Fishpig_Wordpress_Addon_RevolutionSlider><new_version>1.1.0.17</new_version><id>revolutionslider</id><name>Revolution Slider</name><url>http://fishpig.co.uk/magento/wordpress-integration/revolution-slider/</url></Fishpig_Wordpress_Addon_RevolutionSlider><Fishpig_Wordpress_Addon_TOC><new_version>1.0.0.3</new_version><id>toc</id><name>Table of Contents Plus</name><url>http://fishpig.co.uk/magento/wordpress-integration/</url></Fishpig_Wordpress_Addon_TOC></extensions></fishpig></config>
 
 
app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/system.xml DELETED
@@ -1,367 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <fishpig translate="label" module="wordpress">
5
- <label>FishPig</label>
6
- <sort_order>200</sort_order>
7
- </fishpig>
8
- </tabs>
9
- <sections>
10
- <wordpress translate="label" module="wordpress">
11
- <label>WordPress Integration</label>
12
- <tab>fishpig</tab>
13
- <sort_order>999</sort_order>
14
- <show_in_default>1</show_in_default>
15
- <show_in_store>1</show_in_store>
16
- <groups>
17
- <module>
18
- <label>WordPress Integration</label>
19
- <sort_order>1</sort_order>
20
- <show_in_default>1</show_in_default>
21
- <show_in_store>1</show_in_store>
22
- <expanded>0</expanded>
23
- <fields>
24
- <enabled>
25
- <label>Enabled</label>
26
- <frontend_type>select</frontend_type>
27
- <source_model>adminhtml/system_config_source_yesno</source_model>
28
- <sort_order>1</sort_order>
29
- <show_in_default>1</show_in_default>
30
- <show_in_store>1</show_in_store>
31
- </enabled>
32
- <check_for_updates>
33
- <label>Check for Updates</label>
34
- <frontend_type>select</frontend_type>
35
- <source_model>adminhtml/system_config_source_yesno</source_model>
36
- <sort_order>6</sort_order>
37
- <show_in_default>1</show_in_default>
38
- </check_for_updates>
39
- </fields>
40
- </module>
41
- <database>
42
- <label>Database</label>
43
- <sort_order>6</sort_order>
44
- <show_in_default>1</show_in_default>
45
- <show_in_store>1</show_in_store>
46
- <expanded>0</expanded>
47
- <fields>
48
- <is_shared>
49
- <label>Do Magento and WordPress share a database?</label>
50
- <frontend_type>select</frontend_type>
51
- <source_model>adminhtml/system_config_source_yesno</source_model>
52
- <sort_order>1</sort_order>
53
- <show_in_default>1</show_in_default>
54
- <show_in_store>1</show_in_store>
55
- </is_shared>
56
- <host>
57
- <label>Host</label>
58
- <frontend_type>text</frontend_type>
59
- <sort_order>6</sort_order>
60
- <show_in_default>1</show_in_default>
61
- <show_in_store>1</show_in_store>
62
- <validate>required-entry</validate>
63
- <depends><is_shared>0</is_shared></depends>
64
- </host>
65
- <username>
66
- <label>Username</label>
67
- <frontend_type>text</frontend_type>
68
- <backend_model>wordpress/system_config_backend_encrypted</backend_model>
69
- <sort_order>11</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_store>1</show_in_store>
72
- <validate>required-entry</validate>
73
- <depends><is_shared>0</is_shared></depends>
74
- </username>
75
- <password>
76
- <label>Password</label>
77
- <frontend_type>password</frontend_type>
78
- <backend_model>wordpress/system_config_backend_encrypted</backend_model>
79
- <sort_order>16</sort_order>
80
- <show_in_default>1</show_in_default>
81
- <show_in_store>1</show_in_store>
82
- <validate>required-entry</validate>
83
- <depends><is_shared>0</is_shared></depends>
84
- </password>
85
- <dbname>
86
- <label>Name</label>
87
- <frontend_type>text</frontend_type>
88
- <backend_model>wordpress/system_config_backend_encrypted</backend_model>
89
- <sort_order>21</sort_order>
90
- <show_in_default>1</show_in_default>
91
- <show_in_store>1</show_in_store>
92
- <validate>required-entry</validate>
93
- <depends><is_shared>0</is_shared></depends>
94
- </dbname>
95
- <charset>
96
- <label>Charset</label>
97
- <frontend_type>text</frontend_type>
98
- <sort_order>26</sort_order>
99
- <show_in_default>1</show_in_default>
100
- <show_in_store>1</show_in_store>
101
- <depends><is_shared>0</is_shared></depends>
102
- </charset>
103
- <table_prefix>
104
- <label>Table Prefix</label>
105
- <frontend_type>text</frontend_type>
106
- <sort_order>31</sort_order>
107
- <show_in_default>1</show_in_default>
108
- <show_in_store>1</show_in_store>
109
- </table_prefix>
110
- </fields>
111
- </database>
112
- <integration>
113
- <label>Integration</label>
114
- <sort_order>16</sort_order>
115
- <show_in_default>1</show_in_default>
116
- <show_in_store>1</show_in_store>
117
- <expanded>0</expanded>
118
- <fields>
119
- <full>
120
- <label>Integrate Theme</label>
121
- <tooltip>If Yes, your blog will use your Magento theme</tooltip>
122
- <frontend_type>select</frontend_type>
123
- <source_model>adminhtml/system_config_source_yesno</source_model>
124
- <sort_order>1</sort_order>
125
- <show_in_default>1</show_in_default>
126
- <show_in_store>1</show_in_store>
127
- </full>
128
- <route>
129
- <label>Home URL</label>
130
- <frontend_type>text</frontend_type>
131
- <frontend_model>wordpress/adminhtml_system_config_form_field_route</frontend_model>
132
- <validate>required-entry validate-blog-route</validate>
133
- <sort_order>11</sort_order>
134
- <show_in_default>1</show_in_default>
135
-
136
- <show_in_store>1</show_in_store>
137
- <depends><full>1</full></depends>
138
- </route>
139
- <path>
140
- <label>Path</label>
141
- <comment>Enter the path to your WordPress installation.</comment>
142
- <tooltip>If WordPress is installed in a sub-directory, enter the name without any slashes.</tooltip>
143
- <validate>required-entry validate-blog-path</validate>
144
- <frontend_type>text</frontend_type>
145
- <sort_order>21</sort_order>
146
- <show_in_default>1</show_in_default>
147
- <show_in_store>1</show_in_store>
148
- </path>
149
- <force_single_store>
150
- <label>Single Store</label>
151
- <tooltip>Select Yes if you have multiple stores that share a single blog</tooltip>
152
- <sort_order>100</sort_order>
153
- <frontend_type>select</frontend_type>
154
- <source_model>adminhtml/system_config_source_yesno</source_model>
155
- <show_in_default>1</show_in_default>
156
- <show_in_store>1</show_in_store>
157
- </force_single_store>
158
- </fields>
159
- </integration>
160
- <license>
161
- <label>License</label>
162
- <comment>You must have a valid license for each add-on extension listed below. Licenses are automatically validated and logged by FishPig. It is illegal to use an extension listed below with an invalid license.</comment>
163
- <sort_order>17</sort_order>
164
- <show_in_default>1</show_in_default>
165
- <expanded>1</expanded>
166
- <fields></fields>
167
- </license>
168
- <autologin>
169
- <label>Auto-Login</label>
170
- <sort_order>18</sort_order>
171
- <show_in_default>1</show_in_default>
172
- <expanded>0</expanded>
173
- <comment><![CDATA[<p>For help setting up the Auto-Login features, see <a href="http://fishpig.co.uk/magento/wordpress-integration/auto-login/" target="_blank">this article</a>.</p>]]></comment>
174
- <fields>
175
- <username>
176
- <label>Username</label>
177
- <sort_order>1</sort_order>
178
- <frontend_type>text</frontend_type>
179
- <frontend_model>wordpress/adminhtml_frontend_autologin</frontend_model>
180
- <backend_model>wordpress/system_config_backend_autologin</backend_model>
181
- <show_in_default>1</show_in_default>
182
- <comment>WordPress Admin username</comment>
183
- </username>
184
- <password>
185
- <label>Password</label>
186
- <sort_order>6</sort_order>
187
- <frontend_type>password</frontend_type>
188
- <frontend_model>wordpress/adminhtml_frontend_autologin</frontend_model>
189
- <backend_model>wordpress/system_config_backend_autologin</backend_model>
190
- <show_in_default>1</show_in_default>
191
- <comment>WordPress Admin password</comment>
192
- </password>
193
- </fields>
194
- </autologin>
195
- <extend>
196
- <label>Add-Ons</label>
197
- <sort_order>20</sort_order>
198
- <show_in_default>1</show_in_default>
199
- <show_in_store>1</show_in_store>
200
- <fields />
201
- </extend>
202
- <menu>
203
- <label>Menu</label>
204
- <comment>Append a WordPress custom menu onto your Magento Topmenu</comment>
205
- <sort_order>26</sort_order>
206
- <show_in_default>1</show_in_default>
207
- <show_in_store>1</show_in_store>
208
- <expanded>0</expanded>
209
- <fields>
210
- <enabled>
211
- <label>Enabled</label>
212
- <sort_order>1</sort_order>
213
- <frontend_type>select</frontend_type>
214
- <source_model>adminhtml/system_config_source_yesno</source_model>
215
- <show_in_default>1</show_in_default>
216
- <show_in_store>1</show_in_store>
217
- </enabled>
218
- <id>
219
- <label>Menu</label>
220
- <comment>You can create new menu's in the WordPress Admin</comment>
221
- <sort_order>8</sort_order>
222
- <frontend_type>select</frontend_type>
223
- <source_model>wordpress/system_config_source_menu</source_model>
224
- <show_in_default>1</show_in_default>
225
- <show_in_store>1</show_in_store>
226
- <depends><enabled>1</enabled></depends>
227
- </id>
228
- </fields>
229
- </menu>
230
- <toplink>
231
- <label>Top Link</label>
232
- <sort_order>31</sort_order>
233
- <show_in_default>1</show_in_default>
234
- <show_in_store>1</show_in_store>
235
- <expanded>0</expanded>
236
- <fields>
237
- <enabled>
238
- <label>Enabled</label>
239
- <sort_order>51</sort_order>
240
- <frontend_type>select</frontend_type>
241
- <source_model>adminhtml/system_config_source_yesno</source_model>
242
- <show_in_default>1</show_in_default>
243
- <show_in_store>1</show_in_store>
244
- </enabled>
245
- <label>
246
- <label>Label</label>
247
- <comment>This is also used for the blog Breadcrumb label</comment>
248
- <sort_order>52</sort_order>
249
- <frontend_type>text</frontend_type>
250
- <show_in_default>1</show_in_default>
251
- <show_in_store>1</show_in_store>
252
- <depends><enabled>1</enabled></depends>
253
- </label>
254
- <position>
255
- <label>Position</label>
256
- <frontend_type>text</frontend_type>
257
- <sort_order>53</sort_order>
258
- <show_in_default>1</show_in_default>
259
- <show_in_store>1</show_in_store>
260
- <depends><enabled>1</enabled></depends>
261
- </position>
262
- </fields>
263
- </toplink>
264
- <misc>
265
- <label>Misc</label>
266
- <sort_order>500</sort_order>
267
- <show_in_default>1</show_in_default>
268
- <show_in_store>1</show_in_store>
269
- <fields>
270
- <include_css>
271
- <label>Stylesheet</label>
272
- <comment>If enabled, a simple WordPress CSS file will be included on the blog only.</comment>
273
- <sort_order>1</sort_order>
274
- <frontend_type>select</frontend_type>
275
- <source_model>adminhtml/system_config_source_yesno</source_model>
276
- <show_in_default>1</show_in_default>
277
- <show_in_store>1</show_in_store>
278
- </include_css>
279
- <sidebar_left_empty>
280
- <label>Remove Magento Blocks from Left Sidebar</label>
281
- <sort_order>31</sort_order>
282
- <frontend_type>select</frontend_type>
283
- <source_model>adminhtml/system_config_source_yesno</source_model>
284
- <show_in_default>1</show_in_default>
285
- <show_in_store>1</show_in_store>
286
- </sidebar_left_empty>
287
- <sidebar_right_empty>
288
- <label>Remove Magento Blocks from Right Sidebar</label>
289
- <sort_order>32</sort_order>
290
- <frontend_type>select</frontend_type>
291
- <source_model>adminhtml/system_config_source_yesno</source_model>
292
- <show_in_default>1</show_in_default>
293
- <show_in_store>1</show_in_store>
294
- </sidebar_right_empty>
295
- <autop>
296
- <label>Automatically add paragraphs</label>
297
- <sort_order>41</sort_order>
298
- <frontend_type>select</frontend_type>
299
- <source_model>adminhtml/system_config_source_yesno</source_model>
300
- <show_in_default>1</show_in_default>
301
- <show_in_store>1</show_in_store>
302
- </autop>
303
- <include_jquery>
304
- <label>Include jQuery</label>
305
- <sort_order>101</sort_order>
306
- <frontend_type>select</frontend_type>
307
- <source_model>adminhtml/system_config_source_yesno</source_model>
308
- <show_in_default>1</show_in_default>
309
- <show_in_store>1</show_in_store>
310
- </include_jquery>
311
- <include_underscore>
312
- <label>Include underscore.js</label>
313
- <sort_order>102</sort_order>
314
- <frontend_type>select</frontend_type>
315
- <source_model>adminhtml/system_config_source_yesno</source_model>
316
- <show_in_default>1</show_in_default>
317
- <show_in_store>1</show_in_store>
318
- </include_underscore>
319
- </fields>
320
- </misc>
321
- <social>
322
- <label>Social Media Buttons</label>
323
- <sort_order>500</sort_order>
324
- <show_in_default>1</show_in_default>
325
- <show_in_store>1</show_in_store>
326
- <fields>
327
- <enabled>
328
- <label>Enabled</label>
329
- <sort_order>1</sort_order>
330
- <frontend_type>select</frontend_type>
331
- <source_model>adminhtml/system_config_source_yesno</source_model>
332
- <show_in_default>1</show_in_default>
333
- <show_in_store>1</show_in_store>
334
- </enabled>
335
- <service>
336
- <label>Service</label>
337
- <sort_order>31</sort_order>
338
- <frontend_type>select</frontend_type>
339
- <source_model>wordpress/system_config_source_social_media_service</source_model>
340
- <show_in_default>1</show_in_default>
341
- <show_in_store>1</show_in_store>
342
- <depends><enabled>1</enabled></depends>
343
- </service>
344
- <head_html>
345
- <label>Head Code</label>
346
- <comment>Enter code added to head of page</comment>
347
- <sort_order>32</sort_order>
348
- <frontend_type>editor</frontend_type>
349
- <show_in_default>1</show_in_default>
350
- <show_in_store>1</show_in_store>
351
- <depends><enabled>1</enabled></depends>
352
- </head_html>
353
- <buttons_html>
354
- <label>Buttons Code</label>
355
- <comment>Enter the buttons code</comment>
356
- <sort_order>33</sort_order>
357
- <frontend_type>editor</frontend_type>
358
- <show_in_default>1</show_in_default>
359
- <show_in_store>1</show_in_store>
360
- <depends><enabled>1</enabled></depends>
361
- </buttons_html>
362
- </fields>
363
- </social>
364
- </groups>
365
- </wordpress>
366
- </sections>
367
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc app/code/community/Fishpig/Wordpress/etc/widget.xml DELETED
@@ -1,40 +0,0 @@
1
- <?xml version="1.0"?>
2
- <widgets>
3
- <wordpress_posts type="wordpress/sidebar_widget_posts">
4
- <name>WordPress &gt; Recent Posts</name>
5
- <description type="desc">Add a list of your most recent blog posts.</description>
6
- <parameters>
7
- <title translate="label description">
8
- <visible>1</visible>
9
- <label>Title</label>
10
- <description>Enter the block title</description>
11
- <value>Recent Posts</value>
12
- <type>text</type>
13
- </title>
14
- <number translate="label description">
15
- <visible>1</visible>
16
- <label>Number of Posts</label>
17
- <value>5</value>
18
- <type>text</type>
19
- </number>
20
- <category_id translate="label description">
21
- <visible>1</visible>
22
- <label>Category ID</label>
23
- <description>If set, only posts from this category will be displayed. Leave empty to display from all categories.</description>
24
- <type>text</type>
25
- </category_id>
26
- <author_id translate="label description">
27
- <visible>1</visible>
28
- <label>Author ID</label>
29
- <description>If set, only posts from this author will be displayed. Leave empty to display from all authors.</description>
30
- <type>text</type>
31
- </author_id>
32
- <template translate="label">
33
- <label>Template</label>
34
- <visible>1</visible>
35
- <type>text</type>
36
- <value>wordpress/sidebar/widget/posts.phtml</value>
37
- </template>
38
- </parameters>
39
- </wordpress_posts>
40
- </widgets>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Fishpig_Wordpress>
5
- <version>4.2.1.0</version>
6
  </Fishpig_Wordpress>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Fishpig_Wordpress>
5
+ <version>4.2.1.1</version>
6
  </Fishpig_Wordpress>
7
  </modules>
8
  <global>
app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-install-0.1.0.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- $this->startSetup();
10
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-2.5.9.0-2.5.9.1.php DELETED
@@ -1,117 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- $this->startSetup();
10
-
11
- try {
12
- $table = $this->getTable('core/config_data');
13
-
14
- $updates = array(
15
- array(
16
- 'cond' => array('path' => 'wordpress/database/is_different_db', 'value' => '1'),
17
- 'data' => array('value' => '4'),
18
- ),
19
- array(
20
- 'cond' => array('path' => 'wordpress/database/is_different_db', 'value' => '0'),
21
- 'data' => array('value' => '1'),
22
- ),
23
- array(
24
- 'cond' => array('path' => 'wordpress/database/is_different_db', 'value' => '4'),
25
- 'data' => array('value' => '0'),
26
- ),
27
- array(
28
- 'cond' => array('path' => 'wordpress/database/is_different_db'),
29
- 'data' => array('path' => 'wordpress/database/is_shared'),
30
- ),
31
- array(
32
- 'cond' => array('path' => 'wordpress_blog/layout/template_default'),
33
- 'data' => array('path' => 'wordpress/layout/default'),
34
- ),
35
- array(
36
- 'cond' => array('path' => 'wordpress_blog/layout/template_default'),
37
- 'data' => array('path' => 'wordpress/template/default'),
38
- ),
39
- array(
40
- 'cond' => array('path' => 'wordpress_blog/layout/template_homepage'),
41
- 'data' => array('path' => 'wordpress/template/homepage'),
42
- ),
43
- array(
44
- 'cond' => array('path' => 'wordpress_blog/layout/template_post_list'),
45
- 'data' => array('path' => 'wordpress/template/post_list'),
46
- ),
47
- array(
48
- 'cond' => array('path' => 'wordpress_blog/layout/template_post_view'),
49
- 'data' => array('path' => 'wordpress/template/post_view'),
50
- ),
51
- array(
52
- 'cond' => array('path' => 'wordpress_blog/layout/template_page'),
53
- 'data' => array('path' => 'wordpress/template/page'),
54
- ),
55
- array(
56
- 'cond' => array('path' => 'wordpress_blog/menu/enabled'),
57
- 'data' => array('path' => 'wordpress/menu/enabled'),
58
- ),
59
- array(
60
- 'cond' => array('path' => 'wordpress_blog/menu/id'),
61
- 'data' => array('path' => 'wordpress/menu/id'),
62
- ),
63
- array(
64
- 'cond' => array('path' => 'wordpress_blog/layout/toplink_enabled'),
65
- 'data' => array('path' => 'wordpress/toplink/enabled'),
66
- ),
67
- array(
68
- 'cond' => array('path' => 'wordpress_blog/layout/toplink_label'),
69
- 'data' => array('path' => 'wordpress/toplink/label'),
70
- ),
71
- array(
72
- 'cond' => array('path' => 'wordpress_blog/layout/toplink_position'),
73
- 'data' => array('path' => 'wordpress/toplink/position'),
74
- ),
75
- array(
76
- 'cond' => array('path' => 'wordpress_blog/associations/force_single_store'),
77
- 'data' => array('path' => 'wordpress/integration/force_single_store'),
78
- ),
79
- array(
80
- 'cond' => array('path' => 'wordpress_blog/layout/sidebar_left_empty'),
81
- 'data' => array('path' => 'wordpress/misc/sidebar_left_empty'),
82
- ),
83
- array(
84
- 'cond' => array('path' => 'wordpress_blog/layout/sidebar_right_empty'),
85
- 'data' => array('path' => 'wordpress/misc/sidebar_right_empty'),
86
- ),
87
- array(
88
- 'cond' => array('path' => 'wordpress_blog/posts/autop'),
89
- 'data' => array('path' => 'wordpress/misc/autop'),
90
- ),
91
- array(
92
- 'cond' => array('path' => 'wordpress_blog/layout/include_css'),
93
- 'data' => array('path' => 'wordpress/misc/include_css'),
94
- ),
95
- );
96
-
97
- foreach($updates as $update) {
98
- $cond = array();
99
-
100
- foreach($update['cond'] as $field => $value) {
101
- $cond[] = $this->getConnection()->quoteInto($field . '=?', $value);
102
- }
103
-
104
- try {
105
- $this->getConnection()->update($table, $update['data'], implode(' AND ', $cond));
106
- }
107
- catch (Exception $e) {
108
- Mage::helper('wordpress')->log($e);
109
- }
110
- }
111
- }
112
- catch (Exception $e) {
113
- Mage::helper('wordpress')->log($e);
114
- throw $e;
115
- }
116
-
117
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql app/code/community/Fishpig/Wordpress/sql/wordpress_setup/mysql4-upgrade-3.2.0.0-3.2.0.1.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * @category Fishpig
4
- * @package Fishpig_Wordpress
5
- * @license http://fishpig.co.uk/license.txt
6
- * @author Ben Tideswell <help@fishpig.co.uk>
7
- */
8
-
9
- $this->startSetup();
10
-
11
- try {
12
- // Delete old autologin table
13
- $this->getConnection()->query("DROP TABLE IF EXISTS {$this->getTable('wordpress_autologin')}");
14
-
15
- // Delete old CPT table
16
- $this->getConnection()->query("DROP TABLE IF EXISTS {$this->getTable('wordpress_addon_cpt_type')}");
17
-
18
- // Check for association tables
19
- Mage::helper('wordpress/associations')->checkForTables();
20
-
21
- // Clean duplicate users (old CS error)
22
- Mage::getResourceModel('wordpress/user')->cleanDuplicates();
23
- }
24
- catch (Exception $e) {
25
- Mage::helper('wordpress')->log($e);
26
- }
27
-
28
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/wordpress/sidebar/widget/instagram.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ **/
5
+ ?>
6
+ <?php if ($this->getImages()): ?>
7
+ <div class="block block-blog block-blog-instagram">
8
+ <div class="block-title">
9
+ <strong><span><?php echo $this->getTitle() ?></span></strong>
10
+ </div>
11
+ <div class="block-content">
12
+ <ul>
13
+ <?php foreach($this->getImages() as $image): ?>
14
+ <li class="item">
15
+ <a href="<?php echo $this->getPostUrl($image) ?>" target="_blank">
16
+ <img src="<?php echo $image->getThumbnailSrc() ?>" alt="<?php echo $this->escapeHtml($image->getCaption()) ?>" />
17
+ </a>
18
+ </li>
19
+ <?php endforeach; ?>
20
+ </ul>
21
+ </div>
22
+ </div>
23
+ <?php endif; ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fishpig_Wordpress_Integration</name>
4
- <version>4.2.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://fishpig.co.uk/license.txt">FishPig EULA</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Easily integrate Magento and WordPress without modifying any core files.</description>
11
  <notes>For changes, please see http://fishpig.co.uk/magento/wordpress-integration/#changelog</notes>
12
  <authors><author><name>fishpig</name><user>fishpig</user><email>ben@fishpig.co.uk</email></author></authors>
13
- <date>2016-11-28</date>
14
- <time>11:11:18</time>
15
- <contents><target name="magecommunity"><dir name="Fishpig"><dir name="Wordpress"><dir name="Block"><file name="Abstract.php" hash="bf9e97598ed72068b3172dc477978c9f"/><dir name="Adminhtml"><dir name="Associations"><file name="Abstract.php" hash="dd589f8fcae2122632457e08c01aa774"/><dir name="Category"><file name="Category.php" hash="26782c6bc34cfbf7f81d1775c40a8a35"/><file name="Post.php" hash="1dd1330e619bdff79ad7d7c6fd08edd6"/></dir><dir name="Cms"><dir name="Page"><file name="Category.php" hash="7442c0874792bc08438c472875368b21"/><file name="Post.php" hash="5bed4c4e1baa1d0f0430d5cdfa87d020"/></dir></dir><dir name="Product"><file name="Category.php" hash="f99636a65b55ccc8818a98230439949d"/><file name="Post.php" hash="0493ae37198cbf50f5ae45565432f894"/></dir></dir><file name="Extend.php" hash="8f5d6ffe4ccb8b48221626ff33882090"/><dir name="Frontend"><file name="Autologin.php" hash="7a795c13d35491ba0a79fd1b15854c6a"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Route.php" hash="cb79ab33659cf906988b1403e0fc625c"/></dir></dir></dir></dir><file name="Update.php" hash="d1aa4001cc758132bcaca792c8dc5f07"/></dir><file name="Ajax.php" hash="0e8e97efddde53b1818c1eaec2b305b0"/><dir name="Archive"><file name="View.php" hash="b56c0c8b9e26a071c28440a0e52e6800"/></dir><dir name="Author"><file name="View.php" hash="03fa439ff3bece2c0cc2e56c2412740a"/></dir><dir name="Feed"><file name="Abstract.php" hash="d8405e51ded312cda6c00b09dd873788"/><dir name="Post"><file name="Comment.php" hash="6e279932f0d45375b5fdee0939e15415"/></dir><file name="Post.php" hash="d1bf0bfcfd687d5f3ca50b341afff560"/></dir><file name="Homepage.php" hash="d5383c14b381594e211a2c7438684d41"/><file name="Menu.php" hash="5dc369f5542bcf6ac87ab7ce8a98c6c1"/><dir name="Page"><file name="View.php" hash="dedf5c07dc52afc6aac0a87fb0c239b6"/></dir><dir name="Post"><file name="Abstract.php" hash="b782a654b478c4067aacba20f0431dc0"/><dir name="Associated"><file name="Products.php" hash="8a74abcfe97df273d75d7fb7b0f9d8d6"/></dir><file name="Associated.php" hash="6fbae669e0269916e578e4f6a1355415"/><dir name="List"><file name="Associated.php" hash="056fd7910da5a30d71c884982297879b"/><file name="Pager.php" hash="7def684fe156c3f59ac8185a0aad345f"/><file name="Renderer.php" hash="35fa1e4294f07d43bf2f8b5e7628161a"/><dir name="Wrapper"><file name="Abstract.php" hash="0a0e7eafe02de151e05353c01d6d4a67"/></dir></dir><file name="List.php" hash="85aa53897a40f88f5dd2f5af982bff8f"/><file name="Meta.php" hash="4482daab91f5c1a731d1d45d79c369b5"/><dir name="View"><dir name="Comment"><file name="Abstract.php" hash="06c0592b3f10c6af2bc8d3d7cdc5a73e"/><file name="Form.php" hash="3a75d0ebbd104076afb8195cc46e339d"/><file name="Pager.php" hash="d0d6c23852f6e4fa894cded53cb289a5"/><file name="Wrapper.php" hash="6318449f58d4a3b11018b3354252f021"/></dir><file name="Comments.php" hash="d3bee9fd86a5318b7986a4d776eed5f7"/></dir><file name="View.php" hash="4a8aca01c7ea5ee32027569c802bbc86"/></dir><dir name="Search"><file name="Result.php" hash="ad8ea64756a575b874afcae9250f6b97"/></dir><dir name="Shortcode"><file name="Product.php" hash="53b1986e1376ea0bdb2a793744253804"/></dir><dir name="Sidebar"><dir name="Widget"><file name="Abstract.php" hash="67234d08da2afec0e61c191ce2e90819"/><file name="Archives.php" hash="cba60c97dc3c9e6b4b73db53787e0aa4"/><file name="Calendar.php" hash="eb838cc8406a0ff3d33b767bdeec0044"/><file name="Categories.php" hash="c9c419da25dd707b8b932abca7bfd892"/><file name="Comments.php" hash="8d38d35bd7aa16188d3b33f3844a6e42"/><file name="Image.php" hash="655fdcb2700a2603539e3008b07b7ae1"/><file name="Links.php" hash="1985b68fd53b3502540e932d25d77ae8"/><file name="Menu.php" hash="5c55903395588b36fa2f6c2779a4ed62"/><file name="Meta.php" hash="942292929971a6705379a87d73e3c226"/><file name="Pages.php" hash="cde08845cca7a7f43ea2e40ca6d090ef"/><file name="Posts.php" hash="1b35086ddc34206ea272856ce447f5dc"/><dir name="Rss"><file name="Abstract.php" hash="c07d0787e920060313db1b7698437c40"/></dir><file name="Rss.php" hash="4b16b12cb7c7370cd4977375d31c184b"/><file name="Search.php" hash="18d02709f88950490e60b00adf98bf54"/><file name="Tagcloud.php" hash="e7ddcb0652286b1442bab0d82aebef00"/><file name="Taxonomy.php" hash="3bb2ee45b014e8aa3a59a15c44cdc03d"/><file name="Text.php" hash="e23ecb266b807af0a73c6155648d42c2"/><file name="Yarpp.php" hash="418b6d211410a98f0336130769c998a0"/></dir></dir><file name="Sidebar.php" hash="06d6ba70df5abb07c23278418efc4089"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Post"><file name="Type.php" hash="dcc3e93873f10829d1211f8325f40044"/></dir></dir></dir></dir></dir><file name="Template.php" hash="aadd68bcb1da5cfe974d36dabc498754"/><dir name="Term"><file name="View.php" hash="f640abf673b7412cf05528924db2646f"/></dir></dir><dir name="Block app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Block app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Block"><file name="Abstract.php" hash="bf9e97598ed72068b3172dc477978c9f"/><dir name="Adminhtml"><dir name="Associations"><file name="Abstract.php" hash="dd589f8fcae2122632457e08c01aa774"/><dir name="Category"><file name="Category.php" hash="26782c6bc34cfbf7f81d1775c40a8a35"/><file name="Post.php" hash="1dd1330e619bdff79ad7d7c6fd08edd6"/></dir><dir name="Cms"><dir name="Page"><file name="Category.php" hash="7442c0874792bc08438c472875368b21"/><file name="Post.php" hash="5bed4c4e1baa1d0f0430d5cdfa87d020"/></dir></dir><dir name="Product"><file name="Category.php" hash="f99636a65b55ccc8818a98230439949d"/><file name="Post.php" hash="0493ae37198cbf50f5ae45565432f894"/></dir></dir><file name="Extend.php" hash="8f5d6ffe4ccb8b48221626ff33882090"/><dir name="Frontend"><file name="Autologin.php" hash="7a795c13d35491ba0a79fd1b15854c6a"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Route.php" hash="cb79ab33659cf906988b1403e0fc625c"/></dir></dir></dir></dir><file name="Update.php" hash="d1aa4001cc758132bcaca792c8dc5f07"/></dir><file name="Ajax.php" hash="0e8e97efddde53b1818c1eaec2b305b0"/><dir name="Archive"><file name="View.php" hash="b56c0c8b9e26a071c28440a0e52e6800"/></dir><dir name="Author"><file name="View.php" hash="03fa439ff3bece2c0cc2e56c2412740a"/></dir><dir name="Feed"><file name="Abstract.php" hash="d8405e51ded312cda6c00b09dd873788"/><dir name="Post"><file name="Comment.php" hash="6e279932f0d45375b5fdee0939e15415"/></dir><file name="Post.php" hash="d1bf0bfcfd687d5f3ca50b341afff560"/></dir><file name="Homepage.php" hash="d5383c14b381594e211a2c7438684d41"/><file name="Menu.php" hash="5dc369f5542bcf6ac87ab7ce8a98c6c1"/><dir name="Page"><file name="View.php" hash="dedf5c07dc52afc6aac0a87fb0c239b6"/></dir><dir name="Post"><file name="Abstract.php" hash="b782a654b478c4067aacba20f0431dc0"/><dir name="Associated"><file name="Products.php" hash="8a74abcfe97df273d75d7fb7b0f9d8d6"/></dir><file name="Associated.php" hash="6fbae669e0269916e578e4f6a1355415"/><dir name="List"><file name="Associated.php" hash="056fd7910da5a30d71c884982297879b"/><file name="Pager.php" hash="7def684fe156c3f59ac8185a0aad345f"/><file name="Renderer.php" hash="35fa1e4294f07d43bf2f8b5e7628161a"/><dir name="Wrapper"><file name="Abstract.php" hash="0a0e7eafe02de151e05353c01d6d4a67"/></dir></dir><file name="List.php" hash="85aa53897a40f88f5dd2f5af982bff8f"/><file name="Meta.php" hash="4482daab91f5c1a731d1d45d79c369b5"/><dir name="View"><dir name="Comment"><file name="Abstract.php" hash="06c0592b3f10c6af2bc8d3d7cdc5a73e"/><file name="Form.php" hash="3a75d0ebbd104076afb8195cc46e339d"/><file name="Pager.php" hash="d0d6c23852f6e4fa894cded53cb289a5"/><file name="Wrapper.php" hash="6318449f58d4a3b11018b3354252f021"/></dir><file name="Comments.php" hash="d3bee9fd86a5318b7986a4d776eed5f7"/></dir><file name="View.php" hash="4a8aca01c7ea5ee32027569c802bbc86"/></dir><dir name="Search"><file name="Result.php" hash="ad8ea64756a575b874afcae9250f6b97"/></dir><dir name="Shortcode"><file name="Product.php" hash="53b1986e1376ea0bdb2a793744253804"/></dir><dir name="Sidebar"><dir name="Widget"><file name="Abstract.php" hash="67234d08da2afec0e61c191ce2e90819"/><file name="Archives.php" hash="cba60c97dc3c9e6b4b73db53787e0aa4"/><file name="Calendar.php" hash="eb838cc8406a0ff3d33b767bdeec0044"/><file name="Categories.php" hash="c9c419da25dd707b8b932abca7bfd892"/><file name="Comments.php" hash="8d38d35bd7aa16188d3b33f3844a6e42"/><file name="Image.php" hash="655fdcb2700a2603539e3008b07b7ae1"/><file name="Links.php" hash="1985b68fd53b3502540e932d25d77ae8"/><file name="Menu.php" hash="5c55903395588b36fa2f6c2779a4ed62"/><file name="Meta.php" hash="942292929971a6705379a87d73e3c226"/><file name="Pages.php" hash="cde08845cca7a7f43ea2e40ca6d090ef"/><file name="Posts.php" hash="1b35086ddc34206ea272856ce447f5dc"/><dir name="Rss"><file name="Abstract.php" hash="c07d0787e920060313db1b7698437c40"/></dir><file name="Rss.php" hash="4b16b12cb7c7370cd4977375d31c184b"/><file name="Search.php" hash="18d02709f88950490e60b00adf98bf54"/><file name="Tagcloud.php" hash="e7ddcb0652286b1442bab0d82aebef00"/><file name="Taxonomy.php" hash="3bb2ee45b014e8aa3a59a15c44cdc03d"/><file name="Text.php" hash="e23ecb266b807af0a73c6155648d42c2"/><file name="Yarpp.php" hash="418b6d211410a98f0336130769c998a0"/></dir></dir><file name="Sidebar.php" hash="06d6ba70df5abb07c23278418efc4089"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Post"><file name="Type.php" hash="dcc3e93873f10829d1211f8325f40044"/></dir></dir></dir></dir></dir><file name="Template.php" hash="aadd68bcb1da5cfe974d36dabc498754"/><dir name="Term"><file name="View.php" hash="f640abf673b7412cf05528924db2646f"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="Controller"><file name="Abstract.php" hash="936db8d033b8c257c9d4df5ff919b9e1"/><file name="Router.php" hash="98c155ccd254f43470857a7084bb696e"/><dir name="Router"><file name="Addon.php" hash="896162d5b3608442134e71eb5ab7b06c"/></dir></dir><dir name="Controller app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Controller app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Controller"><file name="Abstract.php" hash="936db8d033b8c257c9d4df5ff919b9e1"/><file name="Router.php" hash="98c155ccd254f43470857a7084bb696e"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><file name="Exception.php" hash="ef2e08daa502bce27f98d83c9194c8f2"/><dir name="Exception.php app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Exception.php app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><file name="Exception.php" hash="ef2e08daa502bce27f98d83c9194c8f2"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Abstract.php" hash="c0e97b8c7b60545b1b127b8439a8e736"/><file name="App.php" hash="e30f1a447369e49f7f30e6bf9254387b"/><file name="Associations.php" hash="9a08b34d4eb505059555f3bb65ca4229"/><dir name="Catalog"><file name="Product.php" hash="d00afec7c5bfe37e8ba1aa21d638ae90"/></dir><file name="Data.php" hash="b2fdb68f6a04e8abe9fbf17fb7d75be9"/><file name="Database.php" hash="dcd89ce8c8627c9917206ad65e18f6f3"/><file name="Filter.php" hash="b408dc56b69c24f2083c6a3fcd57dbe4"/><dir name="Plugin"><file name="Abstract.php" hash="c8f9e76ddf381ee131efc9441a2990a2"/><dir name="Seo"><file name="Abstract.php" hash="4cf4a5d807ba6d36670d92d8b8deae1e"/></dir></dir><file name="Plugin.php" hash="046ed88b3892c7456c894d86656113bd"/><file name="Router.php" hash="0218c7adc12511f45afa683184875c95"/><dir name="Shortcode"><file name="Abstract.php" hash="42b163f6bbb83bcae9e8f212b2ac4916"/><file name="AssociatedProducts.php" hash="146595bd7d7294794004c8813dad234c"/><file name="Caption.php" hash="47455590dafb7ee27f9872592312d3f0"/><file name="Code.php" hash="002746d8c64e8faa9c2340a4496ae7b6"/><file name="Dailymotion.php" hash="e12adc8cef400f0a382cf69138610426"/><file name="Gallery.php" hash="53ec715f115e2844edf56e22a4687d41"/><file name="Gist.php" hash="c90ad1b6293d29845a38eca66099ca2b"/><file name="Instagram.php" hash="4e155d67366c8c6598b8fdd4c5c395c2"/><file name="Product.php" hash="d37b2513b66a554349b4ccdf854edc11"/><file name="Scribd.php" hash="4b70de264a033be1104dd63d9e78f1c6"/><file name="Spotify.php" hash="d041bb90577d6a8acc1521f95637b302"/><file name="Vimeo.php" hash="83b242ee25c6debc72b3af3c79b97a68"/><file name="Youtube.php" hash="1717787865eeb2830c72678fcdbe64ff"/></dir><file name="Social.php" hash="5ee03cfac0e48660e3a0eb49d4d28d28"/><file name="System.php" hash="a8fd4f8df94523f9780c20363dd0ac64"/></dir><dir name="Helper app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Helper app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Helper"><file name="Abstract.php" hash="c0e97b8c7b60545b1b127b8439a8e736"/><file name="App.php" hash="e30f1a447369e49f7f30e6bf9254387b"/><file name="Associations.php" hash="9a08b34d4eb505059555f3bb65ca4229"/><dir name="Catalog"><file name="Product.php" hash="d00afec7c5bfe37e8ba1aa21d638ae90"/></dir><file name="Data.php" hash="b2fdb68f6a04e8abe9fbf17fb7d75be9"/><file name="Database.php" hash="dcd89ce8c8627c9917206ad65e18f6f3"/><file name="Filter.php" hash="b408dc56b69c24f2083c6a3fcd57dbe4"/><dir name="Plugin"><file name="Abstract.php" hash="c8f9e76ddf381ee131efc9441a2990a2"/><dir name="Seo"><file name="Abstract.php" hash="4cf4a5d807ba6d36670d92d8b8deae1e"/></dir></dir><file name="Plugin.php" hash="046ed88b3892c7456c894d86656113bd"/><file name="Router.php" hash="0218c7adc12511f45afa683184875c95"/><dir name="Shortcode"><file name="Abstract.php" hash="42b163f6bbb83bcae9e8f212b2ac4916"/><file name="AssociatedProducts.php" hash="146595bd7d7294794004c8813dad234c"/><file name="Caption.php" hash="47455590dafb7ee27f9872592312d3f0"/><file name="Code.php" hash="002746d8c64e8faa9c2340a4496ae7b6"/><file name="Dailymotion.php" hash="e12adc8cef400f0a382cf69138610426"/><file name="Gallery.php" hash="53ec715f115e2844edf56e22a4687d41"/><file name="Gist.php" hash="c90ad1b6293d29845a38eca66099ca2b"/><file name="Instagram.php" hash="4e155d67366c8c6598b8fdd4c5c395c2"/><file name="Product.php" hash="d37b2513b66a554349b4ccdf854edc11"/><file name="Scribd.php" hash="4b70de264a033be1104dd63d9e78f1c6"/><file name="Spotify.php" hash="d041bb90577d6a8acc1521f95637b302"/><file name="Vimeo.php" hash="83b242ee25c6debc72b3af3c79b97a68"/><file name="Youtube.php" hash="1717787865eeb2830c72678fcdbe64ff"/></dir><file name="Social.php" hash="5ee03cfac0e48660e3a0eb49d4d28d28"/><file name="System.php" hash="a8fd4f8df94523f9780c20363dd0ac64"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="Model"><file name="Abstract.php" hash="57aaab0c828039b58b7552c36602927a"/><file name="Archive.php" hash="bf512f09abb2ea7c20e63c1f6e6c734f"/><file name="Image.php" hash="ba5aefa5aaaba530cef51a2237ba5042"/><dir name="Menu"><file name="Item.php" hash="b88d7ee44f3bcc6d1d2521dc89a677f7"/></dir><file name="Menu.php" hash="de877052ac65514d393a131df3d5c142"/><file name="Observer.php" hash="adc5d20302ef33a14c63432ad1312a49"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="3068111ba883bacabe87f7fff5f1f795"/></dir><file name="Comment.php" hash="8f7a5797db8aad19b4d55dba6f6ab857"/><file name="Type.php" hash="b789aef92421a82d2cdafe19898356a3"/></dir><file name="Post.php" hash="b5ac551e5ede067cd72ed1e4bb9b33ba"/><dir name="Resource"><file name="Abstract.php" hash="003a37262547fb8f02679739e21338c1"/><dir name="Collection"><file name="Abstract.php" hash="7d9a68175201177ec22deb6f6f29d388"/></dir><dir name="Image"><file name="Collection.php" hash="7d36d6dbe46b12d6a8412dbd07d3bc41"/></dir><file name="Image.php" hash="1b637473b71dd672ccd6a10a4f702ee2"/><dir name="Menu"><file name="Collection.php" hash="7deacc7b99f35392fd8c14ca3905d6ea"/><dir name="Item"><file name="Collection.php" hash="08249f3bed35c5d44adc01bd04ffc7a7"/></dir><file name="Item.php" hash="7e6ebd1cf1b1d4d33f2fb052cfa6e554"/></dir><file name="Menu.php" hash="c0e53a408ce206a801e81d667712dfc0"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="357167e7379412bd047a2a7d63a7a6c3"/><dir name="Collection"><file name="Abstract.php" hash="c618bf7c6af0b1693c24432616368c71"/></dir></dir><file name="Collection.php" hash="2a71cf7573bc75d7bc3f8abf88bad235"/><dir name="Comment"><file name="Collection.php" hash="a44a18593da1b78efaee9b26be2f7e32"/></dir><file name="Comment.php" hash="1d9a8e258581120a084d84f556911636"/></dir><file name="Post.php" hash="90516c1b09928be401916a33c368a236"/><file name="Setup.php" hash="81d4730bb23b8139cb9e6dc654d366b8"/><dir name="Term"><file name="Collection.php" hash="7089f8aeb441ebac4601fb9e070e74b2"/></dir><file name="Term.php" hash="85f42eaa2f05be6f2cd3fc5268e93559"/><dir name="User"><file name="Collection.php" hash="16e628d55a0fa01747e01a695f709e00"/></dir><file name="User.php" hash="2f3a904ba1a03a9ea36e628059d4b73f"/></dir><dir name="Sitemap"><file name="Sitemap.php" hash="bca54ec7d86e4920e50da0b587c4b99e"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Autologin.php" hash="7d2664238443b07ea685ef3df01f5eff"/><file name="Encrypted.php" hash="520824f9a5533cf790aa8b5bb136e7c9"/></dir><dir name="Source"><file name="Menu.php" hash="9caaf56ff64f3858d4e206c6335c37ec"/><dir name="Social"><dir name="Media"><file name="Service.php" hash="61f66b78e2a122f07a9307b273b62feb"/></dir></dir></dir></dir></dir><dir name="Term"><file name="Taxonomy.php" hash="e2976a1b2c1b7cb7199b88a73dd78ea9"/></dir><file name="Term.php" hash="c185736836c876efa91bd29ee5cf7110"/><file name="User.php" hash="0f75d9705aaa0b690217721a61ecd3e6"/></dir><dir name="Model app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Model app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="Model"><file name="Abstract.php" hash="57aaab0c828039b58b7552c36602927a"/><file name="Archive.php" hash="bf512f09abb2ea7c20e63c1f6e6c734f"/><file name="Image.php" hash="ba5aefa5aaaba530cef51a2237ba5042"/><dir name="Menu"><file name="Item.php" hash="b88d7ee44f3bcc6d1d2521dc89a677f7"/></dir><file name="Menu.php" hash="de877052ac65514d393a131df3d5c142"/><file name="Observer.php" hash="adc5d20302ef33a14c63432ad1312a49"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="3068111ba883bacabe87f7fff5f1f795"/></dir><file name="Comment.php" hash="8f7a5797db8aad19b4d55dba6f6ab857"/><file name="Type.php" hash="b789aef92421a82d2cdafe19898356a3"/></dir><file name="Post.php" hash="b5ac551e5ede067cd72ed1e4bb9b33ba"/><dir name="Resource"><file name="Abstract.php" hash="003a37262547fb8f02679739e21338c1"/><dir name="Collection"><file name="Abstract.php" hash="7d9a68175201177ec22deb6f6f29d388"/></dir><dir name="Image"><file name="Collection.php" hash="7d36d6dbe46b12d6a8412dbd07d3bc41"/></dir><file name="Image.php" hash="1b637473b71dd672ccd6a10a4f702ee2"/><dir name="Menu"><file name="Collection.php" hash="7deacc7b99f35392fd8c14ca3905d6ea"/><dir name="Item"><file name="Collection.php" hash="08249f3bed35c5d44adc01bd04ffc7a7"/></dir><file name="Item.php" hash="7e6ebd1cf1b1d4d33f2fb052cfa6e554"/></dir><file name="Menu.php" hash="c0e53a408ce206a801e81d667712dfc0"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="357167e7379412bd047a2a7d63a7a6c3"/><dir name="Collection"><file name="Abstract.php" hash="c618bf7c6af0b1693c24432616368c71"/></dir></dir><file name="Collection.php" hash="2a71cf7573bc75d7bc3f8abf88bad235"/><dir name="Comment"><file name="Collection.php" hash="a44a18593da1b78efaee9b26be2f7e32"/></dir><file name="Comment.php" hash="1d9a8e258581120a084d84f556911636"/></dir><file name="Post.php" hash="90516c1b09928be401916a33c368a236"/><file name="Setup.php" hash="81d4730bb23b8139cb9e6dc654d366b8"/><dir name="Term"><file name="Collection.php" hash="7089f8aeb441ebac4601fb9e070e74b2"/></dir><file name="Term.php" hash="85f42eaa2f05be6f2cd3fc5268e93559"/><dir name="User"><file name="Collection.php" hash="16e628d55a0fa01747e01a695f709e00"/></dir><file name="User.php" hash="2f3a904ba1a03a9ea36e628059d4b73f"/></dir><dir name="Sitemap"><file name="Sitemap.php" hash="bca54ec7d86e4920e50da0b587c4b99e"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Autologin.php" hash="7d2664238443b07ea685ef3df01f5eff"/><file name="Encrypted.php" hash="520824f9a5533cf790aa8b5bb136e7c9"/></dir><dir name="Source"><file name="Menu.php" hash="9caaf56ff64f3858d4e206c6335c37ec"/><dir name="Social"><dir name="Media"><file name="Service.php" hash="61f66b78e2a122f07a9307b273b62feb"/></dir></dir></dir></dir></dir><dir name="Term"><file name="Taxonomy.php" hash="e2976a1b2c1b7cb7199b88a73dd78ea9"/></dir><file name="Term.php" hash="c185736836c876efa91bd29ee5cf7110"/><file name="User.php" hash="0f75d9705aaa0b690217721a61ecd3e6"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><file name="change-log.txt" hash="1eabdd06602ca659048c07ad29e7adb8"/><dir name="change-log.txt app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="change-log.txt app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><file name="change-log.txt" hash="1eabdd06602ca659048c07ad29e7adb8"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Wordpress"><file name="AssociationsController.php" hash="304218bd303b88e788487c2f2e2cbb04"/></dir><file name="WordpressController.php" hash="3c40d9782f0a970798574f4a3eb4235a"/></dir><file name="AjaxController.php" hash="410a9d84692fabfc3e846598a772c803"/><file name="ArchiveController.php" hash="e9ec7c6d89501c9efd8a33db2170bcb9"/><file name="AuthorController.php" hash="8056629849e92b754e6eb85e1537565a"/><file name="IndexController.php" hash="a5fee64e05a8a14babb50e95eeff0906"/><file name="PostController.php" hash="74704fdf0bbf481e2782f54d1b071786"/><file name="SearchController.php" hash="fceba89823f011517bbf48a04c4bb361"/><file name="TermController.php" hash="8bc39e2dca19b04ac52f7e320d41bc8c"/></dir><dir name="controllers app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="controllers app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="controllers"><dir name="Adminhtml"><dir name="Wordpress"><file name="AssociationsController.php" hash="304218bd303b88e788487c2f2e2cbb04"/></dir><file name="WordpressController.php" hash="3c40d9782f0a970798574f4a3eb4235a"/></dir><file name="AjaxController.php" hash="410a9d84692fabfc3e846598a772c803"/><file name="ArchiveController.php" hash="e9ec7c6d89501c9efd8a33db2170bcb9"/><file name="AuthorController.php" hash="8056629849e92b754e6eb85e1537565a"/><file name="IndexController.php" hash="a5fee64e05a8a14babb50e95eeff0906"/><file name="PostController.php" hash="74704fdf0bbf481e2782f54d1b071786"/><file name="SearchController.php" hash="fceba89823f011517bbf48a04c4bb361"/><file name="TermController.php" hash="8bc39e2dca19b04ac52f7e320d41bc8c"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="22061db5a80dc2fa952a64778a346dfe"/><file name="config.xml" hash="18bacb1c8311b2e9afc47c5c3440dd4d"/><file name="fishpig.xml" hash="e24400143b6d480ac4a501f0fdc32493"/><file name="system.xml" hash="8dce70be3871210de82104253045535a"/><file name="widget.xml" hash="b7b586ef3d869177a43e8e87a04b1222"/></dir><dir name="etc app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="etc app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="etc"><file name="adminhtml.xml" hash="22061db5a80dc2fa952a64778a346dfe"/><file name="config.xml" hash="18bacb1c8311b2e9afc47c5c3440dd4d"/><file name="fishpig.xml" hash="e24400143b6d480ac4a501f0fdc32493"/><file name="system.xml" hash="8dce70be3871210de82104253045535a"/><file name="widget.xml" hash="b7b586ef3d869177a43e8e87a04b1222"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="sql"><dir name="wordpress_setup"><file name="mysql4-install-0.1.0.php" hash="771dbb85a173051acc83b506fe67067d"/><file name="mysql4-upgrade-2.5.9.0-2.5.9.1.php" hash="a295aaeb8aa45d84bc1541fdac70d7ad"/><file name="mysql4-upgrade-3.2.0.0-3.2.0.1.php" hash="504da139c47e676666ac2b4210916d5f"/></dir></dir><dir name="sql app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="sql app"><dir name="code"><dir name="community"><dir name="Fishpig"><dir name="Wordpress"><dir name="sql"><dir name="wordpress_setup"><file name="mysql4-install-0.1.0.php" hash="771dbb85a173051acc83b506fe67067d"/><file name="mysql4-upgrade-2.5.9.0-2.5.9.1.php" hash="a295aaeb8aa45d84bc1541fdac70d7ad"/><file name="mysql4-upgrade-3.2.0.0-3.2.0.1.php" hash="504da139c47e676666ac2b4210916d5f"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="Addon"><dir name="WordPressSEO"><dir name="Helper"><file name="Data.php" hash="0bdb85515554de5c7eba0828099f9ac2"/></dir><dir name="etc"><file name="config.xml" hash="d1dde914497c73e0523b108a7bbd8841"/></dir></dir><dir name="Yarpp"><dir name="Block"><dir name="Sidebar"><file name="Widget.php" hash="98d5edda7378a0514f00950816f768e8"/></dir></dir><dir name="etc"><file name="config.xml" hash="746bd41d16f1d2402a35e64f12786520"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="wordpress.xml" hash="025b215d245317fbc619ae5677979339"/></dir><dir name="template"><dir name="wordpress"><file name="integration-tests.phtml" hash="6f7030e821d62e240675ba6831966aa7"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="wordpress.xml" hash="75f001e822e2d2a7213b531ae7066a97"/></dir><dir name="template"><dir name="wordpress"><dir><dir name="archive"><file name="view.phtml" hash="7243f533d0357685aa5cf8c115b148a1"/></dir><dir name="author"><file name="view.phtml" hash="1e52d2c16276406553a8d48c75eeb306"/></dir><dir name="post"><dir name="associated"><file name="products.phtml" hash="0b635b1cb6eab98aaa641a1f27bbe5fa"/></dir><file name="associated.phtml" hash="80e9593a788da42a0fcbe24f53c27cb5"/><dir name="list"><dir name="renderer"><file name="default.phtml" hash="68d65457c905c7cdf85c8fb93473e2f0"/></dir><file name="wrapper.phtml" hash="19549d50d36482dee642d80b7a932765"/></dir><file name="list.phtml" hash="19d0395edf4b1a3d787be50b61a487f1"/><file name="meta.phtml" hash="5eb9a91335c357ec77717495cbc513c6"/><dir name="view"><dir name="comment"><file name="form.phtml" hash="c22607dc13b7cc294da7c6d605925893"/><file name="wrapper.phtml" hash="dd6980b9b432634d2c63b03e635f09a4"/></dir><file name="comments.phtml" hash="05668659c30bf78727bbedfdbd49c6ac"/><file name="page.phtml" hash="a693be74e920be8e04ff726cf16abaee"/></dir><file name="view.phtml" hash="3c15b1c39adb91857cd5d88a7550b600"/></dir><dir name="search"><file name="result.phtml" hash="263b739fe9302e6e5d815f3bf2279b2e"/></dir><dir name="shortcode"><file name="gallery.phtml" hash="ff7e796c4e511e2f27a823be104a4374"/><file name="product.phtml" hash="7fb95222834907fac31477e5934ceedc"/></dir><dir name="sidebar"><dir name="widget"><file name="abstract.phtml" hash="1979cff1c6a6337b6980f62c2cd89577"/><file name="archives.phtml" hash="6f7d3e877b22cac88b130ef2b68fe286"/><file name="calendar.phtml" hash="fe0dca9946a9d0bd82a6114786c865c9"/><file name="categories.phtml" hash="4340111e138cd3f9c47c48ea7736013e"/><file name="categoryposts.phtml" hash="8dad6f1026313e2a327d8fd4fa4a786d"/><file name="comments.phtml" hash="184e6434d5a7f23f83a03cb21b0d8083"/><file name="image.phtml" hash="c7657307809b127e252764c911bb9a1e"/><file name="links.phtml" hash="cf40ee224503d5eaf48c9494023e22c0"/><file name="menu.phtml" hash="7029074d6173761261ca6c30fcc194bb"/><file name="meta.phtml" hash="47c351bac53537f1536d2e2c13f069e7"/><file name="pages.phtml" hash="f3bbea9d984360f236ceb78f781d6199"/><file name="posts.phtml" hash="27c09919df79d50909c0fcb90c374cba"/><file name="rss.phtml" hash="ad8ad715f82a23540356920d76f8b74a"/><file name="search.phtml" hash="bb5846228cae41d0d71cc97b3e4a28a6"/><file name="tagcloud.phtml" hash="4978442189cf818ae4d57207ba642615"/><dir name="taxonomy"><file name="renderer.phtml" hash="41af9ae08f1aee29818c764b0bc1a256"/></dir><file name="taxonomy.phtml" hash="13a7cce60b3aeddee57484c237db697a"/><file name="text.phtml" hash="08f656c30d7e072f7f2c29e04743129c"/></dir></dir><dir name="term"><file name="view.phtml" hash="6c1a13cb279b137e0d915ea3e17d90fd"/></dir></dir><file name="homepage.phtml" hash="05856d1c44562bfc3d64f205f70c1de0"/><file name="protected.phtml" hash="31f5a14ccba3f7b69e3a4075c53bc539"/><file name="sidebar.phtml" hash="c6268b9ec5074662b8125d5aabc05b0c"/></dir><dir name="wordpress-addons"><dir name="yarpp"><file name="related.phtml" hash="08ee87974b6762c3b350464f76b85c91"/><dir name="sidebar"><file name="widget.phtml" hash="821b64bb40296aa65314ddfe7ed232f4"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="app"><dir name="etc"><dir name="modules"><file name="Fishpig_Wordpress.xml" hash="f7947cc170ce6bf1ab7a21e58ac48d31"/></dir></dir></dir><dir name="js"><dir name="fishpig"><dir name="wordpress"><file name="comments.js" hash="a3c5286844ccb293a9976bac46605289"/><file name="update.js" hash="3df101b798daa5248a279989f7fe2ff9"/><file name="search.js" hash="5631d5149f4fc145db04864b1527b2a8"/><file name="lightbox.js" hash="bb7c9e300dc33d399ca72039e727e266"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="wordpress"><file name="styles.css" hash="8e85ffde94798850dcf5c70cdd06ad00"/><file name="ajax-loader.gif" hash="a51c5608d01acf32df728f299767f82b"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="cs_CZ"><file name="Fishpig_Wordpress.csv" hash="416afbb6426b717f2cb37c99daf77adc"/></dir><dir name="da_DK"><file name="Fishpig_Wordpress.csv" hash="d4c4803edc751baf3c7726afc6c5568f"/></dir><dir name="de_DE"><file name="Fishpig_Wordpress.csv" hash="6479677778d79a8932597bfc4a23cc20"/></dir><dir name="es_ES"><file name="Fishpig_Wordpress.csv" hash="c3397d271f0c75c1dbe1b0878f404df4"/></dir><dir name="fr_FR"><file name="Fishpig_Wordpress.csv" hash="605d8ea12a5bbb3448a360bf46c9572a"/></dir><dir name="it_IT"><file name="Fishpig_Wordpress.csv" hash="60208176d94e30400d260494d440cb3c"/></dir><dir name="ja_JP"><file name="Fishpig_Wordpress.csv" hash="3fe07f48ab2e9cc1d899264f3a9cef52"/></dir><dir name="nb_NO"><file name="Fishpig_Wordpress.csv" hash="b0d5de887b5518beb1db976ca72dd2e5"/></dir><dir name="nl_NL"><file name="Fishpig_Wordpress.csv" hash="c8f0fb68fe1e207a554b9f49b82c01ea"/></dir><dir name="nn_NO"><file name="Fishpig_Wordpress.csv" hash="bfcb347e03369a2539f0217541badf4c"/></dir><dir name="pl_PL"><file name="Fishpig_Wordpress.csv" hash="0bd6f726386f5feaf89725453460a0ca"/></dir><dir name="pt_BR"><file name="Fishpig_Wordpress.csv" hash="92f644b350b828fa44f6ba9a82df0fe2"/></dir><dir name="pt_PT"><file name="Fishpig_Wordpress.csv" hash="a222f515815ae5effe2ce57f53072c90"/></dir><dir name="ru_RU"><file name="Fishpig_Wordpress.csv" hash="b534ad6f293419af26b045f3348a1a83"/></dir><dir name="sv_SE"><file name="Fishpig_Wordpress.csv" hash="c790bfe6a98530de1f4fe47ba6d8e113"/></dir><dir name="zh_CN"><file name="Fishpig_Wordpress.csv" hash="caef42e20155f23aafb4421ee46979ff"/></dir><dir name="en_GB"><file name="Fishpig_Wordpress.csv" hash="1e1b37fed9d6f60e9ea8129fac657953"/></dir><dir name="en_US"><file name="Fishpig_Wordpress.csv" hash="1e1b37fed9d6f60e9ea8129fac657953"/></dir><dir name="sl_SI"><file name="Fishpig_Wordpress.csv" hash="f5d57703149cc50dfaed42c2c390b7d4"/></dir><dir name="tr_TR"><file name="Fishpig_Wordpress.csv" hash="8f31cfca1e7ab452b404ec29a4b782bf"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Fishpig_Wordpress_Integration</name>
4
+ <version>4.2.1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://fishpig.co.uk/license.txt">FishPig EULA</license>
7
  <channel>community</channel>
10
  <description>Easily integrate Magento and WordPress without modifying any core files.</description>
11
  <notes>For changes, please see http://fishpig.co.uk/magento/wordpress-integration/#changelog</notes>
12
  <authors><author><name>fishpig</name><user>fishpig</user><email>ben@fishpig.co.uk</email></author></authors>
13
+ <date>2016-12-05</date>
14
+ <time>15:44:19</time>
15
+ <contents><target name="magecommunity"><dir name="Fishpig"><dir name="Wordpress"><dir name="Block"><file name="Abstract.php" hash="bf9e97598ed72068b3172dc477978c9f"/><dir name="Adminhtml"><dir name="Associations"><file name="Abstract.php" hash="dd589f8fcae2122632457e08c01aa774"/><dir name="Category"><file name="Category.php" hash="26782c6bc34cfbf7f81d1775c40a8a35"/><file name="Post.php" hash="1dd1330e619bdff79ad7d7c6fd08edd6"/></dir><dir name="Cms"><dir name="Page"><file name="Category.php" hash="7442c0874792bc08438c472875368b21"/><file name="Post.php" hash="5bed4c4e1baa1d0f0430d5cdfa87d020"/></dir></dir><dir name="Product"><file name="Category.php" hash="f99636a65b55ccc8818a98230439949d"/><file name="Post.php" hash="0493ae37198cbf50f5ae45565432f894"/></dir></dir><file name="Extend.php" hash="8f5d6ffe4ccb8b48221626ff33882090"/><dir name="Frontend"><file name="Autologin.php" hash="7a795c13d35491ba0a79fd1b15854c6a"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Route.php" hash="cb79ab33659cf906988b1403e0fc625c"/></dir></dir></dir></dir><file name="Update.php" hash="d1aa4001cc758132bcaca792c8dc5f07"/></dir><file name="Ajax.php" hash="0e8e97efddde53b1818c1eaec2b305b0"/><dir name="Archive"><file name="View.php" hash="b56c0c8b9e26a071c28440a0e52e6800"/></dir><dir name="Author"><file name="View.php" hash="03fa439ff3bece2c0cc2e56c2412740a"/></dir><dir name="Feed"><file name="Abstract.php" hash="d8405e51ded312cda6c00b09dd873788"/><dir name="Post"><file name="Comment.php" hash="6e279932f0d45375b5fdee0939e15415"/></dir><file name="Post.php" hash="d1bf0bfcfd687d5f3ca50b341afff560"/></dir><file name="Homepage.php" hash="d5383c14b381594e211a2c7438684d41"/><file name="Menu.php" hash="5dc369f5542bcf6ac87ab7ce8a98c6c1"/><dir name="Page"><file name="View.php" hash="dedf5c07dc52afc6aac0a87fb0c239b6"/></dir><dir name="Post"><file name="Abstract.php" hash="b782a654b478c4067aacba20f0431dc0"/><dir name="Associated"><file name="Products.php" hash="8a74abcfe97df273d75d7fb7b0f9d8d6"/></dir><file name="Associated.php" hash="6fbae669e0269916e578e4f6a1355415"/><dir name="List"><file name="Associated.php" hash="056fd7910da5a30d71c884982297879b"/><file name="Pager.php" hash="7def684fe156c3f59ac8185a0aad345f"/><file name="Renderer.php" hash="35fa1e4294f07d43bf2f8b5e7628161a"/><dir name="Wrapper"><file name="Abstract.php" hash="0a0e7eafe02de151e05353c01d6d4a67"/></dir></dir><file name="List.php" hash="85aa53897a40f88f5dd2f5af982bff8f"/><file name="Meta.php" hash="4482daab91f5c1a731d1d45d79c369b5"/><dir name="View"><dir name="Comment"><file name="Abstract.php" hash="06c0592b3f10c6af2bc8d3d7cdc5a73e"/><file name="Form.php" hash="3a75d0ebbd104076afb8195cc46e339d"/><file name="Pager.php" hash="d0d6c23852f6e4fa894cded53cb289a5"/><file name="Wrapper.php" hash="6318449f58d4a3b11018b3354252f021"/></dir><file name="Comments.php" hash="d3bee9fd86a5318b7986a4d776eed5f7"/></dir><file name="View.php" hash="4a8aca01c7ea5ee32027569c802bbc86"/></dir><dir name="Search"><file name="Result.php" hash="ad8ea64756a575b874afcae9250f6b97"/></dir><dir name="Shortcode"><file name="Product.php" hash="53b1986e1376ea0bdb2a793744253804"/></dir><dir name="Sidebar"><dir name="Widget"><file name="Abstract.php" hash="67234d08da2afec0e61c191ce2e90819"/><file name="Archives.php" hash="cba60c97dc3c9e6b4b73db53787e0aa4"/><file name="Calendar.php" hash="eb838cc8406a0ff3d33b767bdeec0044"/><file name="Categories.php" hash="c9c419da25dd707b8b932abca7bfd892"/><file name="Comments.php" hash="8d38d35bd7aa16188d3b33f3844a6e42"/><file name="Image.php" hash="655fdcb2700a2603539e3008b07b7ae1"/><file name="Instagram.php" hash="ab8a8d7b68f991e91c5e31c3044ebded"/><file name="Links.php" hash="1985b68fd53b3502540e932d25d77ae8"/><file name="Menu.php" hash="5c55903395588b36fa2f6c2779a4ed62"/><file name="Meta.php" hash="942292929971a6705379a87d73e3c226"/><file name="Pages.php" hash="cde08845cca7a7f43ea2e40ca6d090ef"/><file name="Posts.php" hash="1b35086ddc34206ea272856ce447f5dc"/><dir name="Rss"><file name="Abstract.php" hash="c07d0787e920060313db1b7698437c40"/></dir><file name="Rss.php" hash="4b16b12cb7c7370cd4977375d31c184b"/><file name="Search.php" hash="18d02709f88950490e60b00adf98bf54"/><file name="Tagcloud.php" hash="e7ddcb0652286b1442bab0d82aebef00"/><file name="Taxonomy.php" hash="3bb2ee45b014e8aa3a59a15c44cdc03d"/><file name="Text.php" hash="e23ecb266b807af0a73c6155648d42c2"/><file name="Yarpp.php" hash="418b6d211410a98f0336130769c998a0"/></dir></dir><file name="Sidebar.php" hash="06d6ba70df5abb07c23278418efc4089"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><dir name="Post"><file name="Type.php" hash="dcc3e93873f10829d1211f8325f40044"/></dir></dir></dir></dir></dir><file name="Template.php" hash="aadd68bcb1da5cfe974d36dabc498754"/><dir name="Term"><file name="View.php" hash="f640abf673b7412cf05528924db2646f"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="936db8d033b8c257c9d4df5ff919b9e1"/><file name="Router.php" hash="98c155ccd254f43470857a7084bb696e"/><dir name="Router"><file name="Addon.php" hash="896162d5b3608442134e71eb5ab7b06c"/></dir></dir><dir name="Helper"><file name="Abstract.php" hash="c0e97b8c7b60545b1b127b8439a8e736"/><file name="App.php" hash="e30f1a447369e49f7f30e6bf9254387b"/><file name="Associations.php" hash="9a08b34d4eb505059555f3bb65ca4229"/><dir name="Catalog"><file name="Product.php" hash="d00afec7c5bfe37e8ba1aa21d638ae90"/></dir><file name="Data.php" hash="b2fdb68f6a04e8abe9fbf17fb7d75be9"/><file name="Database.php" hash="dcd89ce8c8627c9917206ad65e18f6f3"/><file name="Filter.php" hash="b408dc56b69c24f2083c6a3fcd57dbe4"/><dir name="Plugin"><file name="Abstract.php" hash="c8f9e76ddf381ee131efc9441a2990a2"/><dir name="Seo"><file name="Abstract.php" hash="4cf4a5d807ba6d36670d92d8b8deae1e"/></dir></dir><file name="Plugin.php" hash="046ed88b3892c7456c894d86656113bd"/><file name="Router.php" hash="0218c7adc12511f45afa683184875c95"/><dir name="Shortcode"><file name="Abstract.php" hash="42b163f6bbb83bcae9e8f212b2ac4916"/><file name="AssociatedProducts.php" hash="146595bd7d7294794004c8813dad234c"/><file name="Caption.php" hash="47455590dafb7ee27f9872592312d3f0"/><file name="Code.php" hash="002746d8c64e8faa9c2340a4496ae7b6"/><file name="Dailymotion.php" hash="e12adc8cef400f0a382cf69138610426"/><file name="Gallery.php" hash="53ec715f115e2844edf56e22a4687d41"/><file name="Gist.php" hash="c90ad1b6293d29845a38eca66099ca2b"/><file name="Instagram.php" hash="4e155d67366c8c6598b8fdd4c5c395c2"/><file name="Product.php" hash="d37b2513b66a554349b4ccdf854edc11"/><file name="Scribd.php" hash="4b70de264a033be1104dd63d9e78f1c6"/><file name="Spotify.php" hash="d041bb90577d6a8acc1521f95637b302"/><file name="Vimeo.php" hash="83b242ee25c6debc72b3af3c79b97a68"/><file name="Youtube.php" hash="1717787865eeb2830c72678fcdbe64ff"/></dir><file name="Social.php" hash="5ee03cfac0e48660e3a0eb49d4d28d28"/><file name="System.php" hash="a8fd4f8df94523f9780c20363dd0ac64"/></dir><dir name="Model"><file name="Abstract.php" hash="57aaab0c828039b58b7552c36602927a"/><file name="Archive.php" hash="bf512f09abb2ea7c20e63c1f6e6c734f"/><file name="Image.php" hash="ba5aefa5aaaba530cef51a2237ba5042"/><dir name="Menu"><file name="Item.php" hash="b88d7ee44f3bcc6d1d2521dc89a677f7"/></dir><file name="Menu.php" hash="de877052ac65514d393a131df3d5c142"/><file name="Observer.php" hash="adc5d20302ef33a14c63432ad1312a49"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="3068111ba883bacabe87f7fff5f1f795"/></dir><file name="Comment.php" hash="8f7a5797db8aad19b4d55dba6f6ab857"/><file name="Type.php" hash="b789aef92421a82d2cdafe19898356a3"/></dir><file name="Post.php" hash="b5ac551e5ede067cd72ed1e4bb9b33ba"/><dir name="Resource"><file name="Abstract.php" hash="003a37262547fb8f02679739e21338c1"/><dir name="Collection"><file name="Abstract.php" hash="7d9a68175201177ec22deb6f6f29d388"/></dir><dir name="Image"><file name="Collection.php" hash="7d36d6dbe46b12d6a8412dbd07d3bc41"/></dir><file name="Image.php" hash="1b637473b71dd672ccd6a10a4f702ee2"/><dir name="Menu"><file name="Collection.php" hash="7deacc7b99f35392fd8c14ca3905d6ea"/><dir name="Item"><file name="Collection.php" hash="08249f3bed35c5d44adc01bd04ffc7a7"/></dir><file name="Item.php" hash="7e6ebd1cf1b1d4d33f2fb052cfa6e554"/></dir><file name="Menu.php" hash="c0e53a408ce206a801e81d667712dfc0"/><dir name="Post"><dir name="Attachment"><file name="Abstract.php" hash="357167e7379412bd047a2a7d63a7a6c3"/><dir name="Collection"><file name="Abstract.php" hash="c618bf7c6af0b1693c24432616368c71"/></dir></dir><file name="Collection.php" hash="2a71cf7573bc75d7bc3f8abf88bad235"/><dir name="Comment"><file name="Collection.php" hash="a44a18593da1b78efaee9b26be2f7e32"/></dir><file name="Comment.php" hash="1d9a8e258581120a084d84f556911636"/></dir><file name="Post.php" hash="90516c1b09928be401916a33c368a236"/><file name="Setup.php" hash="81d4730bb23b8139cb9e6dc654d366b8"/><dir name="Term"><file name="Collection.php" hash="7089f8aeb441ebac4601fb9e070e74b2"/></dir><file name="Term.php" hash="85f42eaa2f05be6f2cd3fc5268e93559"/><dir name="User"><file name="Collection.php" hash="16e628d55a0fa01747e01a695f709e00"/></dir><file name="User.php" hash="2f3a904ba1a03a9ea36e628059d4b73f"/></dir><dir name="Sitemap"><file name="Sitemap.php" hash="bca54ec7d86e4920e50da0b587c4b99e"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Autologin.php" hash="7d2664238443b07ea685ef3df01f5eff"/><file name="Encrypted.php" hash="520824f9a5533cf790aa8b5bb136e7c9"/></dir><dir name="Source"><file name="Menu.php" hash="9caaf56ff64f3858d4e206c6335c37ec"/><dir name="Social"><dir name="Media"><file name="Service.php" hash="61f66b78e2a122f07a9307b273b62feb"/></dir></dir></dir></dir></dir><dir name="Term"><file name="Taxonomy.php" hash="e2976a1b2c1b7cb7199b88a73dd78ea9"/></dir><file name="Term.php" hash="c185736836c876efa91bd29ee5cf7110"/><file name="User.php" hash="0f75d9705aaa0b690217721a61ecd3e6"/></dir><file name="change-log.txt" hash="1eabdd06602ca659048c07ad29e7adb8"/><dir name="controllers"><dir name="Adminhtml"><dir name="Wordpress"><file name="AssociationsController.php" hash="304218bd303b88e788487c2f2e2cbb04"/></dir><file name="WordpressController.php" hash="3c40d9782f0a970798574f4a3eb4235a"/></dir><file name="AjaxController.php" hash="410a9d84692fabfc3e846598a772c803"/><file name="ArchiveController.php" hash="e9ec7c6d89501c9efd8a33db2170bcb9"/><file name="AuthorController.php" hash="8056629849e92b754e6eb85e1537565a"/><file name="IndexController.php" hash="a5fee64e05a8a14babb50e95eeff0906"/><file name="PostController.php" hash="2f560a9c10209e3c95e8e7689df018b6"/><file name="SearchController.php" hash="fceba89823f011517bbf48a04c4bb361"/><file name="TermController.php" hash="8bc39e2dca19b04ac52f7e320d41bc8c"/></dir><dir name="etc"><file name="adminhtml.xml" hash="22061db5a80dc2fa952a64778a346dfe"/><file name="config.xml" hash="f494382d15c9ff0b1585b801f29f5c6e"/><file name="fishpig.xml" hash="e24400143b6d480ac4a501f0fdc32493"/><file name="system.xml" hash="8dce70be3871210de82104253045535a"/><file name="widget.xml" hash="b7b586ef3d869177a43e8e87a04b1222"/></dir><dir name="sql"><dir name="wordpress_setup"><file name="mysql4-install-0.1.0.php" hash="771dbb85a173051acc83b506fe67067d"/><file name="mysql4-upgrade-2.5.9.0-2.5.9.1.php" hash="a295aaeb8aa45d84bc1541fdac70d7ad"/><file name="mysql4-upgrade-3.2.0.0-3.2.0.1.php" hash="504da139c47e676666ac2b4210916d5f"/></dir></dir><dir name="Addon"><dir name="WordPressSEO"><dir name="Helper"><file name="Data.php" hash="0bdb85515554de5c7eba0828099f9ac2"/></dir><dir name="etc"><file name="config.xml" hash="d1dde914497c73e0523b108a7bbd8841"/></dir></dir><dir name="Yarpp"><dir name="Block"><dir name="Sidebar"><file name="Widget.php" hash="98d5edda7378a0514f00950816f768e8"/></dir></dir><dir name="etc"><file name="config.xml" hash="746bd41d16f1d2402a35e64f12786520"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="wordpress.xml" hash="025b215d245317fbc619ae5677979339"/></dir><dir name="template"><dir name="wordpress"><file name="integration-tests.phtml" hash="6f7030e821d62e240675ba6831966aa7"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="wordpress.xml" hash="75f001e822e2d2a7213b531ae7066a97"/></dir><dir name="template"><dir name="wordpress"><dir><dir name="archive"><file name="view.phtml" hash="7243f533d0357685aa5cf8c115b148a1"/></dir><dir name="author"><file name="view.phtml" hash="1e52d2c16276406553a8d48c75eeb306"/></dir><dir name="post"><dir name="associated"><file name="products.phtml" hash="0b635b1cb6eab98aaa641a1f27bbe5fa"/></dir><file name="associated.phtml" hash="80e9593a788da42a0fcbe24f53c27cb5"/><dir name="list"><dir name="renderer"><file name="default.phtml" hash="68d65457c905c7cdf85c8fb93473e2f0"/></dir><file name="wrapper.phtml" hash="19549d50d36482dee642d80b7a932765"/></dir><file name="list.phtml" hash="19d0395edf4b1a3d787be50b61a487f1"/><file name="meta.phtml" hash="5eb9a91335c357ec77717495cbc513c6"/><dir name="view"><dir name="comment"><file name="form.phtml" hash="c22607dc13b7cc294da7c6d605925893"/><file name="wrapper.phtml" hash="dd6980b9b432634d2c63b03e635f09a4"/></dir><file name="comments.phtml" hash="05668659c30bf78727bbedfdbd49c6ac"/><file name="page.phtml" hash="a693be74e920be8e04ff726cf16abaee"/></dir><file name="view.phtml" hash="3c15b1c39adb91857cd5d88a7550b600"/></dir><dir name="search"><file name="result.phtml" hash="263b739fe9302e6e5d815f3bf2279b2e"/></dir><dir name="shortcode"><file name="gallery.phtml" hash="ff7e796c4e511e2f27a823be104a4374"/><file name="product.phtml" hash="7fb95222834907fac31477e5934ceedc"/></dir><dir name="sidebar"><dir name="widget"><file name="abstract.phtml" hash="1979cff1c6a6337b6980f62c2cd89577"/><file name="archives.phtml" hash="6f7d3e877b22cac88b130ef2b68fe286"/><file name="calendar.phtml" hash="fe0dca9946a9d0bd82a6114786c865c9"/><file name="categories.phtml" hash="4340111e138cd3f9c47c48ea7736013e"/><file name="categoryposts.phtml" hash="8dad6f1026313e2a327d8fd4fa4a786d"/><file name="comments.phtml" hash="184e6434d5a7f23f83a03cb21b0d8083"/><file name="image.phtml" hash="c7657307809b127e252764c911bb9a1e"/><file name="instagram.phtml" hash="bd37446ccf42a6e0dbb4b6c63edc3533"/><file name="links.phtml" hash="cf40ee224503d5eaf48c9494023e22c0"/><file name="menu.phtml" hash="7029074d6173761261ca6c30fcc194bb"/><file name="meta.phtml" hash="47c351bac53537f1536d2e2c13f069e7"/><file name="pages.phtml" hash="f3bbea9d984360f236ceb78f781d6199"/><file name="posts.phtml" hash="27c09919df79d50909c0fcb90c374cba"/><file name="rss.phtml" hash="ad8ad715f82a23540356920d76f8b74a"/><file name="search.phtml" hash="bb5846228cae41d0d71cc97b3e4a28a6"/><file name="tagcloud.phtml" hash="4978442189cf818ae4d57207ba642615"/><dir name="taxonomy"><file name="renderer.phtml" hash="41af9ae08f1aee29818c764b0bc1a256"/></dir><file name="taxonomy.phtml" hash="13a7cce60b3aeddee57484c237db697a"/><file name="text.phtml" hash="08f656c30d7e072f7f2c29e04743129c"/></dir></dir><dir name="term"><file name="view.phtml" hash="6c1a13cb279b137e0d915ea3e17d90fd"/></dir></dir><file name="homepage.phtml" hash="05856d1c44562bfc3d64f205f70c1de0"/><file name="protected.phtml" hash="31f5a14ccba3f7b69e3a4075c53bc539"/><file name="sidebar.phtml" hash="c6268b9ec5074662b8125d5aabc05b0c"/></dir><dir name="wordpress-addons"><dir name="yarpp"><file name="related.phtml" hash="08ee87974b6762c3b350464f76b85c91"/><dir name="sidebar"><file name="widget.phtml" hash="821b64bb40296aa65314ddfe7ed232f4"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="app"><dir name="etc"><dir name="modules"><file name="Fishpig_Wordpress.xml" hash="f7947cc170ce6bf1ab7a21e58ac48d31"/></dir></dir></dir><dir name="js"><dir name="fishpig"><dir name="wordpress"><file name="comments.js" hash="a3c5286844ccb293a9976bac46605289"/><file name="update.js" hash="3df101b798daa5248a279989f7fe2ff9"/><file name="search.js" hash="5631d5149f4fc145db04864b1527b2a8"/><file name="lightbox.js" hash="bb7c9e300dc33d399ca72039e727e266"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="wordpress"><file name="styles.css" hash="8e85ffde94798850dcf5c70cdd06ad00"/><file name="ajax-loader.gif" hash="a51c5608d01acf32df728f299767f82b"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="cs_CZ"><file name="Fishpig_Wordpress.csv" hash="416afbb6426b717f2cb37c99daf77adc"/></dir><dir name="da_DK"><file name="Fishpig_Wordpress.csv" hash="d4c4803edc751baf3c7726afc6c5568f"/></dir><dir name="de_DE"><file name="Fishpig_Wordpress.csv" hash="6479677778d79a8932597bfc4a23cc20"/></dir><dir name="es_ES"><file name="Fishpig_Wordpress.csv" hash="c3397d271f0c75c1dbe1b0878f404df4"/></dir><dir name="fr_FR"><file name="Fishpig_Wordpress.csv" hash="605d8ea12a5bbb3448a360bf46c9572a"/></dir><dir name="it_IT"><file name="Fishpig_Wordpress.csv" hash="60208176d94e30400d260494d440cb3c"/></dir><dir name="ja_JP"><file name="Fishpig_Wordpress.csv" hash="3fe07f48ab2e9cc1d899264f3a9cef52"/></dir><dir name="nb_NO"><file name="Fishpig_Wordpress.csv" hash="b0d5de887b5518beb1db976ca72dd2e5"/></dir><dir name="nl_NL"><file name="Fishpig_Wordpress.csv" hash="c8f0fb68fe1e207a554b9f49b82c01ea"/></dir><dir name="nn_NO"><file name="Fishpig_Wordpress.csv" hash="bfcb347e03369a2539f0217541badf4c"/></dir><dir name="pl_PL"><file name="Fishpig_Wordpress.csv" hash="0bd6f726386f5feaf89725453460a0ca"/></dir><dir name="pt_BR"><file name="Fishpig_Wordpress.csv" hash="92f644b350b828fa44f6ba9a82df0fe2"/></dir><dir name="pt_PT"><file name="Fishpig_Wordpress.csv" hash="a222f515815ae5effe2ce57f53072c90"/></dir><dir name="ru_RU"><file name="Fishpig_Wordpress.csv" hash="b534ad6f293419af26b045f3348a1a83"/></dir><dir name="sv_SE"><file name="Fishpig_Wordpress.csv" hash="c790bfe6a98530de1f4fe47ba6d8e113"/></dir><dir name="zh_CN"><file name="Fishpig_Wordpress.csv" hash="caef42e20155f23aafb4421ee46979ff"/></dir><dir name="en_GB"><file name="Fishpig_Wordpress.csv" hash="1e1b37fed9d6f60e9ea8129fac657953"/></dir><dir name="en_US"><file name="Fishpig_Wordpress.csv" hash="1e1b37fed9d6f60e9ea8129fac657953"/></dir><dir name="sl_SI"><file name="Fishpig_Wordpress.csv" hash="f5d57703149cc50dfaed42c2c390b7d4"/></dir><dir name="tr_TR"><file name="Fishpig_Wordpress.csv" hash="8f31cfca1e7ab452b404ec29a4b782bf"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
18
  </package>