Admin Columns - Version 3.0

Version Description

Release Date: May 3rd, 2017

  • [Refactor] Complete refactor of core code. Please read Upgrading from v3 to v4
  • [Improved] Column will now have a default empty value (dash character)
  • [Improved] A column can now use an ajax callback for displaying it's contents (with AC_Column_AjaxValue interface)
  • [Improved] Updated the User Interface
  • [Improved] Using dashicons instead of image icons
  • [Improved] Action column now always is the primary column
  • [Improved] Heading structure in Admin is now correct
  • [Improved] Page Template column supports post types (since WP 4.7)
  • [Improved] Improved Custom Field column types
  • [Added] New user column added: Author name
  • [Added] New user column added: Show Toolbar
  • [Added] New column for shortlink added
  • [Added] Filter for suppressing admin notices
  • [Added] New helpers added for array, date, formfield, icon, image, post, string ,taxonomy and user. Helpers can be accessed by using 'ac_helper()->array()'' etc
  • [Added] Filter for enabling a 'clear all columns' button to the setting page. 'ac/settings/enable_clear_columns_button'
  • [Added] New method for singleton for Admin Columns main class. 'ac()'
  • [Fixed] Comment Response column is no longer displayed in the table when viewing "Comments On".
Download this release

Release Info

Developer tschutter
Plugin Icon 128x128 Admin Columns
Version 3.0
Comparing to
See all releases

Code changes from version 2.5.6.4 to 3.0

Files changed (370) hide show
  1. api.php +180 -0
  2. assets/css/admin-column.css +0 -1237
  3. assets/css/admin-column.min.css +0 -1
  4. assets/css/admin-general.css +203 -0
  5. assets/css/admin-general.min.css +1 -0
  6. assets/css/admin-page-addons.css +103 -0
  7. assets/css/admin-page-addons.min.css +1 -0
  8. assets/css/admin-page-columns.css +861 -0
  9. assets/css/admin-page-columns.min.css +1 -0
  10. assets/css/admin-page-help.css +11 -0
  11. assets/css/admin-page-help.min.css +1 -0
  12. assets/css/admin-page-settings.css +4 -0
  13. assets/css/admin-page-settings.min.css +0 -0
  14. assets/css/admin-welcome.css +81 -0
  15. assets/css/admin-welcome.min.css +1 -0
  16. assets/css/column.css +0 -177
  17. assets/css/column.min.css +0 -1
  18. assets/css/message.css +44 -0
  19. assets/css/message.min.css +1 -0
  20. assets/css/plugin-screen.css +15 -0
  21. assets/css/plugin-screen.min.css +1 -0
  22. assets/css/table.css +421 -0
  23. assets/css/table.min.css +1 -0
  24. assets/fonts/cpac_icons.eot +0 -0
  25. assets/fonts/cpac_icons.ttf +0 -0
  26. assets/fonts/cpac_icons.woff +0 -0
  27. assets/images/{logo-woocommerce.png → addons/acf-icon.png} +0 -0
  28. assets/images/addons/acf.png +0 -0
  29. assets/images/addons/pods-icon.png +0 -0
  30. assets/images/addons/pods.png +0 -0
  31. assets/images/addons/toolset-types-icon-alt.png +0 -0
  32. assets/images/addons/toolset-types-icon.png +0 -0
  33. assets/images/addons/toolset-types.png +0 -0
  34. assets/images/addons/woocommerce-icon.png +0 -0
  35. assets/images/addons/woocommerce.png +0 -0
  36. assets/images/drag.svg +39 -0
  37. assets/images/drag_2x.png +0 -0
  38. assets/images/get_the_addon.png +0 -0
  39. assets/images/logo-acf.png +0 -0
  40. assets/js/admin-columns.js +0 -40
  41. assets/js/admin-columns.min.js +0 -1
  42. assets/js/admin-general.js +116 -0
  43. assets/js/admin-general.min.js +1 -0
  44. assets/js/admin-page-columns.js +936 -0
  45. assets/js/admin-page-columns.min.js +1 -0
  46. assets/js/admin-settings.js +0 -876
  47. assets/js/admin-settings.min.js +0 -1
  48. assets/js/message.js +26 -0
  49. assets/js/message.min.js +1 -0
  50. assets/js/table.js +162 -0
  51. assets/js/table.min.js +1 -0
  52. classes/API.php +166 -0
  53. classes/Addon.php +349 -0
  54. classes/Addon/ACF.php +49 -0
  55. classes/Addon/Pods.php +33 -0
  56. classes/Addon/Types.php +33 -0
  57. classes/Addon/WooCommerce.php +32 -0
  58. classes/Addons.php +109 -0
  59. classes/Admin.php +171 -0
  60. classes/Admin/Help.php +43 -0
  61. classes/Admin/Help/Basics.php +37 -0
  62. classes/Admin/Help/CustomField.php +76 -0
  63. classes/Admin/Help/Introduction.php +26 -0
  64. classes/Admin/Page.php +132 -0
  65. classes/Admin/Page/Addons.php +432 -0
  66. classes/Admin/Page/Columns.php +897 -0
  67. classes/Admin/Page/Help.php +330 -0
  68. classes/Admin/Page/Settings.php +240 -0
  69. classes/{upgrade.php → Admin/Page/Upgrade.php} +372 -411
  70. classes/Admin/Page/Welcome.php +97 -0
  71. classes/Admin/Pages.php +98 -0
  72. classes/Admin/Promo.php +142 -0
  73. classes/Admin/Promo/BlackFriday.php +21 -0
  74. classes/Autoloader.php +124 -0
  75. classes/Collection.php +94 -0
  76. classes/Column.php +446 -0
  77. classes/Column/ActionColumnHelper.php +78 -0
  78. classes/Column/Actions.php +48 -0
  79. classes/Column/AjaxValue.php +16 -0
  80. classes/Column/Comment/Actions.php +16 -0
  81. classes/Column/Comment/Agent.php +27 -0
  82. classes/Column/Comment/Approved.php +27 -0
  83. classes/Column/Comment/Author.php +21 -0
  84. classes/Column/Comment/AuthorAvatar.php +23 -0
  85. classes/Column/Comment/AuthorEmail.php +29 -0
  86. classes/Column/Comment/AuthorIP.php +24 -0
  87. classes/Column/Comment/AuthorName.php +27 -0
  88. classes/Column/Comment/AuthorUrl.php +27 -0
  89. classes/Column/Comment/Comment.php +17 -0
  90. classes/Column/Comment/Date.php +21 -0
  91. classes/Column/Comment/DateGmt.php +35 -0
  92. classes/Column/Comment/Excerpt.php +30 -0
  93. classes/Column/Comment/ID.php +21 -0
  94. classes/Column/Comment/Post.php +31 -0
  95. classes/Column/Comment/ReplyTo.php +35 -0
  96. classes/Column/Comment/Response.php +38 -0
  97. classes/{column/comment/status.php → Column/Comment/Status.php} +38 -50
  98. classes/Column/Comment/Type.php +27 -0
  99. classes/Column/Comment/User.php +32 -0
  100. classes/Column/Comment/WordCount.php +23 -0
  101. classes/Column/CustomField.php +56 -0
  102. classes/{column/link/actions.php → Column/Link/Actions.php} +45 -53
  103. classes/Column/Link/Description.php +23 -0
  104. classes/Column/Link/ID.php +21 -0
  105. classes/Column/Link/Image.php +27 -0
  106. classes/Column/Link/Length.php +23 -0
  107. classes/Column/Link/Notes.php +27 -0
  108. classes/Column/Link/Owner.php +32 -0
  109. classes/Column/Link/Rss.php +23 -0
  110. classes/Column/Link/Target.php +23 -0
  111. classes/Column/Media/Actions.php +16 -0
  112. classes/Column/Media/AlternateText.php +29 -0
  113. classes/Column/Media/AttachedTo.php +31 -0
  114. classes/Column/Media/Author.php +11 -0
  115. classes/Column/Media/AuthorName.php +14 -0
  116. classes/Column/Media/AvailableSizes.php +85 -0
  117. classes/Column/Media/Caption.php +25 -0
  118. classes/Column/Media/Comments.php +21 -0
  119. classes/Column/Media/Date.php +21 -0
  120. classes/Column/Media/Description.php +19 -0
  121. classes/Column/Media/Dimensions.php +40 -0
  122. classes/Column/Media/ExifData.php +33 -0
  123. classes/Column/Media/FileName.php +29 -0
  124. classes/Column/Media/FileSize.php +30 -0
  125. classes/Column/Media/FullPath.php +25 -0
  126. classes/Column/Media/Height.php +31 -0
  127. classes/Column/Media/ID.php +21 -0
  128. classes/Column/Media/Meta.php +21 -0
  129. classes/Column/Media/MimeType.php +25 -0
  130. classes/Column/Media/Parent.php +21 -0
  131. classes/Column/Media/Taxonomy.php +11 -0
  132. classes/Column/Media/Title.php +17 -0
  133. classes/Column/Media/Width.php +31 -0
  134. classes/Column/Meta.php +74 -0
  135. classes/Column/Placeholder.php +52 -0
  136. classes/Column/Post/Actions.php +16 -0
  137. classes/Column/Post/Attachment.php +46 -0
  138. classes/Column/Post/AttachmentCount.php +31 -0
  139. classes/Column/Post/Author.php +21 -0
  140. classes/Column/Post/AuthorName.php +32 -0
  141. classes/Column/Post/BeforeMoreTag.php +37 -0
  142. classes/Column/Post/Categories.php +29 -0
  143. classes/Column/Post/CommentCount.php +32 -0
  144. classes/Column/Post/CommentStatus.php +34 -0
  145. classes/Column/Post/Comments.php +21 -0
  146. classes/Column/Post/Content.php +25 -0
  147. classes/Column/Post/Date.php +17 -0
  148. classes/Column/Post/DatePublished.php +27 -0
  149. classes/Column/Post/Depth.php +31 -0
  150. classes/Column/Post/EstimatedReadingTime.php +35 -0
  151. classes/Column/Post/Excerpt.php +35 -0
  152. classes/Column/Post/FeaturedImage.php +62 -0
  153. classes/Column/Post/Formats.php +37 -0
  154. classes/Column/Post/ID.php +21 -0
  155. classes/Column/Post/LastModifiedAuthor.php +28 -0
  156. classes/Column/Post/Modified.php +28 -0
  157. classes/Column/Post/Order.php +29 -0
  158. classes/Column/Post/PageTemplate.php +42 -0
  159. classes/Column/Post/Parent.php +37 -0
  160. classes/Column/Post/Path.php +27 -0
  161. classes/Column/Post/Permalink.php +25 -0
  162. classes/Column/Post/PingStatus.php +31 -0
  163. classes/Column/Post/Roles.php +42 -0
  164. classes/{column/post/shortcodes.php → Column/Post/Shortcodes.php} +61 -68
  165. classes/Column/Post/Shortlink.php +27 -0
  166. classes/Column/Post/Slug.php +25 -0
  167. classes/Column/Post/Status.php +39 -0
  168. classes/Column/Post/Sticky.php +40 -0
  169. classes/Column/Post/Tags.php +29 -0
  170. classes/Column/Post/Taxonomy.php +19 -0
  171. classes/Column/Post/Title.php +21 -0
  172. classes/Column/Post/TitleRaw.php +25 -0
  173. classes/Column/Post/WordCount.php +25 -0
  174. classes/Column/Taxonomy.php +46 -0
  175. classes/Column/UsedByMenu.php +73 -0
  176. classes/Column/User/Actions.php +16 -0
  177. classes/Column/User/CommentCount.php +29 -0
  178. classes/Column/User/Description.php +25 -0
  179. classes/Column/User/DisplayName.php +27 -0
  180. classes/Column/User/Email.php +17 -0
  181. classes/Column/User/FirstName.php +29 -0
  182. classes/Column/User/ID.php +25 -0
  183. classes/Column/User/LastName.php +29 -0
  184. classes/Column/User/Name.php +17 -0
  185. classes/Column/User/Nickname.php +29 -0
  186. classes/Column/User/PostCount.php +46 -0
  187. classes/Column/User/Posts.php +17 -0
  188. classes/Column/User/Registered.php +29 -0
  189. classes/Column/User/RichEditing.php +28 -0
  190. classes/Column/User/Role.php +35 -0
  191. classes/Column/User/ShowToolbar.php +31 -0
  192. classes/Column/User/Url.php +27 -0
  193. classes/Column/User/Username.php +17 -0
  194. classes/Column/WooCommercePlaceholder.php +16 -0
  195. classes/Groups.php +154 -0
  196. classes/Helper.php +36 -0
  197. classes/Helper/Array.php +135 -0
  198. classes/Helper/Date.php +169 -0
  199. classes/Helper/File.php +31 -0
  200. classes/Helper/Html.php +364 -0
  201. classes/Helper/Icon.php +73 -0
  202. classes/Helper/Image.php +246 -0
  203. classes/Helper/Network.php +38 -0
  204. classes/Helper/Post.php +118 -0
  205. classes/Helper/String.php +279 -0
  206. classes/Helper/Taxonomy.php +136 -0
  207. classes/Helper/User.php +144 -0
  208. classes/ListScreen.php +839 -0
  209. classes/ListScreen/Comment.php +70 -0
  210. classes/ListScreen/Link.php +42 -0
  211. classes/ListScreen/Media.php +49 -0
  212. classes/ListScreen/Post.php +69 -0
  213. classes/ListScreen/User.php +67 -0
  214. classes/ListScreenPost.php +56 -0
  215. classes/Meta/Query.php +470 -0
  216. classes/Meta/QueryColumn.php +24 -0
  217. classes/Notice/Plugin.php +182 -0
  218. classes/Notice/Review.php +147 -0
  219. classes/PluginInformation.php +97 -0
  220. classes/Settings/Column.php +374 -0
  221. classes/Settings/Column/ActionIcons.php +52 -0
  222. classes/Settings/Column/BeforeAfter.php +99 -0
  223. classes/Settings/Column/CharacterLimit.php +57 -0
  224. classes/Settings/Column/CommentCount.php +92 -0
  225. classes/Settings/Column/CustomField.php +113 -0
  226. classes/Settings/Column/CustomFieldType.php +284 -0
  227. classes/Settings/Column/Date.php +187 -0
  228. classes/Settings/Column/ExifData.php +92 -0
  229. classes/Settings/Column/Image.php +195 -0
  230. classes/Settings/Column/Label.php +77 -0
  231. classes/Settings/Column/LinkLabel.php +63 -0
  232. classes/Settings/Column/LinkToMenu.php +76 -0
  233. classes/Settings/Column/Message.php +42 -0
  234. classes/Settings/Column/Meta.php +145 -0
  235. classes/Settings/Column/Password.php +61 -0
  236. classes/Settings/Column/PathScope.php +89 -0
  237. classes/Settings/Column/Post.php +109 -0
  238. classes/Settings/Column/PostLink.php +96 -0
  239. classes/Settings/Column/PostType.php +64 -0
  240. classes/Settings/Column/Separator.php +74 -0
  241. classes/Settings/Column/Taxonomy.php +51 -0
  242. classes/Settings/Column/Term.php +83 -0
  243. classes/Settings/Column/Toggle.php +24 -0
  244. classes/Settings/Column/Type.php +131 -0
  245. classes/Settings/Column/User.php +185 -0
  246. classes/Settings/Column/Width.php +133 -0
  247. classes/Settings/Column/WordLimit.php +70 -0
  248. classes/Settings/Column/WordsPerMinute.php +124 -0
  249. classes/Settings/Form/Element.php +289 -0
  250. classes/Settings/Form/Element/Checkbox.php +88 -0
  251. classes/Settings/Form/Element/Input.php +57 -0
  252. classes/Settings/Form/Element/Radio.php +13 -0
  253. classes/Settings/Form/Element/Select.php +94 -0
  254. classes/Settings/FormatCollectionInterface.php +17 -0
  255. classes/Settings/FormatValueInterface.php +17 -0
  256. classes/Settings/HeaderInterface.php +14 -0
  257. classes/TableScreen.php +433 -0
  258. classes/ThirdParty/ACF.php +33 -0
  259. classes/ThirdParty/NinjaForms.php +23 -0
  260. classes/ThirdParty/WPML.php +72 -0
  261. classes/ThirdParty/WPMLColumn.php +36 -0
  262. classes/ThirdParty/WooCommerce.php +23 -0
  263. classes/View.php +122 -0
  264. classes/ViewInterface.php +23 -0
  265. classes/addons.php +0 -416
  266. classes/column.php +0 -1661
  267. classes/column/acf-placeholder.php +0 -23
  268. classes/column/actions.php +0 -192
  269. classes/column/comment/ID.php +0 -29
  270. classes/column/comment/actions.php +0 -108
  271. classes/column/comment/agent.php +0 -37
  272. classes/column/comment/approved.php +0 -39
  273. classes/column/comment/author-avatar.php +0 -31
  274. classes/column/comment/author-email.php +0 -38
  275. classes/column/comment/author-ip.php +0 -37
  276. classes/column/comment/author-name.php +0 -23
  277. classes/column/comment/author-url.php +0 -37
  278. classes/column/comment/author.php +0 -37
  279. classes/column/comment/date-gmt.php +0 -46
  280. classes/column/comment/date.php +0 -46
  281. classes/column/comment/excerpt.php +0 -48
  282. classes/column/comment/post.php +0 -89
  283. classes/column/comment/reply-to.php +0 -44
  284. classes/column/comment/type.php +0 -26
  285. classes/column/comment/user.php +0 -32
  286. classes/column/comment/word-count.php +0 -32
  287. classes/column/custom-field.php +0 -410
  288. classes/column/default.php +0 -37
  289. classes/column/link/ID.php +0 -30
  290. classes/column/link/description.php +0 -32
  291. classes/column/link/image.php +0 -46
  292. classes/column/link/length.php +0 -32
  293. classes/column/link/notes.php +0 -44
  294. classes/column/link/owner.php +0 -40
  295. classes/column/link/rss.php +0 -32
  296. classes/column/link/target.php +0 -32
  297. classes/column/media/ID.php +0 -30
  298. classes/column/media/actions.php +0 -75
  299. classes/column/media/alternate-text.php +0 -39
  300. classes/column/media/attached-to.php +0 -44
  301. classes/column/media/available-sizes.php +0 -60
  302. classes/column/media/caption.php +0 -39
  303. classes/column/media/description.php +0 -38
  304. classes/column/media/dimensions.php +0 -32
  305. classes/column/media/exif-data.php +0 -100
  306. classes/column/media/file-name.php +0 -44
  307. classes/column/media/file-size.php +0 -52
  308. classes/column/media/full-path.php +0 -111
  309. classes/column/media/height.php +0 -28
  310. classes/column/media/mime-type.php +0 -39
  311. classes/column/media/width.php +0 -27
  312. classes/column/post/ID.php +0 -37
  313. classes/column/post/actions.php +0 -64
  314. classes/column/post/attachment-count.php +0 -34
  315. classes/column/post/attachment.php +0 -71
  316. classes/column/post/author-name.php +0 -101
  317. classes/column/post/before-moretag.php +0 -60
  318. classes/column/post/comment-count.php +0 -102
  319. classes/column/post/comment-status.php +0 -53
  320. classes/column/post/content.php +0 -47
  321. classes/column/post/date-published.php +0 -55
  322. classes/column/post/depth.php +0 -43
  323. classes/column/post/estimated-reading-time.php +0 -115
  324. classes/column/post/excerpt.php +0 -52
  325. classes/column/post/featured-image.php +0 -71
  326. classes/column/post/formats.php +0 -53
  327. classes/column/post/last-modified-author.php +0 -60
  328. classes/column/post/modified.php +0 -39
  329. classes/column/post/order.php +0 -43
  330. classes/column/post/page-template.php +0 -44
  331. classes/column/post/parent.php +0 -55
  332. classes/column/post/path.php +0 -38
  333. classes/column/post/permalink.php +0 -81
  334. classes/column/post/ping-status.php +0 -51
  335. classes/column/post/roles.php +0 -44
  336. classes/column/post/slug.php +0 -39
  337. classes/column/post/status.php +0 -49
  338. classes/column/post/sticky.php +0 -44
  339. classes/column/post/title-raw.php +0 -39
  340. classes/column/post/word-count.php +0 -45
  341. classes/column/taxonomy.php +0 -91
  342. classes/column/used-by-menu.php +0 -144
  343. classes/column/user/ID.php +0 -36
  344. classes/column/user/actions.php +0 -52
  345. classes/column/user/comment-count.php +0 -40
  346. classes/column/user/description.php +0 -46
  347. classes/column/user/display-name.php +0 -37
  348. classes/column/user/first-name.php +0 -38
  349. classes/column/user/last-name.php +0 -38
  350. classes/column/user/nickname.php +0 -39
  351. classes/column/user/post-count.php +0 -99
  352. classes/column/user/registered.php +0 -53
  353. classes/column/user/rich-editing.php +0 -33
  354. classes/column/user/url.php +0 -38
  355. classes/column/wc-placeholder.php +0 -24
  356. classes/review_notice.php +0 -187
  357. classes/settings.php +0 -1179
  358. classes/storage_model.php +0 -1153
  359. classes/storage_model/comment.php +0 -80
  360. classes/storage_model/link.php +0 -63
  361. classes/storage_model/media.php +0 -90
  362. classes/storage_model/post.php +0 -249
  363. classes/storage_model/user.php +0 -120
  364. classes/third_party.php +0 -5
  365. classes/third_party/acf.php +0 -22
  366. classes/third_party/ninja_forms.php +0 -19
  367. classes/third_party/woocommerce.php +0 -11
  368. classes/third_party/wpml.php +0 -109
  369. classes/utility.php +0 -145
  370. codepress-admin-columns.php +152 -651
api.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @return bool True when Admin Columns Pro plugin is activated.
9
+ */
10
+ function ac_is_pro_active() {
11
+ return function_exists( 'ACP' );
12
+ }
13
+
14
+ /**
15
+ * Get the url where the Admin Columns website is hosted
16
+ *
17
+ * @return string
18
+ */
19
+ function ac_get_site_url( $path = '' ) {
20
+ $url = 'https://www.admincolumns.com';
21
+
22
+ if ( ! empty( $path ) ) {
23
+ $url .= '/' . trim( $path, '/' ) . '/';
24
+ }
25
+
26
+ return $url;
27
+ }
28
+
29
+ /**
30
+ * Url with utm tags
31
+ *
32
+ * @param string $path
33
+ * @param string $utm_medium
34
+ * @param string $utm_content
35
+ *
36
+ * @return string
37
+ */
38
+ function ac_get_site_utm_url( $path, $utm_medium, $utm_content = null, $utm_campaign = false ) {
39
+ $url = ac_get_site_url( $path );
40
+
41
+ if ( ! $utm_campaign ) {
42
+ $utm_campaign = 'plugin-installation';
43
+ }
44
+
45
+ $args = array(
46
+ // Referrer: plugin
47
+ 'utm_source' => 'plugin-installation',
48
+
49
+ // Specific promotions or sales
50
+ 'utm_campaign' => $utm_campaign,
51
+
52
+ // Marketing medium: banner, support documentation, email
53
+ 'utm_medium' => $utm_medium,
54
+
55
+ // Used for differentiation of medium
56
+ 'utm_content' => $utm_content,
57
+ );
58
+
59
+ $args = array_map( 'sanitize_key', $args );
60
+
61
+ return add_query_arg( $args, $url );
62
+ }
63
+
64
+ /**
65
+ * Admin Columns Twitter username
66
+ *
67
+ * @return string
68
+ */
69
+ function ac_get_twitter_handle() {
70
+ return 'admincolumns';
71
+ }
72
+
73
+ /**
74
+ * Simple helper methods for AC_Column objects
75
+ *
76
+ * @since 3.0
77
+ */
78
+ function ac_helper() {
79
+ return AC()->helper();
80
+ }
81
+
82
+ /**
83
+ * @since 3.0
84
+ * @return bool True when a minimum version of Admin Columns Pro plugin is activated.
85
+ */
86
+ function ac_is_version_gte( $version ) {
87
+ return version_compare( AC()->get_version(), $version, '>=' );
88
+ }
89
+
90
+ /**
91
+ * Returns row actions for the WP_List_Tables
92
+ *
93
+ * @return AC_Column_ActionColumnHelper
94
+ */
95
+ function ac_action_column_helper() {
96
+ return AC_Column_ActionColumnHelper::instance();
97
+ }
98
+
99
+ /**
100
+ * Manually set the columns for a list screen
101
+ * This overrides the database settings and thus renders the settings screen for this list screen useless
102
+ *
103
+ * If you like to register a column of your own please have a look at our documentation.
104
+ * We also have a free start-kit available, which contains all the necessary files.
105
+ *
106
+ * Documentation: https://www.admincolumns.com/documentation/developer-docs/creating-new-column-type/
107
+ * Starter-kit: https://github.com/codepress/ac-column-template/
108
+ *
109
+ * @since 2.2
110
+ *
111
+ * @param string|array $list_screen_key List screen key or keys
112
+ * @param array $column_data
113
+ */
114
+ function ac_register_columns( $list_screen_keys, $column_data ) {
115
+ AC()->api()->load_columndata( $list_screen_keys, $column_data );
116
+ }
117
+
118
+ /**
119
+ * Deprecated functions
120
+ */
121
+
122
+ /**
123
+ * Is doing ajax
124
+ *
125
+ * @since 2.3.4
126
+ */
127
+ function cac_is_doing_ajax() {
128
+ _deprecated_function( __FUNCTION__, '3.0' );
129
+
130
+ return AC()->table_screen()->get_list_screen_when_doing_quick_edit() || ( AC()->is_doing_ajax() && isset( $_REQUEST['list_screen'] ) );
131
+ }
132
+
133
+ /**
134
+ * Is WordPress doing ajax
135
+ *
136
+ * @since 2.5
137
+ */
138
+ function cac_wp_is_doing_ajax() {
139
+ _deprecated_function( __FUNCTION__, '3.0' );
140
+
141
+ return AC()->table_screen()->get_list_screen_when_doing_quick_edit();
142
+ }
143
+
144
+ /**
145
+ * Whether the current screen is the Admin Columns settings screen
146
+ *
147
+ * @since 2.4.8
148
+ *
149
+ * @param string $slug Specifies a page screen (optional)
150
+ *
151
+ * @return bool True if the current screen is the settings screen, false otherwise
152
+ */
153
+ function cac_is_setting_screen( $slug = '' ) {
154
+ _deprecated_function( __FUNCTION__, '3.0', 'AC()->admin()->is_current_page( $slug )' );
155
+
156
+ return AC()->admin()->is_current_page( $slug );
157
+ }
158
+
159
+ /**
160
+ * Returns true if the installed version of WooCommerce is version X or greater
161
+ *
162
+ * @since 2.3.4
163
+ * @deprecated 3.0
164
+ * @return boolean true if the installed version of WooCommerce is version X or greater
165
+ */
166
+ function cpac_is_wc_version_gte( $version = '1.0' ) {
167
+ _deprecated_function( __FUNCTION__, '3.0' );
168
+
169
+ return false;
170
+ }
171
+
172
+ /**
173
+ * @deprecated 3.0
174
+ * @return bool True when Admin Columns Pro plugin is activated.
175
+ */
176
+ function cpac_is_pro_active() {
177
+ _deprecated_function( __FUNCTION__, '3.0', 'ac_is_pro_active' );
178
+
179
+ return ac_is_pro_active();
180
+ }
assets/css/admin-column.css DELETED
@@ -1,1237 +0,0 @@
1
- #cpac a:focus,
2
- #cpac a:active {
3
- outline: none;
4
- }
5
- #cpac h2.cpac-nav-tab-wrapper {
6
- margin-bottom: 10px;
7
- }
8
- /**
9
- * General
10
- * ----------------------------------------------------------------------------
11
- */
12
- #icon-codepress-admin-columns {
13
- background: transparent url('../images/icon.png') no-repeat 0 0;
14
- }
15
- .button.loading {
16
- padding-right: 25px;
17
- position: relative;
18
- }
19
- .rtl .button.loading {
20
- padding-left: 25px;
21
- padding-right: 0;
22
- }
23
- .button.loading span {
24
- position: absolute;
25
- top: 2px;
26
- right: 6px;
27
- background: transparent url('../images/loading.gif') no-repeat right 50%;
28
- width: 16px;
29
- height: 16px;
30
- display: inline-block;
31
- }
32
- .rtl .button.loading span {
33
- left: 6px;
34
- right: auto;
35
- }
36
- /**
37
- * Admin Notice Message
38
- * ----------------------------------------------------------------------------
39
- */
40
- .cpac_message.error.warning {
41
- border-left: 4px solid #ffba00;
42
- }
43
- .ajax-message {
44
- display: none;
45
- }
46
- /**
47
- * Dashicons used on list screens
48
- * ----------------------------------------------------------------------------
49
- */
50
- .cpac-column .comment-grey-bubble {
51
- height: 16px;
52
- width: 16px;
53
- }
54
- .cpac-column .comment-grey-bubble:before {
55
- content: '\f101';
56
- font: normal 20px/0.5 'dashicons';
57
- speak: none;
58
- display: inline-block;
59
- padding: 0;
60
- top: 4px;
61
- left: 0;
62
- position: relative;
63
- vertical-align: top;
64
- -webkit-font-smoothing: antialiased;
65
- -moz-osx-font-smoothing: grayscale;
66
- text-decoration: none !important;
67
- }
68
- .rtl .cpac-column .comment-grey-bubble:before {
69
- right: 0;
70
- left: auto;
71
- }
72
- /**
73
- * Menu
74
- * ----------------------------------------------------------------------------
75
- */
76
- .cpac-menu {
77
- clear: both;
78
- overflow: hidden;
79
- margin-bottom: 10px;
80
- }
81
- .cpac-menu .subsubsub {
82
- white-space: normal;
83
- margin-right: 14px;
84
- width: 100%;
85
- margin: 0 14px 0 0;
86
- }
87
- .cpac-menu .subsubsub li.first {
88
- font-weight: bold;
89
- min-width: 100px;
90
- }
91
- .cpac-menu label {
92
- font-weight: bold;
93
- margin-right: 5px;
94
- }
95
- .cpac-menu .spinner {
96
- float: none;
97
- margin-top: 0;
98
- margin-left: 0;
99
- }
100
- /**
101
- * Structure
102
- * ----------------------------------------------------------------------------
103
- */
104
- .columns-container {
105
- margin-right: 300px;
106
- max-width: 700px;
107
- }
108
- .columns-container .columns-left {
109
- float: left;
110
- width: 100%;
111
- }
112
- .columns-container .columns-left .column-footer .submit.save {
113
- display: inline-block;
114
- }
115
- .columns-container .columns-left .column-footer .submit.update {
116
- display: none;
117
- }
118
- .columns-container .columns-right {
119
- float: right;
120
- margin-right: -300px;
121
- width: 280px;
122
- }
123
- .columns-container .columns-right .columns-right-inside.fixed {
124
- width: 280px;
125
- }
126
- .columns-container.stored .columns-right .sidebox.form-actions .submit.save {
127
- display: none;
128
- }
129
- .columns-container.stored .columns-right .sidebox.form-actions .submit.update {
130
- display: block;
131
- }
132
- .columns-container.stored .columns-right .sidebox.form-actions .form-reset {
133
- display: block;
134
- }
135
- .columns-container.stored .column-footer .submit.save {
136
- display: none;
137
- }
138
- .columns-container.stored .column-footer .submit.update {
139
- display: inline-block;
140
- }
141
- /**
142
- * UI Sortable Plugin
143
- * ----------------------------------------------------------------------------
144
- */
145
- .ui-sortable-helper {
146
- -webkit-box-shadow: 1px 3px 6px 0px rgba(1, 1, 1, 0.4);
147
- box-shadow: 1px 3px 6px 0px rgba(1, 1, 1, 0.4);
148
- }
149
- .ui-sortable-helper .column-meta {
150
- border-width: 1px;
151
- }
152
- .cpac-placeholder {
153
- visibility: visible !important;
154
- border-top: 1px solid #dfdfdf;
155
- padding: 5px 4px 7px 0;
156
- }
157
- .cpac-placeholder .inner-placeholder {
158
- border: 1px dashed #808080;
159
- background: #eee;
160
- width: 100%;
161
- height: 100%;
162
- }
163
- .cpac-placeholder :first-child {
164
- border: none;
165
- }
166
- .menu {
167
- position: relative;
168
- margin-bottom: 16px;
169
- }
170
- .menu select {
171
- display: inline-block;
172
- margin: 0;
173
- }
174
- .menu .spinner {
175
- display: none;
176
- float: none;
177
- visibility: visible;
178
- margin: 0 0 0 14px;
179
- }
180
- .menu .view-link,
181
- .menu .view-link:active {
182
- display: inline-block;
183
- margin: 0 0 0 12px;
184
- top: 2px;
185
- }
186
- /**
187
- * Columns
188
- * ----------------------------------------------------------------------------
189
- */
190
- .columns-left .cpac-notice {
191
- background: #fff;
192
- border-left: 4px solid #ffba00;
193
- -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
194
- box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
195
- margin-bottom: 15px;
196
- padding: 1px 12px;
197
- }
198
- .columns-left .cpac-boxes .cpac-columns form {
199
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
200
- margin: 0;
201
- }
202
- .columns-left .cpac-boxes.disabled {
203
- opacity: 0.7;
204
- }
205
- .columns-left .cpac-boxes.disabled a.edit-button,
206
- .columns-left .cpac-boxes.disabled a.remove-button,
207
- .columns-left .cpac-boxes.disabled a.clone-button,
208
- .columns-left .cpac-boxes.disabled .column_action {
209
- display: none !important;
210
- }
211
- .columns-left .cpac-boxes.disabled .column-meta td.column_sort {
212
- display: none;
213
- }
214
- .columns-left .cpac-boxes.disabled .meta span {
215
- cursor: default !important;
216
- }
217
- .columns-left .cpac-boxes.disabled .meta span:before {
218
- color: #808080 !important;
219
- }
220
- .columns-left .cpac-boxes.disabled .meta span.off {
221
- opacity: 0.5;
222
- }
223
- .columns-left .cpac-boxes.disabled .column-footer {
224
- display: none;
225
- }
226
- /**
227
- * Column
228
- * ----------------------------------------------------------------------------
229
- */
230
- .cpac-column .column-meta {
231
- border-style: solid;
232
- border-color: #dfdfdf;
233
- border-width: 1px 1px 0;
234
- background: #fcfcfc;
235
- }
236
- .cpac-column .column-meta:nth-child(2n) .column-meta {
237
- background: #f9f9f9;
238
- }
239
- .cpac-column .column-meta img {
240
- margin-right: 3px;
241
- }
242
- .cpac-column .column-meta table {
243
- border: none;
244
- background: transparent;
245
- border-radius: 0;
246
- }
247
- .cpac-column .column-meta table tr td {
248
- vertical-align: top;
249
- height: 18px;
250
- border: none;
251
- padding: 11px 8px;
252
- border-width: 1px 0 0;
253
- border-style: solid;
254
- border-color: transparent;
255
- }
256
- .cpac-column .column-meta table tr td.column_sort {
257
- width: 10px;
258
- background: transparent url('../images/drag.png') no-repeat 8px 8px;
259
- cursor: move;
260
- }
261
- .cpac-column .column-meta table tr td.column_label {
262
- width: 70%;
263
- font-weight: bold;
264
- vertical-align: middle;
265
- position: relative;
266
- }
267
- .cpac-column .column-meta table tr td.column_label .inner {
268
- position: relative;
269
- overflow: hidden;
270
- height: 18px;
271
- }
272
- .cpac-column .column-meta table tr td.column_label .inner > a {
273
- color: #5a5a5a;
274
- padding: 0 4px;
275
- }
276
- .cpac-column .column-meta table tr td.column_label .inner > a:hover {
277
- color: #333333;
278
- }
279
- .cpac-column .column-meta table tr td.column_label .inner > a.edit-button,
280
- .cpac-column .column-meta table tr td.column_label .inner > a.remove-button,
281
- .cpac-column .column-meta table tr td.column_label .inner > a.clone-button {
282
- display: none;
283
- color: #a00;
284
- text-decoration: none;
285
- text-shadow: none;
286
- font-weight: normal;
287
- margin-left: 5px;
288
- font-size: 12px;
289
- }
290
- .cpac-column .column-meta table tr td.column_label .inner > a.edit-button:hover,
291
- .cpac-column .column-meta table tr td.column_label .inner > a.remove-button:hover,
292
- .cpac-column .column-meta table tr td.column_label .inner > a.clone-button:hover {
293
- color: #f00;
294
- }
295
- .cpac-column .column-meta table tr td.column_label .inner > a.edit-button,
296
- .cpac-column .column-meta table tr td.column_label .inner > a.clone-button {
297
- color: #0074a2;
298
- }
299
- .cpac-column .column-meta table tr td.column_label .inner > a.edit-button:hover,
300
- .cpac-column .column-meta table tr td.column_label .inner > a.clone-button:hover {
301
- color: #2ea2cc;
302
- }
303
- .cpac-column .column-meta table tr td.column_label .inner .meta {
304
- display: inline-block;
305
- float: right;
306
- font-weight: normal;
307
- color: #b2b2b2;
308
- font-size: 12px;
309
- }
310
- .cpac-column .column-meta table tr td.column_label .inner .meta span {
311
- cursor: pointer;
312
- }
313
- .cpac-column .column-meta table tr td.column_label .inner .meta span.width {
314
- margin-right: 5px;
315
- cursor: auto;
316
- color: #737373;
317
- }
318
- .cpac-column .column-meta table tr td.column_label .inner .meta span.disabled {
319
- cursor: default;
320
- }
321
- .cpac-column .column-meta table tr td.column_label span.vers {
322
- float: left;
323
- }
324
- .cpac-column .column-meta table tr td.column_type {
325
- width: auto;
326
- min-width: 120px;
327
- text-align: right;
328
- vertical-align: middle;
329
- color: #999999;
330
- padding-right: 0;
331
- }
332
- .cpac-column .column-meta table tr td.column_type .inner {
333
- height: 18px;
334
- overflow: hidden;
335
- }
336
- .cpac-column .column-meta table tr td.column_type .inner a {
337
- color: #999999;
338
- }
339
- .cpac-column .column-meta table tr td.column_edit {
340
- width: 38px;
341
- min-width: 38px;
342
- background: transparent url('../images/arrow.png') no-repeat 23px 18px;
343
- cursor: pointer;
344
- }
345
- .cpac-column .column-meta:hover .column_label .inner > a.remove-button,
346
- .cpac-column .column-meta:hover .column_label .inner > a.edit-button,
347
- .cpac-column .column-meta:hover .column_label .inner > a.clone-button {
348
- display: inline-block;
349
- }
350
- .cpac-column .column-meta span.vers {
351
- padding-top: 2px;
352
- }
353
- .cpac-column .column-meta span.vers .comment-grey-bubble {
354
- float: right;
355
- }
356
- .cpac-column .column-form {
357
- display: none;
358
- border-width: 1px 1px 0;
359
- border-style: solid;
360
- border-color: #dfdfdf;
361
- position: relative;
362
- }
363
- .cpac-column .column-form table {
364
- border: none;
365
- background: #fcfcfc;
366
- }
367
- .cpac-column .column-form table tr.hide {
368
- display: none;
369
- }
370
- .cpac-column .column-form table tr td {
371
- vertical-align: top;
372
- border: none;
373
- padding: 8px;
374
- background: #ffffff;
375
- border-top: 1px solid #F5F5F5;
376
- }
377
- .cpac-column .column-form table tr td select,
378
- .cpac-column .column-form table tr td input[type=text] {
379
- width: 99.95%;
380
- }
381
- .cpac-column .column-form table tr td select.small,
382
- .cpac-column .column-form table tr td input[type=text].small {
383
- width: 100px;
384
- }
385
- .cpac-column .column-form table tr td span.suffix {
386
- line-height: 40px;
387
- color: #808080;
388
- }
389
- .cpac-column .column-form table tr td select optgroup:nth-child(2n) {
390
- background: #F9F9F9;
391
- }
392
- .cpac-column .column-form table tr td.label {
393
- position: relative;
394
- overflow: visible;
395
- background: #f5f5f5;
396
- border-right: 1px solid #E1E1E1;
397
- vertical-align: top;
398
- width: 34%;
399
- border-top: 1px solid #F0F0F0;
400
- }
401
- .cpac-column .column-form table tr td.label label {
402
- font-weight: bold;
403
- color: #333333;
404
- display: block;
405
- position: relative;
406
- }
407
- .cpac-column .column-form table tr td.label p {
408
- color: #666666;
409
- display: block;
410
- font-size: 12px;
411
- font-style: normal;
412
- line-height: 16px;
413
- margin: 0 !important;
414
- }
415
- .cpac-column .column-form table tr td.label p.description {
416
- display: none;
417
- position: absolute;
418
- z-index: 99;
419
- top: 30px;
420
- left: 0;
421
- background: #eaf2fa;
422
- border-radius: 5px;
423
- border: 1px solid #c7d7e2;
424
- padding: 5px 8px !important;
425
- font-weight: normal;
426
- }
427
- .cpac-column .column-form table tr td.label p.description em {
428
- display: block;
429
- color: #999;
430
- }
431
- .cpac-column .column-form table tr td.label .info {
432
- position: absolute;
433
- top: 0;
434
- left: 0;
435
- width: 100%;
436
- height: 100%;
437
- z-index: 1;
438
- }
439
- .cpac-column .column-form table tr td.label .info:before {
440
- position: absolute;
441
- z-index: 1;
442
- right: 10px;
443
- top: 50%;
444
- margin-top: -7px;
445
- content: '';
446
- display: block;
447
- border-radius: 32px;
448
- border: 1px solid #E6E6E6;
449
- width: 12px;
450
- height: 12px;
451
- }
452
- .cpac-column .column-form table tr td.label .info:after {
453
- position: absolute;
454
- z-index: 1;
455
- right: 10px;
456
- top: 50%;
457
- margin-top: -6px;
458
- content: '?';
459
- display: block;
460
- width: 14px;
461
- height: 14px;
462
- color: #E6E6E6;
463
- font: bold 10px Arial;
464
- text-align: center;
465
- vertical-align: middle;
466
- line-height: 14px;
467
- }
468
- .cpac-column .column-form table tr td.input label {
469
- padding-left: 10px;
470
- padding-right: 0;
471
- }
472
- .cpac-column .column-form table tr td.input div.msg {
473
- margin-top: 5px;
474
- display: none;
475
- color: #333;
476
- padding: 6px 8px;
477
- background-color: #ffebe8;
478
- border: 1px solid #fff;
479
- -moz-border-radius: 3px;
480
- -webkit-border-radius: 3px;
481
- border-radius: 3px;
482
- }
483
- .cpac-column .column-form table tr td.input .section {
484
- padding: 12px;
485
- }
486
- .cpac-column .column-form table tr.column_width .input {
487
- position: relative;
488
- }
489
- .cpac-column .column-form table tr.column_width .input div.description {
490
- font-size: 11px;
491
- width: 54px;
492
- position: absolute;
493
- left: 10px;
494
- text-align: middle;
495
- }
496
- .cpac-column .column-form table tr.column_width .input div.description input {
497
- background: #efefef;
498
- border: none;
499
- height: 20px;
500
- line-height: 20px;
501
- text-align: right;
502
- width: 36px;
503
- font-size: 12px;
504
- }
505
- .cpac-column .column-form table tr.column_width .input div.width-slider {
506
- margin-left: 68px;
507
- margin-right: 90px;
508
- position: relative;
509
- margin-top: 5px;
510
- }
511
- .cpac-column .column-form table tr.column_width .input div.width-slider .ui-slider-handle {
512
- cursor: ew-resize;
513
- }
514
- .cpac-column .column-form table tr.column_width .input div.unit-select {
515
- position: absolute;
516
- top: 8px;
517
- right: 10px;
518
- width: 90px;
519
- text-align: right;
520
- }
521
- .cpac-column .column-form table tr.column_width .input div.unit-select label {
522
- padding-left: 5px;
523
- }
524
- .cpac-column .column-form table tr.column_image_size {
525
- border: 10px solid red;
526
- }
527
- .cpac-column .column-form table tr.column_image_size td.input label.custom-size {
528
- display: inline-block;
529
- margin-top: 4px;
530
- margin-bottom: 4px;
531
- }
532
- .cpac-column .column-form table tr.column_image_size td.input label.custom-size input {
533
- margin-right: 3px;
534
- }
535
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size {
536
- display: inline-block;
537
- }
538
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .hidden {
539
- display: none;
540
- }
541
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w,
542
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h {
543
- margin: 0;
544
- }
545
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w.hidden,
546
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h.hidden {
547
- display: none;
548
- }
549
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w input[type="text"],
550
- .cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h input[type="text"] {
551
- margin-right: 3px;
552
- width: 40px !important;
553
- }
554
- .cpac-column .column-form table tr.column_action td {
555
- border-top: 1px solid #ebebeb;
556
- background: #f9f9f9;
557
- }
558
- .cpac-column .column-form table tr.column_action td p {
559
- margin: 0;
560
- }
561
- .cpac-column .column-form table tr.column_action td p a.remove-button {
562
- color: #a00;
563
- text-decoration: none;
564
- text-shadow: none;
565
- font-weight: normal;
566
- margin-left: 5px;
567
- font-size: 12px;
568
- padding: 0 5px;
569
- }
570
- .cpac-column .column-form table tr.column_action td p a.remove-button:hover {
571
- color: #fff;
572
- background: #f00;
573
- }
574
- .cpac-column .column-form table tr:first-child td {
575
- border-top: none;
576
- }
577
- .cpac-column.loading .column-form > .spinner {
578
- position: absolute;
579
- left: 50%;
580
- top: 50%;
581
- z-index: 200;
582
- margin-left: -10px;
583
- margin-top: -10px;
584
- display: block;
585
- }
586
- .cpac-column.loading .column-form:before {
587
- content: '';
588
- position: absolute;
589
- width: 100%;
590
- height: 100%;
591
- background: #FFF;
592
- z-index: 100;
593
- opacity: 0.5;
594
- }
595
- .cpac-column.opened .column-meta {
596
- background-color: #c7c7c7;
597
- background-image: -ms-linear-gradient(top, #e9e9e9, #c7c7c7);
598
- background-image: -moz-linear-gradient(top, #e9e9e9, #c7c7c7);
599
- background-image: -o-linear-gradient(top, #e9e9e9, #c7c7c7);
600
- background-image: -webkit-gradient(linear, left top, left bottom, from(#e9e9e9), to(#c7c7c7));
601
- background-image: -webkit-linear-gradient(top, #e9e9e9, #c7c7c7);
602
- background-image: linear-gradient(top, #e9e9e9, #c7c7c7);
603
- border-color: #aeaeae;
604
- }
605
- .cpac-column.opened .column-meta table {
606
- background: transparent;
607
- }
608
- .cpac-column.opened .column-meta table td {
609
- border-color: #f8f8f8;
610
- color: #333;
611
- text-shadow: 0 1px 0 #FFFFFF;
612
- }
613
- .cpac-column.opened .column-meta table td a {
614
- color: #333;
615
- text-shadow: 0 1px 0 #FFFFFF;
616
- }
617
- .cpac-column.opened .column-meta table td.column_sort {
618
- background-position: 8px -39px;
619
- }
620
- .cpac-column.opened .column-meta table td.column_label .inner .meta span {
621
- color: #808080;
622
- text-shadow: none;
623
- }
624
- .cpac-column.opened .column-meta table td.column_type {
625
- color: #5C5C5C;
626
- }
627
- /**
628
- * Column: Footer
629
- * ----------------------------------------------------------------------------
630
- */
631
- .column-footer {
632
- background: #EAF2FA;
633
- border: 1px solid #c7d7e2;
634
- min-height: 26px;
635
- padding: 8px;
636
- overflow: hidden;
637
- }
638
- .column-footer .order-message {
639
- background: transparent url('../images/order_arrow.png') no-repeat 0 0;
640
- color: #7A9BBE;
641
- float: left;
642
- font-family: Comic Sans MS, sans-serif;
643
- font-size: 11px;
644
- height: 13px;
645
- line-height: 1em;
646
- margin-left: 4px;
647
- padding: 7px 0 0 22px;
648
- text-shadow: 0 1px 0 #FFFFFF;
649
- display: inline-block;
650
- }
651
- .column-footer .button-container {
652
- float: right;
653
- display: inline-block;
654
- margin-top: -5px;
655
- }
656
- .column-footer .button-container a {
657
- display: inline-block;
658
- margin-top: 5px;
659
- margin-left: 5px;
660
- }
661
- /**
662
- * Welcome Screen
663
- * ----------------------------------------------------------------------------
664
- */
665
- .cpac-content-body hr {
666
- -moz-border-bottom-colors: none;
667
- -moz-border-left-colors: none;
668
- -moz-border-right-colors: none;
669
- -moz-border-top-colors: none;
670
- background: none repeat scroll 0 0 transparent;
671
- border-color: #DFDFDF -moz-use-text-color -moz-use-text-color;
672
- border-image: none;
673
- border-right: 0 none;
674
- border-style: solid none none;
675
- border-width: 1px 0 0;
676
- clear: both;
677
- margin: 30px 0;
678
- opacity: 0.2;
679
- }
680
- #cpac-welcome.about-wrap div.error {
681
- display: block !important;
682
- }
683
- .cpac-alert {
684
- display: inline-block;
685
- background: none repeat scroll 0 0 #FCF8E3;
686
- border: 1px solid #FBEED5;
687
- border-radius: 4px 4px 4px 4px;
688
- color: #C09853;
689
- margin: 20px 0;
690
- padding: 16px 14px;
691
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
692
- }
693
- .cpac-alert p {
694
- margin: 0;
695
- }
696
- .cpac-alert.cpac-alert-success {
697
- background-color: #DFF0D8;
698
- border-color: #D6E9C6;
699
- color: #468847;
700
- }
701
- .cpac-alert.cpac-alert-error {
702
- background-color: #F2DEDE;
703
- border-color: #EED3D7;
704
- color: #B94A48;
705
- }
706
- .cpac-alert a.button-primary {
707
- height: 28px;
708
- line-height: 28px;
709
- display: inline-block;
710
- }
711
- #cpac-download-add-ons-table {
712
- max-width: 600px;
713
- }
714
- .wp-core-ui .button-large {
715
- height: 40px;
716
- line-height: 40px;
717
- font-size: 16px;
718
- padding: 0 15px;
719
- text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
720
- }
721
- /**
722
- * Notifications
723
- * ----------------------------------------------------------------------------
724
- */
725
- .cac-notification.updated {
726
- border-left-color: #0071aa;
727
- }
728
- .cac-notification.updated .learnmore {
729
- float: right;
730
- }
731
- .cac-notification.updated .learnmore:after {
732
- content: "\f139";
733
- font: normal 20px/1 'dashicons';
734
- float: right;
735
- }
736
- /**
737
- * Sidebar
738
- * ----------------------------------------------------------------------------
739
- */
740
- .columns-right .sidebox {
741
- background: none repeat scroll 0 0 #FFFFFF;
742
- border: 1px solid #E1E1E1;
743
- border-radius: 0 0 0 0;
744
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
745
- position: relative;
746
- margin-bottom: 14px;
747
- }
748
- .columns-right .sidebox h3 {
749
- padding: 10px;
750
- margin: 0;
751
- position: relative;
752
- }
753
- .columns-right .sidebox h3.title {
754
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
755
- font-size: 15px;
756
- font-weight: normal;
757
- line-height: 1;
758
- margin: 0;
759
- padding: 7px 10px;
760
- background: #f1f1f1;
761
- background-image: -webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9));
762
- background-image: -webkit-linear-gradient(bottom, #ececec, #f9f9f9);
763
- background-image: -moz-linear-gradient(bottom, #ececec, #f9f9f9);
764
- background-image: -o-linear-gradient(bottom, #ececec, #f9f9f9);
765
- background-image: linear-gradient(to top, #ececec, #f9f9f9);
766
- border-bottom-color: #dfdfdf;
767
- text-shadow: #fff 0 1px 0;
768
- -webkit-box-shadow: 0 1px 0 #fff;
769
- box-shadow: 0 1px 0 #fff;
770
- border-bottom-style: solid;
771
- border-bottom-width: 1px;
772
- }
773
- .columns-right .sidebox h3 span.left {
774
- position: relative;
775
- background: #fff;
776
- z-index: 2;
777
- padding-right: 8px;
778
- }
779
- .columns-right .sidebox h3 span.contenttype {
780
- display: block;
781
- line-height: 20px;
782
- font-size: 12px;
783
- text-transform: uppercase;
784
- color: #808080;
785
- margin-top: 4px;
786
- }
787
- .columns-right .sidebox h3 span.contenttype.right {
788
- position: absolute;
789
- display: inline-block;
790
- z-index: 1;
791
- right: 10px;
792
- text-align: right;
793
- margin-top: 0;
794
- }
795
- .columns-right .sidebox .inside {
796
- padding: 10px;
797
- }
798
- .columns-right .sidebox .inside p {
799
- margin-top: 0;
800
- }
801
- .columns-right .sidebox.form-actions .form-reset {
802
- display: none;
803
- border-bottom: 1px solid #F5F5F5;
804
- padding: 8px;
805
- }
806
- .columns-right .sidebox.form-actions .reset-column-type {
807
- text-decoration: none;
808
- color: #BC0B0B;
809
- line-height: 25px;
810
- display: inline-block;
811
- background: none;
812
- border: none;
813
- padding: 0;
814
- font-size: 13px;
815
- cursor: pointer;
816
- margin: 0;
817
- }
818
- .columns-right .sidebox.form-actions .reset-column-type:hover {
819
- color: #f00;
820
- }
821
- .columns-right .sidebox.form-actions .form-update {
822
- padding: 8px;
823
- overflow: hidden;
824
- }
825
- .columns-right .sidebox.form-actions .submit {
826
- display: none;
827
- width: 100%;
828
- height: 28px;
829
- line-height: 28px;
830
- text-align: center;
831
- }
832
- .columns-right .sidebox.form-actions .submit.save {
833
- display: block;
834
- }
835
- .columns-right .sidebox#ac-pro-version {
836
- background: none;
837
- }
838
- .columns-right .sidebox#ac-pro-version .padding-box {
839
- padding: 20px 10px 10px;
840
- background: #3d4350;
841
- color: #fff;
842
- }
843
- .columns-right .sidebox#ac-pro-version h3 {
844
- font-size: 34px;
845
- }
846
- .columns-right .sidebox#ac-pro-version h3 a {
847
- text-decoration: none;
848
- color: #fff;
849
- }
850
- .columns-right .sidebox#ac-pro-version h3 a span {
851
- color: #e9426e;
852
- }
853
- .columns-right .sidebox#ac-pro-version .acp-button {
854
- background: #e9426e;
855
- border: none;
856
- color: #fff;
857
- text-decoration: none;
858
- text-align: center;
859
- display: block;
860
- padding: 6px 20px;
861
- border-radius: 3px;
862
- }
863
- .columns-right .sidebox#ac-pro-version ul li {
864
- padding-bottom: 3px;
865
- }
866
- .columns-right .sidebox#ac-pro-version ul li a {
867
- color: #fff;
868
- text-decoration: none;
869
- }
870
- .columns-right .sidebox#ac-pro-version ul li a:before {
871
- content: '\2713';
872
- font-weight: bold;
873
- font-size: 16px;
874
- display: inline-block;
875
- vertical-align: top;
876
- margin-right: 10px;
877
- }
878
- .columns-right .sidebox#ac-pro-version ul li.acp-integration {
879
- padding: 6px 0;
880
- }
881
- .columns-right .sidebox#ac-pro-version ul li.acp-integration img {
882
- height: 21px;
883
- display: inline-block;
884
- vertical-align: middle;
885
- margin-right: 5px;
886
- }
887
- .columns-right .sidebox#ac-pro-version ul li.acp-integration img.woocommerce {
888
- height: 24px;
889
- }
890
- .columns-right .sidebox#ac-pro-version ul li.acp-integration a:before {
891
- content: '+';
892
- }
893
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal {
894
- background: none;
895
- color: #3d4350;
896
- padding-bottom: 20px;
897
- text-align: center;
898
- background-color: #fff;
899
- }
900
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal h3 {
901
- font-size: 20px;
902
- line-height: 26px;
903
- padding-top: 0;
904
- padding-bottom: 0;
905
- margin-bottom: 18px;
906
- }
907
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal a.acp-button {
908
- font-size: 16px;
909
- }
910
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter {
911
- border: 1px solid #3d4350;
912
- background: none;
913
- color: #3d4350;
914
- }
915
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter h3 {
916
- font-size: 20px;
917
- padding-bottom: 0;
918
- }
919
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter input {
920
- width: 100%;
921
- margin-bottom: 8px;
922
- }
923
- .columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter .acp-button {
924
- margin-top: 15px;
925
- margin-bottom: 0;
926
- padding: 7px 20px;
927
- }
928
- .columns-right .sidebox#add-acf {
929
- background-color: #5ee8bf;
930
- }
931
- .columns-right .sidebox#add-acf h3 {
932
- padding: 0;
933
- }
934
- .columns-right .sidebox#add-acf h3 a {
935
- color: #fff;
936
- text-decoration: none;
937
- font-size: 15px;
938
- }
939
- .columns-right .sidebox#direct-feedback #feedback-support,
940
- .columns-right .sidebox#direct-feedback #feedback-rate {
941
- display: none;
942
- }
943
- .columns-right .sidebox#direct-feedback .inside > a {
944
- border-radius: 4px;
945
- border: 1px solid #CCC;
946
- width: 48%;
947
- height: 64px;
948
- text-align: center;
949
- line-height: 64px;
950
- font-weight: bold;
951
- color: #222;
952
- display: inline-block;
953
- text-decoration: none;
954
- }
955
- .columns-right .sidebox#direct-feedback .inside > a:hover {
956
- background: #FAFAFA;
957
- }
958
- .columns-right .sidebox#direct-feedback .inside form textarea {
959
- width: 100%;
960
- height: 120px;
961
- }
962
- .columns-right .sidebox#direct-feedback .inside form input[type="submit"] {
963
- display: inline-block;
964
- float: right;
965
- border-radius: 4px;
966
- border: 1px solid #CCC;
967
- height: 32px;
968
- text-align: center;
969
- line-height: 32px;
970
- font-weight: bold;
971
- font-size: 12px;
972
- padding: 0 32px;
973
- color: #CCC;
974
- background: none;
975
- text-decoration: none;
976
- cursor: pointer;
977
- }
978
- .columns-right .sidebox#direct-feedback .inside form input[type="submit"]:hover {
979
- background: #FAFAFA;
980
- }
981
- .columns-right .sidebox#direct-feedback .inside form p.description {
982
- float: left;
983
- font-size: 10px;
984
- }
985
- .columns-right .sidebox#direct-feedback .inside ul {
986
- margin: 0;
987
- }
988
- .columns-right .sidebox#direct-feedback .inside ul.share li {
989
- margin: 0;
990
- display: block;
991
- float: left;
992
- margin-left: 9px;
993
- width: 30%;
994
- }
995
- .columns-right .sidebox#direct-feedback .inside ul.share li a {
996
- text-decoration: none;
997
- vertical-align: middle;
998
- line-height: 20px;
999
- padding: 16px 0;
1000
- width: 100%;
1001
- text-align: center;
1002
- border: 1px solid #CCC;
1003
- border-radius: 4px;
1004
- display: block;
1005
- }
1006
- .columns-right .sidebox#direct-feedback .inside ul.share li a:hover {
1007
- background: #FAFAFA;
1008
- }
1009
- .columns-right .sidebox#direct-feedback .inside ul.share li:first-child {
1010
- margin-left: 0;
1011
- }
1012
- .columns-right .sidebox#direct-feedback #feedback-support .inside ul.share li {
1013
- width: 48%;
1014
- }
1015
- /**
1016
- * Setting Tab
1017
- * ----------------------------------------------------------------------------
1018
- */
1019
- table.cpac-form-table {
1020
- max-width: 1100px;
1021
- margin-top: 20px;
1022
- }
1023
- table.cpac-form-table > tbody > tr > td,
1024
- table.cpac-form-table > tbody > tr > th {
1025
- vertical-align: top;
1026
- }
1027
- table.cpac-form-table td.padding-22 {
1028
- padding-top: 22px;
1029
- }
1030
- table.cpac-form-table.settings tr td {
1031
- padding-top: 74px;
1032
- }
1033
- table.cpac-form-table.settings tr:first-child th {
1034
- padding-top: 0;
1035
- }
1036
- table.cpac-form-table.settings tr:first-child td {
1037
- padding-top: 54px;
1038
- }
1039
- /**
1040
- * WP Pointer
1041
- * ----------------------------------------------------------------------------
1042
- */
1043
- .wp-pointer-content {
1044
- overflow: hidden;
1045
- }
1046
- .wp-pointer-content ol {
1047
- margin-left: 1.5em;
1048
- padding: 0 15px;
1049
- }
1050
- .wp-pointer-right {
1051
- margin-right: 15px;
1052
- }
1053
- .wp-pointer.noclick .wp-pointer-buttons {
1054
- display: none;
1055
- }
1056
- /* =RTL language
1057
- -------------------------------------------------------------- */
1058
- body.rtl .wp-pointer-right {
1059
- margin-left: 15px;
1060
- margin-right: 0;
1061
- }
1062
- body.rtl .wp-pointer-right ol {
1063
- margin-right: 1.5em;
1064
- margin-left: 0;
1065
- }
1066
- body.rtl .cpac-menu .subsubsub {
1067
- margin-left: 14px;
1068
- margin-right: 0;
1069
- }
1070
- body.rtl .columns-container {
1071
- margin-left: 300px;
1072
- margin-right: 0;
1073
- }
1074
- body.rtl .columns-left {
1075
- float: right;
1076
- }
1077
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta img {
1078
- margin-left: 3px;
1079
- margin-right: 0;
1080
- }
1081
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label .inner > a.remove-button {
1082
- margin-right: 12px;
1083
- margin-left: 0;
1084
- }
1085
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label .inner .meta {
1086
- float: left;
1087
- }
1088
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label span.vers {
1089
- float: right;
1090
- }
1091
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_type {
1092
- text-align: left;
1093
- padding-left: 0;
1094
- padding-right: auto;
1095
- }
1096
- body.rtl .columns-left .cpac-columns .cpac-column .column-meta span.vers .comment-grey-bubble {
1097
- float: left;
1098
- }
1099
- body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr.column_image_size td.input label input {
1100
- margin-left: 3px;
1101
- margin-right: 0;
1102
- }
1103
- body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr td.label p.description {
1104
- right: 0;
1105
- left: auto;
1106
- }
1107
- body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr td.label a.more-info {
1108
- float: left;
1109
- }
1110
- body.rtl .columns-left .cpac-columns .cpac-column .column-form div.description {
1111
- float: right;
1112
- }
1113
- body.rtl .columns-left .cpac-columns .cpac-column .column-form div.input-width-range {
1114
- float: right;
1115
- }
1116
- body.rtl .columns-left .cpac-columns .cpac-column .column-form tr td.input label {
1117
- padding-left: 10px;
1118
- padding-right: 0;
1119
- }
1120
- body.rtl .columns-left .cpac-columns .cpac-column .column-form a.help {
1121
- float: left;
1122
- }
1123
- body.rtl .columns-left .column-footer .order-message {
1124
- float: right;
1125
- padding-right: 22px;
1126
- padding-left: 0;
1127
- background: transparent url('../images/order_arrow-rtl.png') no-repeat right top;
1128
- }
1129
- body.rtl .columns-left .column-footer .button-container {
1130
- float: left;
1131
- }
1132
- body.rtl .columns-left .column-footer .submit {
1133
- display: none;
1134
- }
1135
- body.rtl .columns-right {
1136
- float: left;
1137
- margin-left: -300px;
1138
- margin-right: 0;
1139
- }
1140
- body.rtl .cpac-placeholder {
1141
- padding: 5px 0 7px 4px;
1142
- }
1143
- body.rtl .cpac_export .ms-container .ms-selection {
1144
- float: left;
1145
- }
1146
- /* =Responsive
1147
- -------------------------------------------------------------- */
1148
- @media only screen and (max-width: 900px) {
1149
- .columns-container {
1150
- margin-right: 0;
1151
- }
1152
- .columns-container .menu {
1153
- float: none;
1154
- }
1155
- .columns-container .columns-left {
1156
- float: none;
1157
- }
1158
- .columns-container .columns-right {
1159
- float: none;
1160
- margin-top: 0;
1161
- margin-right: 0;
1162
- width: 100%;
1163
- }
1164
- }
1165
- /* =Addons
1166
- -------------------------------------------------------------- */
1167
- .cpac-addons li {
1168
- width: 200px;
1169
- background: #FFF;
1170
- float: left;
1171
- margin-right: 16px;
1172
- margin-bottom: 16px;
1173
- border: 1px solid #DDD;
1174
- -webkit-box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.15);
1175
- -moz-box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.15);
1176
- box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.15);
1177
- }
1178
- .cpac-addons li:hover {
1179
- -webkit-box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.25);
1180
- -moz-box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.25);
1181
- box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.25);
1182
- }
1183
- .cpac-addons li a {
1184
- color: #444;
1185
- }
1186
- .cpac-addons li .cpac-addon-content {
1187
- display: table;
1188
- width: 100%;
1189
- height: 125px;
1190
- text-align: center;
1191
- vertical-align: middle;
1192
- border-top: 1px solid #DDD;
1193
- background: #0069a4;
1194
- background: -moz-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
1195
- background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #0069a4), color-stop(100%, #085079));
1196
- background: -webkit-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
1197
- background: -o-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
1198
- background: -ms-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
1199
- background: radial-gradient(ellipse at center, #0069a4 0%, #085079 100%);
1200
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0069a4', endColorstr='#085079', GradientType=1);
1201
- }
1202
- .cpac-addons li .cpac-addon-content > * {
1203
- display: table-cell;
1204
- vertical-align: middle;
1205
- }
1206
- .cpac-addons li .cpac-addon-content h3 {
1207
- padding: 0 16px;
1208
- color: #FFF;
1209
- line-height: 150%;
1210
- }
1211
- .cpac-addons li .cpac-addon-content img {
1212
- width: 100%;
1213
- }
1214
- .cpac-addons li .cpac-addon-header {
1215
- width: 100%;
1216
- padding: 25px 15px;
1217
- -moz-box-sizing: border-box;
1218
- box-sizing: border-box;
1219
- }
1220
- .cpac-addons li .cpac-addon-header > *:first-child {
1221
- margin-top: 0;
1222
- }
1223
- .cpac-addons li .cpac-addon-header > *:last-child {
1224
- margin-bottom: 0;
1225
- }
1226
- .cpac-addons li .cpac-addon-actions {
1227
- background: #EEE;
1228
- border-top: 1px solid #DDD;
1229
- padding: 8px;
1230
- }
1231
- .cpac-addons li .cpac-addon-actions .cpac-installed:before {
1232
- content: "\f147";
1233
- font-family: 'dashicons';
1234
- vertical-align: middle;
1235
- margin-left: -5px;
1236
- margin-right: 3px;
1237
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin-column.min.css DELETED
@@ -1 +0,0 @@
1
- .button.loading span,.cpac-column .comment-grey-bubble{height:16px;width:16px}#cpac h2.cpac-nav-tab-wrapper,.cpac-menu{margin-bottom:10px}#cpac a:active,#cpac a:focus{outline:0}#icon-codepress-admin-columns{background:url(../images/icon.png) no-repeat}.button.loading{padding-right:25px;position:relative}.rtl .button.loading{padding-left:25px;padding-right:0}.button.loading span{position:absolute;top:2px;right:6px;background:url(../images/loading.gif) right 50% no-repeat;display:inline-block}.rtl .button.loading span{left:6px;right:auto}.cpac_message.error.warning{border-left:4px solid #ffba00}.ajax-message{display:none}.cpac-column .comment-grey-bubble:before{content:'\f101';font:400 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;left:0;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.rtl .cpac-column .comment-grey-bubble:before{right:0;left:auto}.cpac-menu{clear:both;overflow:hidden}.cpac-menu .subsubsub{white-space:normal;width:100%;margin:0 14px 0 0}.cpac-menu .subsubsub li.first{font-weight:700;min-width:100px}.cpac-menu label{font-weight:700;margin-right:5px}.cpac-menu .spinner{float:none;margin-top:0;margin-left:0}.columns-container{margin-right:300px;max-width:700px}.columns-container .columns-left{float:left;width:100%}.columns-container .columns-left .column-footer .submit.save{display:inline-block}.columns-container .columns-left .column-footer .submit.update,.columns-container.stored .columns-right .sidebox.form-actions .submit.save{display:none}.columns-container .columns-right{float:right;margin-right:-300px;width:280px}.columns-container .columns-right .columns-right-inside.fixed{width:280px}.columns-container.stored .columns-right .sidebox.form-actions .form-reset,.columns-container.stored .columns-right .sidebox.form-actions .submit.update{display:block}.columns-container.stored .column-footer .submit.save{display:none}.columns-container.stored .column-footer .submit.update,.menu select{display:inline-block}.ui-sortable-helper{-webkit-box-shadow:1px 3px 6px 0 rgba(1,1,1,.4);box-shadow:1px 3px 6px 0 rgba(1,1,1,.4)}.ui-sortable-helper .column-meta{border-width:1px}.cpac-placeholder{visibility:visible!important;border-top:1px solid #dfdfdf;padding:5px 4px 7px 0}.cpac-placeholder .inner-placeholder{border:1px dashed grey;background:#eee;width:100%;height:100%}.cpac-placeholder :first-child{border:none}.menu{position:relative;margin-bottom:16px}.menu select{margin:0}.menu .spinner{display:none;float:none;visibility:visible;margin:0 0 0 14px}.menu .view-link,.menu .view-link:active{display:inline-block;margin:0 0 0 12px;top:2px}.columns-left .cpac-notice{background:#fff;border-left:4px solid #ffba00;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin-bottom:15px;padding:1px 12px}.columns-left .cpac-boxes .cpac-columns form{box-shadow:0 1px 3px rgba(0,0,0,.1);margin:0}.columns-left .cpac-boxes.disabled{opacity:.7}.columns-left .cpac-boxes.disabled .column_action,.columns-left .cpac-boxes.disabled a.clone-button,.columns-left .cpac-boxes.disabled a.edit-button,.columns-left .cpac-boxes.disabled a.remove-button{display:none!important}.columns-left .cpac-boxes.disabled .column-footer,.columns-left .cpac-boxes.disabled .column-meta td.column_sort{display:none}.columns-left .cpac-boxes.disabled .meta span{cursor:default!important}.columns-left .cpac-boxes.disabled .meta span:before{color:grey!important}.columns-left .cpac-boxes.disabled .meta span.off{opacity:.5}.cpac-column .column-meta{border-style:solid;border-color:#dfdfdf;border-width:1px 1px 0;background:#fcfcfc}.cpac-column .column-meta:nth-child(2n) .column-meta{background:#f9f9f9}.cpac-column .column-meta img{margin-right:3px}.cpac-column .column-meta table{border:none;background:0 0;border-radius:0}.cpac-column .column-meta table tr td{vertical-align:top;height:18px;border:solid transparent;padding:11px 8px;border-width:1px 0 0}.cpac-column .column-meta table tr td.column_sort{width:10px;background:url(../images/drag.png) 8px 8px no-repeat;cursor:move}.cpac-column .column-meta table tr td.column_label{width:70%;font-weight:700;vertical-align:middle;position:relative}.cpac-column .column-meta table tr td.column_label .inner{position:relative;overflow:hidden;height:18px}.cpac-column .column-meta table tr td.column_label .inner>a{color:#5a5a5a;padding:0 4px}.cpac-column .column-meta table tr td.column_label .inner>a:hover{color:#333}.cpac-column .column-meta table tr td.column_label .inner>a.clone-button,.cpac-column .column-meta table tr td.column_label .inner>a.edit-button,.cpac-column .column-meta table tr td.column_label .inner>a.remove-button{display:none;color:#a00;text-decoration:none;text-shadow:none;font-weight:400;margin-left:5px;font-size:12px}.cpac-column .column-meta table tr td.column_label .inner>a.clone-button:hover,.cpac-column .column-meta table tr td.column_label .inner>a.edit-button:hover,.cpac-column .column-meta table tr td.column_label .inner>a.remove-button:hover{color:red}.cpac-column .column-meta table tr td.column_label .inner>a.clone-button,.cpac-column .column-meta table tr td.column_label .inner>a.edit-button{color:#0074a2}.cpac-column .column-meta table tr td.column_label .inner>a.clone-button:hover,.cpac-column .column-meta table tr td.column_label .inner>a.edit-button:hover{color:#2ea2cc}.cpac-column .column-meta table tr td.column_label .inner .meta{display:inline-block;float:right;font-weight:400;color:#b2b2b2;font-size:12px}.cpac-column .column-meta table tr td.column_label .inner .meta span{cursor:pointer}.cpac-column .column-meta table tr td.column_label .inner .meta span.width{margin-right:5px;cursor:auto;color:#737373}.cpac-column .column-meta table tr td.column_label .inner .meta span.disabled{cursor:default}.cpac-column .column-meta table tr td.column_label span.vers{float:left}.cpac-column .column-meta table tr td.column_type{width:auto;min-width:120px;text-align:right;vertical-align:middle;color:#999;padding-right:0}.cpac-column .column-meta table tr td.column_type .inner{height:18px;overflow:hidden}.cpac-column .column-meta table tr td.column_type .inner a{color:#999}.cpac-column .column-meta table tr td.column_edit{width:38px;min-width:38px;background:url(../images/arrow.png) 23px 18px no-repeat;cursor:pointer}.cpac-column .column-meta:hover .column_label .inner>a.clone-button,.cpac-column .column-meta:hover .column_label .inner>a.edit-button,.cpac-column .column-meta:hover .column_label .inner>a.remove-button{display:inline-block}.cpac-column .column-meta span.vers{padding-top:2px}.cpac-column .column-meta span.vers .comment-grey-bubble{float:right}.cpac-column .column-form{display:none;border-width:1px 1px 0;border-style:solid;border-color:#dfdfdf;position:relative}.cpac-column .column-form table{border:none;background:#fcfcfc}.cpac-column .column-form table tr.hide{display:none}.cpac-column .column-form table tr td{vertical-align:top;border:none;padding:8px;background:#fff;border-top:1px solid #F5F5F5}.cpac-column .column-form table tr td input[type=text],.cpac-column .column-form table tr td select{width:99.95%}.cpac-column .column-form table tr td input[type=text].small,.cpac-column .column-form table tr td select.small{width:100px}.cpac-column .column-form table tr td span.suffix{line-height:40px;color:grey}.cpac-column .column-form table tr td select optgroup:nth-child(2n){background:#F9F9F9}.cpac-column .column-form table tr td.label{position:relative;overflow:visible;background:#f5f5f5;border-right:1px solid #E1E1E1;vertical-align:top;width:34%;border-top:1px solid #F0F0F0}.column-footer,.wp-pointer-content{overflow:hidden}.cpac-column .column-form table tr td.label label{font-weight:700;color:#333;display:block;position:relative}.cpac-column .column-form table tr td.label p{color:#666;display:block;font-size:12px;font-style:normal;line-height:16px;margin:0!important}.cpac-column .column-form table tr td.label p.description{display:none;position:absolute;z-index:99;top:30px;left:0;background:#eaf2fa;border-radius:5px;border:1px solid #c7d7e2;padding:5px 8px!important;font-weight:400}.cpac-column .column-form table tr td.label p.description em{display:block;color:#999}.cpac-column .column-form table tr td.label .info{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1}.cpac-column .column-form table tr td.label .info:before{position:absolute;z-index:1;right:10px;top:50%;margin-top:-7px;content:'';display:block;border-radius:32px;border:1px solid #E6E6E6;width:12px;height:12px}.cpac-column .column-form table tr td.label .info:after{position:absolute;z-index:1;right:10px;top:50%;margin-top:-6px;content:'?';display:block;width:14px;height:14px;color:#E6E6E6;font:700 10px Arial;text-align:center;vertical-align:middle;line-height:14px}.cpac-column .column-form table tr td.input label{padding-left:10px;padding-right:0}.cpac-column .column-form table tr td.input div.msg{margin-top:5px;display:none;color:#333;padding:6px 8px;background-color:#ffebe8;border:1px solid #fff;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}.cpac-column .column-form table tr td.input .section{padding:12px}.cpac-column .column-form table tr.column_width .input{position:relative}.cpac-column .column-form table tr.column_width .input div.description{font-size:11px;width:54px;position:absolute;left:10px;text-align:middle}.cpac-column .column-form table tr.column_width .input div.description input{background:#efefef;border:none;height:20px;line-height:20px;text-align:right;width:36px;font-size:12px}.cpac-column .column-form table tr.column_width .input div.width-slider{margin-left:68px;margin-right:90px;position:relative;margin-top:5px}.cpac-column .column-form table tr.column_width .input div.width-slider .ui-slider-handle{cursor:ew-resize}.cpac-column .column-form table tr.column_width .input div.unit-select{position:absolute;top:8px;right:10px;width:90px;text-align:right}.cpac-column .column-form table tr.column_width .input div.unit-select label{padding-left:5px}.cpac-column .column-form table tr.column_image_size{border:10px solid red}.cpac-column .column-form table tr.column_image_size td.input label.custom-size{display:inline-block;margin-top:4px;margin-bottom:4px}.cpac-column .column-form table tr.column_image_size td.input label.custom-size input{margin-right:3px}.cpac-column .column-form table tr.column_image_size td.input .custom_image_size{display:inline-block}.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h.hidden,.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w.hidden,.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .hidden{display:none}.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h,.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w{margin:0}.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-h input[type=text],.cpac-column .column-form table tr.column_image_size td.input .custom_image_size .custom-size-w input[type=text]{margin-right:3px;width:40px!important}.cpac-column .column-form table tr.column_action td{border-top:1px solid #ebebeb;background:#f9f9f9}.cpac-column .column-form table tr.column_action td p{margin:0}.cpac-column .column-form table tr.column_action td p a.remove-button{color:#a00;text-decoration:none;text-shadow:none;font-weight:400;margin-left:5px;font-size:12px;padding:0 5px}.cpac-column .column-form table tr.column_action td p a.remove-button:hover{color:#fff;background:red}.cpac-column .column-form table tr:first-child td{border-top:none}.cpac-column.loading .column-form>.spinner{position:absolute;left:50%;top:50%;z-index:200;margin-left:-10px;margin-top:-10px;display:block}.cpac-column.loading .column-form:before{content:'';position:absolute;width:100%;height:100%;background:#FFF;z-index:100;opacity:.5}.cpac-column.opened .column-meta{background-color:#c7c7c7;background-image:-ms-linear-gradient(top,#e9e9e9,#c7c7c7);background-image:-moz-linear-gradient(top,#e9e9e9,#c7c7c7);background-image:-o-linear-gradient(top,#e9e9e9,#c7c7c7);background-image:-webkit-gradient(linear,left top,left bottom,from(#e9e9e9),to(#c7c7c7));background-image:-webkit-linear-gradient(top,#e9e9e9,#c7c7c7);background-image:linear-gradient(top,#e9e9e9,#c7c7c7);border-color:#aeaeae}.cpac-column.opened .column-meta table{background:0 0}.cpac-column.opened .column-meta table td{border-color:#f8f8f8;color:#333;text-shadow:0 1px 0 #FFF}.cpac-column.opened .column-meta table td a{color:#333;text-shadow:0 1px 0 #FFF}.cpac-column.opened .column-meta table td.column_sort{background-position:8px -39px}.cpac-column.opened .column-meta table td.column_label .inner .meta span{color:grey;text-shadow:none}.cpac-column.opened .column-meta table td.column_type{color:#5C5C5C}.column-footer{background:#EAF2FA;border:1px solid #c7d7e2;min-height:26px;padding:8px}.column-footer .order-message{background:url(../images/order_arrow.png) no-repeat;color:#7A9BBE;float:left;font-family:Comic Sans MS,sans-serif;font-size:11px;height:13px;line-height:1em;margin-left:4px;padding:7px 0 0 22px;text-shadow:0 1px 0 #FFF;display:inline-block}.column-footer .button-container{float:right;display:inline-block;margin-top:-5px}.column-footer .button-container a{display:inline-block;margin-top:5px;margin-left:5px}.cpac-content-body hr{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none;border-color:#DFDFDF -moz-use-text-color -moz-use-text-color;border-image:none;border-right:0 none;border-style:solid none none;border-width:1px 0 0;clear:both;margin:30px 0;opacity:.2}#cpac-welcome.about-wrap div.error{display:block!important}.cpac-alert{display:inline-block;background:#FCF8E3;border:1px solid #FBEED5;border-radius:4px;color:#C09853;margin:20px 0;padding:16px 14px;text-shadow:0 1px 0 rgba(255,255,255,.5)}.cpac-alert p{margin:0}.cpac-alert.cpac-alert-success{background-color:#DFF0D8;border-color:#D6E9C6;color:#468847}.cpac-alert.cpac-alert-error{background-color:#F2DEDE;border-color:#EED3D7;color:#B94A48}.cpac-alert a.button-primary{height:28px;line-height:28px;display:inline-block}#cpac-download-add-ons-table{max-width:600px}.wp-core-ui .button-large{height:40px;line-height:40px;font-size:16px;padding:0 15px;text-shadow:0 1px 0 rgba(0,0,0,.5)}.cac-notification.updated{border-left-color:#0071aa}.cac-notification.updated .learnmore{float:right}.cac-notification.updated .learnmore:after{content:"\f139";font:400 20px/1 dashicons;float:right}.columns-right .sidebox{background:#FFF;border:1px solid #E1E1E1;border-radius:0;box-shadow:0 1px 3px rgba(0,0,0,.1);position:relative;margin-bottom:14px}.columns-right .sidebox h3{padding:10px;margin:0;position:relative}.columns-right .sidebox h3.title{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:15px;font-weight:400;line-height:1;margin:0;padding:7px 10px;background:#f1f1f1;background-image:-webkit-gradient(linear,left bottom,left top,from(#ececec),to(#f9f9f9));background-image:-webkit-linear-gradient(bottom,#ececec,#f9f9f9);background-image:-moz-linear-gradient(bottom,#ececec,#f9f9f9);background-image:-o-linear-gradient(bottom,#ececec,#f9f9f9);background-image:linear-gradient(to top,#ececec,#f9f9f9);border-bottom-color:#dfdfdf;text-shadow:#fff 0 1px 0;-webkit-box-shadow:0 1px 0 #fff;box-shadow:0 1px 0 #fff;border-bottom-style:solid;border-bottom-width:1px}.columns-right .sidebox h3 span.left{position:relative;background:#fff;z-index:2;padding-right:8px}.columns-right .sidebox h3 span.contenttype{display:block;line-height:20px;font-size:12px;text-transform:uppercase;color:grey;margin-top:4px}.columns-right .sidebox h3 span.contenttype.right{position:absolute;display:inline-block;z-index:1;right:10px;text-align:right;margin-top:0}.columns-right .sidebox .inside{padding:10px}.columns-right .sidebox .inside p{margin-top:0}.columns-right .sidebox.form-actions .form-reset{display:none;border-bottom:1px solid #F5F5F5;padding:8px}.columns-right .sidebox.form-actions .reset-column-type{text-decoration:none;color:#BC0B0B;line-height:25px;display:inline-block;background:0 0;border:none;padding:0;font-size:13px;cursor:pointer;margin:0}.columns-right .sidebox.form-actions .reset-column-type:hover{color:red}.columns-right .sidebox.form-actions .form-update{padding:8px;overflow:hidden}.columns-right .sidebox.form-actions .submit{display:none;width:100%;height:28px;line-height:28px;text-align:center}.columns-right .sidebox.form-actions .submit.save{display:block}.columns-right .sidebox#ac-pro-version{background:0 0}.columns-right .sidebox#ac-pro-version .padding-box{padding:20px 10px 10px;background:#3d4350;color:#fff}.columns-right .sidebox#ac-pro-version h3{font-size:34px}.columns-right .sidebox#ac-pro-version h3 a{text-decoration:none;color:#fff}.columns-right .sidebox#ac-pro-version h3 a span{color:#e9426e}.columns-right .sidebox#ac-pro-version .acp-button{background:#e9426e;border:none;color:#fff;text-decoration:none;text-align:center;display:block;padding:6px 20px;border-radius:3px}.columns-right .sidebox#ac-pro-version ul li{padding-bottom:3px}.columns-right .sidebox#ac-pro-version ul li a{color:#fff;text-decoration:none}.columns-right .sidebox#ac-pro-version ul li a:before{content:'\2713';font-weight:700;font-size:16px;display:inline-block;vertical-align:top;margin-right:10px}.columns-right .sidebox#ac-pro-version ul li.acp-integration{padding:6px 0}.columns-right .sidebox#ac-pro-version ul li.acp-integration img{height:21px;display:inline-block;vertical-align:middle;margin-right:5px}.columns-right .sidebox#ac-pro-version ul li.acp-integration img.woocommerce{height:24px}.columns-right .sidebox#ac-pro-version ul li.acp-integration a:before{content:'+'}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal{background:#fff;color:#3d4350;padding-bottom:20px;text-align:center}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal h3{font-size:20px;line-height:26px;padding-top:0;padding-bottom:0;margin-bottom:18px}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-deal a.acp-button{font-size:16px}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter{border:1px solid #3d4350;background:0 0;color:#3d4350}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter h3{font-size:20px;padding-bottom:0}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter input{width:100%;margin-bottom:8px}.columns-right .sidebox#ac-pro-version .padding-box.ac-pro-newsletter .acp-button{margin-top:15px;margin-bottom:0;padding:7px 20px}.columns-right .sidebox#add-acf{background-color:#5ee8bf}.columns-right .sidebox#add-acf h3{padding:0}.columns-right .sidebox#add-acf h3 a{color:#fff;text-decoration:none;font-size:15px}.columns-right .sidebox#direct-feedback #feedback-rate,.columns-right .sidebox#direct-feedback #feedback-support{display:none}.columns-right .sidebox#direct-feedback .inside>a{border-radius:4px;border:1px solid #CCC;width:48%;height:64px;text-align:center;line-height:64px;font-weight:700;color:#222;display:inline-block;text-decoration:none}.columns-right .sidebox#direct-feedback .inside>a:hover{background:#FAFAFA}.columns-right .sidebox#direct-feedback .inside form textarea{width:100%;height:120px}.columns-right .sidebox#direct-feedback .inside form input[type=submit]{display:inline-block;float:right;border-radius:4px;border:1px solid #CCC;height:32px;text-align:center;line-height:32px;font-weight:700;font-size:12px;padding:0 32px;color:#CCC;background:0 0;text-decoration:none;cursor:pointer}.columns-right .sidebox#direct-feedback .inside form input[type=submit]:hover,.columns-right .sidebox#direct-feedback .inside ul.share li a:hover{background:#FAFAFA}.columns-right .sidebox#direct-feedback .inside form p.description{float:left;font-size:10px}.columns-right .sidebox#direct-feedback .inside ul{margin:0}.columns-right .sidebox#direct-feedback .inside ul.share li{margin:0 0 0 9px;display:block;float:left;width:30%}.columns-right .sidebox#direct-feedback .inside ul.share li a{text-decoration:none;vertical-align:middle;line-height:20px;padding:16px 0;width:100%;text-align:center;border:1px solid #CCC;border-radius:4px;display:block}.wp-pointer.noclick .wp-pointer-buttons,body.rtl .columns-left .column-footer .submit{display:none}.columns-right .sidebox#direct-feedback .inside ul.share li:first-child{margin-left:0}.columns-right .sidebox#direct-feedback #feedback-support .inside ul.share li{width:48%}table.cpac-form-table{max-width:1100px;margin-top:20px}table.cpac-form-table>tbody>tr>td,table.cpac-form-table>tbody>tr>th{vertical-align:top}table.cpac-form-table td.padding-22{padding-top:22px}table.cpac-form-table.settings tr td{padding-top:74px}table.cpac-form-table.settings tr:first-child th{padding-top:0}table.cpac-form-table.settings tr:first-child td{padding-top:54px}.wp-pointer-content ol{margin-left:1.5em;padding:0 15px}.wp-pointer-right{margin-right:15px}body.rtl .wp-pointer-right{margin-left:15px;margin-right:0}body.rtl .wp-pointer-right ol{margin-right:1.5em;margin-left:0}body.rtl .cpac-menu .subsubsub{margin-left:14px;margin-right:0}body.rtl .columns-container{margin-left:300px;margin-right:0}body.rtl .columns-left{float:right}body.rtl .columns-left .cpac-columns .cpac-column .column-meta img{margin-left:3px;margin-right:0}body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label .inner>a.remove-button{margin-right:12px;margin-left:0}body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label .inner .meta{float:left}body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_label span.vers{float:right}body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr td.label a.more-info,body.rtl .columns-left .cpac-columns .cpac-column .column-meta span.vers .comment-grey-bubble{float:left}body.rtl .columns-left .cpac-columns .cpac-column .column-meta .column_type{text-align:left;padding-left:0;padding-right:auto}body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr.column_image_size td.input label input{margin-left:3px;margin-right:0}body.rtl .columns-left .cpac-columns .cpac-column .column-form table tr td.label p.description{right:0;left:auto}body.rtl .columns-left .cpac-columns .cpac-column .column-form div.description,body.rtl .columns-left .cpac-columns .cpac-column .column-form div.input-width-range{float:right}body.rtl .columns-left .cpac-columns .cpac-column .column-form tr td.input label{padding-left:10px;padding-right:0}body.rtl .columns-left .cpac-columns .cpac-column .column-form a.help{float:left}body.rtl .columns-left .column-footer .order-message{float:right;padding-right:22px;padding-left:0;background:url(../images/order_arrow-rtl.png) right top no-repeat}body.rtl .columns-left .column-footer .button-container,body.rtl .cpac_export .ms-container .ms-selection{float:left}body.rtl .columns-right{float:left;margin-left:-300px;margin-right:0}body.rtl .cpac-placeholder{padding:5px 0 7px 4px}@media only screen and (max-width:900px){.columns-container{margin-right:0}.columns-container .columns-left,.columns-container .menu{float:none}.columns-container .columns-right{float:none;margin-top:0;margin-right:0;width:100%}}.cpac-addons li{width:200px;background:#FFF;float:left;margin-right:16px;margin-bottom:16px;border:1px solid #DDD;-webkit-box-shadow:0 3px 10px 0 rgba(0,0,0,.15);-moz-box-shadow:0 3px 10px 0 rgba(0,0,0,.15);box-shadow:0 3px 10px 0 rgba(0,0,0,.15)}.cpac-addons li:hover{-webkit-box-shadow:0 3px 10px 0 rgba(0,0,0,.25);-moz-box-shadow:0 3px 10px 0 rgba(0,0,0,.25);box-shadow:0 3px 10px 0 rgba(0,0,0,.25)}.cpac-addons li a{color:#444}.cpac-addons li .cpac-addon-content{display:table;width:100%;height:125px;text-align:center;vertical-align:middle;border-top:1px solid #DDD;background:#0069a4;background:-moz-radial-gradient(center,ellipse cover,#0069a4 0,#085079 100%);background:-webkit-gradient(radial,center center,0,center center,100%,color-stop(0,#0069a4),color-stop(100%,#085079));background:-webkit-radial-gradient(center,ellipse cover,#0069a4 0,#085079 100%);background:-o-radial-gradient(center,ellipse cover,#0069a4 0,#085079 100%);background:-ms-radial-gradient(center,ellipse cover,#0069a4 0,#085079 100%);background:radial-gradient(ellipse at center,#0069a4 0,#085079 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0069a4', endColorstr='#085079', GradientType=1)}.cpac-addons li .cpac-addon-content>*{display:table-cell;vertical-align:middle}.cpac-addons li .cpac-addon-content h3{padding:0 16px;color:#FFF;line-height:150%}.cpac-addons li .cpac-addon-content img{width:100%}.cpac-addons li .cpac-addon-header{width:100%;padding:25px 15px;-moz-box-sizing:border-box;box-sizing:border-box}.cpac-addons li .cpac-addon-header>:first-child{margin-top:0}.cpac-addons li .cpac-addon-header>:last-child{margin-bottom:0}.cpac-addons li .cpac-addon-actions{background:#EEE;border-top:1px solid #DDD;padding:8px}.cpac-addons li .cpac-addon-actions .cpac-installed:before{content:"\f147";font-family:dashicons;vertical-align:middle;margin-left:-5px;margin-right:3px}
 
assets/css/admin-general.css ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ @font-face {
3
+ font-family: "cpac_icons";
4
+ src: url("../fonts/cpac_icons.woff") format("woff"); }
5
+
6
+ [class^="cpacicon-"], [class*=" cpacicon-"] {
7
+ font-family: 'cpac_icons';
8
+ speak: none;
9
+ font-style: normal;
10
+ font-weight: normal;
11
+ font-variant: normal;
12
+ text-transform: none;
13
+ line-height: 1;
14
+ /* Better Font Rendering =========== */
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale; }
17
+ [class^="cpacicon-"]:before, [class*=" cpacicon-"]:before {
18
+ font-size: 100%; }
19
+
20
+ .cpacicon-move:before {
21
+ content: ""; }
22
+
23
+ /* Dynamic variables */
24
+ /**
25
+ * General
26
+ * ----------------------------------------------------------------------------
27
+ */
28
+ #cpac a:focus,
29
+ #cpac a:active {
30
+ outline: none; }
31
+
32
+ .wrap .nav-tab-wrapper {
33
+ margin-bottom: 24px; }
34
+
35
+ .wrap .notice {
36
+ margin-top: 16px;
37
+ margin-bottom: 16px; }
38
+
39
+ .ac-badge {
40
+ display: inline-block;
41
+ background: #d54e21;
42
+ border-radius: 10px;
43
+ font-size: 9px;
44
+ line-height: 17px;
45
+ padding: 0 6px;
46
+ margin: -1px 0 0 4px;
47
+ vertical-align: middle;
48
+ color: #fff;
49
+ font-weight: 600; }
50
+
51
+ a.external:after {
52
+ content: "\f504";
53
+ display: inline-block;
54
+ margin-left: 4px;
55
+ font-size: 17px;
56
+ color: #797979;
57
+ line-height: 1;
58
+ font-family: dashicons, serif;
59
+ text-decoration: none;
60
+ font-weight: normal;
61
+ font-style: normal;
62
+ vertical-align: top;
63
+ text-align: center; }
64
+
65
+ /**
66
+ * Button
67
+ * ----------------------------------------------------------------------------
68
+ */
69
+ .button.loading {
70
+ padding-right: 25px;
71
+ position: relative; }
72
+
73
+ /**
74
+ * Message
75
+ * ----------------------------------------------------------------------------
76
+ */
77
+ .cpac_message.error.warning {
78
+ border-left: 4px solid #ffba00; }
79
+
80
+ /**
81
+ * Menu
82
+ * ----------------------------------------------------------------------------
83
+ */
84
+ .menu {
85
+ position: relative;
86
+ padding: 0;
87
+ margin-top: 16px;
88
+ margin-bottom: 16px; }
89
+ .menu select {
90
+ display: inline-block;
91
+ margin: 0; }
92
+ .menu .spinner {
93
+ display: none;
94
+ float: none;
95
+ visibility: visible;
96
+ margin: 0 0 0 14px; }
97
+ .menu .view-link,
98
+ .menu .view-link:active {
99
+ display: inline-block;
100
+ margin: 0 0 0 12px;
101
+ top: 2px; }
102
+
103
+ /**
104
+ * Table
105
+ * ----------------------------------------------------------------------------
106
+ */
107
+ table.ac-form-table {
108
+ max-width: 1100px;
109
+ margin-top: 20px; }
110
+ table.ac-form-table > tbody > tr > td,
111
+ table.ac-form-table > tbody > tr > th {
112
+ vertical-align: top; }
113
+ table.ac-form-table.settings tr th {
114
+ font-weight: normal; }
115
+ table.ac-form-table.settings tr th h2 {
116
+ margin: 0; }
117
+ table.ac-form-table.settings tr td {
118
+ padding-top: 58px; }
119
+
120
+ /**
121
+ * WP Pointer
122
+ * ----------------------------------------------------------------------------
123
+ */
124
+ .wp-pointer-content {
125
+ overflow: hidden; }
126
+ .wp-pointer-content ol {
127
+ margin-left: 1.5em;
128
+ padding: 0 15px; }
129
+
130
+ .wp-pointer-right {
131
+ margin-right: 15px; }
132
+
133
+ .wp-pointer.noclick .wp-pointer-buttons {
134
+ display: none; }
135
+
136
+ /* =RTL language
137
+ -------------------------------------------------------------- */
138
+ body.rtl .wp-pointer-right {
139
+ margin-left: 15px;
140
+ margin-right: 0; }
141
+ body.rtl .wp-pointer-right ol {
142
+ margin-right: 1.5em;
143
+ margin-left: 0; }
144
+
145
+ body.rtl .button.loading {
146
+ padding-left: 25px;
147
+ padding-right: 0; }
148
+ body.rtl .button.loading span {
149
+ left: 6px;
150
+ right: auto; }
151
+
152
+ body.rtl .ac-left {
153
+ float: right; }
154
+ body.rtl .ac-left .ac-columns .ac-column .column-meta img {
155
+ margin-left: 3px;
156
+ margin-right: 0; }
157
+ body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label .inner > a.remove-button {
158
+ margin-right: 12px;
159
+ margin-left: 0; }
160
+ body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label .inner .meta {
161
+ float: left; }
162
+ body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label span.vers {
163
+ float: right; }
164
+ body.rtl .ac-left .ac-columns .ac-column .column-meta .column_type {
165
+ text-align: left;
166
+ padding-left: 0;
167
+ padding-right: auto; }
168
+ body.rtl .ac-left .ac-columns .ac-column .column-meta span.vers .comment-grey-bubble {
169
+ float: left; }
170
+ body.rtl .ac-left .ac-columns .ac-column .column-form table tr.column_image_size td.input label input {
171
+ margin-left: 3px;
172
+ margin-right: 0; }
173
+ body.rtl .ac-left .ac-columns .ac-column .column-form table tr td.label p.description {
174
+ right: 0;
175
+ left: auto; }
176
+ body.rtl .ac-left .ac-columns .ac-column .column-form table tr td.label a.more-info {
177
+ float: left; }
178
+ body.rtl .ac-left .ac-columns .ac-column .column-form div.description {
179
+ float: right; }
180
+ body.rtl .ac-left .ac-columns .ac-column .column-form div.input-width-range {
181
+ float: right; }
182
+ body.rtl .ac-left .ac-columns .ac-column .column-form a.help {
183
+ float: left; }
184
+ body.rtl .ac-left .column-footer .order-message {
185
+ float: right;
186
+ padding-right: 22px;
187
+ padding-left: 0;
188
+ background: transparent url("../images/order_arrow-rtl.png") no-repeat right top; }
189
+ body.rtl .ac-left .column-footer .button-container {
190
+ float: left; }
191
+ body.rtl .ac-left .column-footer .submit {
192
+ display: none; }
193
+
194
+ body.rtl .ac-right {
195
+ float: left;
196
+ margin-left: -300px;
197
+ margin-right: 0; }
198
+
199
+ body.rtl .cpac-placeholder {
200
+ padding: 5px 0 7px 4px; }
201
+
202
+ body.rtl .cpac_export .ms-container .ms-selection {
203
+ float: left; }
assets/css/admin-general.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @charset "UTF-8";@font-face{font-family:cpac_icons;src:url(../fonts/cpac_icons.woff) format("woff")}[class*=" cpacicon-"],[class^=cpacicon-]{font-family:cpac_icons;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[class*=" cpacicon-"]:before,[class^=cpacicon-]:before{font-size:100%}.cpacicon-move:before{content:""}#cpac a:active,#cpac a:focus{outline:none}.wrap .nav-tab-wrapper{margin-bottom:24px}.wrap .notice{margin-top:16px;margin-bottom:16px}.ac-badge{display:inline-block;background:#d54e21;border-radius:10px;font-size:9px;line-height:17px;padding:0 6px;margin:-1px 0 0 4px;vertical-align:middle;color:#fff;font-weight:600}a.external:after{content:"\f504";display:inline-block;margin-left:4px;font-size:17px;color:#797979;line-height:1;font-family:dashicons,serif;text-decoration:none;font-weight:400;font-style:normal;vertical-align:top;text-align:center}.button.loading{padding-right:25px;position:relative}.cpac_message.error.warning{border-left:4px solid #ffba00}.menu{position:relative;padding:0;margin-top:16px;margin-bottom:16px}.menu select{display:inline-block;margin:0}.menu .spinner{display:none;float:none;visibility:visible;margin:0 0 0 14px}.menu .view-link,.menu .view-link:active{display:inline-block;margin:0 0 0 12px;top:2px}table.ac-form-table{max-width:1100px;margin-top:20px}table.ac-form-table>tbody>tr>td,table.ac-form-table>tbody>tr>th{vertical-align:top}table.ac-form-table.settings tr th{font-weight:400}table.ac-form-table.settings tr th h2{margin:0}table.ac-form-table.settings tr td{padding-top:58px}.wp-pointer-content{overflow:hidden}.wp-pointer-content ol{margin-left:1.5em;padding:0 15px}.wp-pointer-right{margin-right:15px}.wp-pointer.noclick .wp-pointer-buttons{display:none}body.rtl .wp-pointer-right{margin-left:15px;margin-right:0}body.rtl .wp-pointer-right ol{margin-right:1.5em;margin-left:0}body.rtl .button.loading{padding-left:25px;padding-right:0}body.rtl .button.loading span{left:6px;right:auto}body.rtl .ac-left{float:right}body.rtl .ac-left .ac-columns .ac-column .column-meta img{margin-left:3px;margin-right:0}body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label .inner>a.remove-button{margin-right:12px;margin-left:0}body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label .inner .meta{float:left}body.rtl .ac-left .ac-columns .ac-column .column-meta .column_label span.vers{float:right}body.rtl .ac-left .ac-columns .ac-column .column-meta .column_type{text-align:left;padding-left:0;padding-right:auto}body.rtl .ac-left .ac-columns .ac-column .column-meta span.vers .comment-grey-bubble{float:left}body.rtl .ac-left .ac-columns .ac-column .column-form table tr.column_image_size td.input label input{margin-left:3px;margin-right:0}body.rtl .ac-left .ac-columns .ac-column .column-form table tr td.label p.description{right:0;left:auto}body.rtl .ac-left .ac-columns .ac-column .column-form table tr td.label a.more-info{float:left}body.rtl .ac-left .ac-columns .ac-column .column-form div.description,body.rtl .ac-left .ac-columns .ac-column .column-form div.input-width-range{float:right}body.rtl .ac-left .ac-columns .ac-column .column-form a.help{float:left}body.rtl .ac-left .column-footer .order-message{float:right;padding-right:22px;padding-left:0;background:transparent url(../images/order_arrow-rtl.png) no-repeat 100% 0}body.rtl .ac-left .column-footer .button-container{float:left}body.rtl .ac-left .column-footer .submit{display:none}body.rtl .ac-right{float:left;margin-left:-300px;margin-right:0}body.rtl .cpac-placeholder{padding:5px 0 7px 4px}body.rtl .cpac_export .ms-container .ms-selection{float:left}
assets/css/admin-page-addons.css ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* =Colors
2
+ -------------------------------------------------------------- */
3
+ /* =Addons
4
+ -------------------------------------------------------------- */
5
+ .ac-addon {
6
+ display: inline-block;
7
+ margin-right: 16px;
8
+ float: left; }
9
+ .ac-addon.group-default {
10
+ float: none;
11
+ clear: both;
12
+ display: table; }
13
+ .ac-addon h2 {
14
+ border-bottom: 1px solid #ccc;
15
+ padding-bottom: 10px; }
16
+ .ac-addon ul {
17
+ overflow: hidden; }
18
+ .ac-addon ul li {
19
+ width: 200px;
20
+ background: #FFF;
21
+ float: left;
22
+ margin-right: 16px;
23
+ margin-bottom: 16px;
24
+ border: 1px solid #DDD;
25
+ -webkit-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.15);
26
+ -moz-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.15);
27
+ box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.15); }
28
+ .ac-addon ul li:last-child {
29
+ margin-right: 0; }
30
+ .ac-addon ul li:hover {
31
+ -webkit-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.25);
32
+ -moz-box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.25);
33
+ box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.25); }
34
+ .ac-addon ul li a {
35
+ color: #444; }
36
+ .ac-addon ul li .addon-header {
37
+ display: table;
38
+ width: 100%;
39
+ height: 125px;
40
+ text-align: center;
41
+ vertical-align: middle;
42
+ border-top: 1px solid #DDD;
43
+ background: #0069a4;
44
+ background: -moz-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
45
+ background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #0069a4), color-stop(100%, #085079));
46
+ background: -webkit-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
47
+ background: -o-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
48
+ background: -ms-radial-gradient(center, ellipse cover, #0069a4 0%, #085079 100%);
49
+ background: radial-gradient(ellipse at center, #0069a4 0%, #085079 100%);
50
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='$addon-color-lightblue', endColorstr='$addon-color-blue', GradientType=1); }
51
+ .ac-addon ul li .addon-header .inner {
52
+ display: table-cell;
53
+ vertical-align: middle;
54
+ padding: 15px 20px; }
55
+ .ac-addon ul li .addon-header .inner h3 {
56
+ padding: 0 16px;
57
+ color: #FFF;
58
+ line-height: 150%; }
59
+ .ac-addon ul li .addon-header .inner img {
60
+ display: inline-block;
61
+ max-height: 52px;
62
+ max-width: 100%; }
63
+ .ac-addon ul li .addon-notice {
64
+ background-color: #fff8e5;
65
+ margin: 0;
66
+ padding: 15px; }
67
+ .ac-addon ul li .addon-notice a {
68
+ font-weight: bold;
69
+ text-decoration: none;
70
+ color: #0073aa; }
71
+ .ac-addon ul li .addon-content {
72
+ width: 100%;
73
+ padding: 25px 15px;
74
+ -moz-box-sizing: border-box;
75
+ box-sizing: border-box;
76
+ min-height: 160px; }
77
+ .ac-addon ul li .addon-content > *:first-child {
78
+ margin-top: 0; }
79
+ .ac-addon ul li .addon-content > *:last-child {
80
+ margin-bottom: 0; }
81
+ .ac-addon ul li .addon-actions {
82
+ background: #eee;
83
+ border-top: 1px solid #ddd;
84
+ padding: 8px;
85
+ overflow: hidden; }
86
+ .ac-addon ul li .addon-actions span.active,
87
+ .ac-addon ul li .addon-actions span.active:hover {
88
+ display: inline-block;
89
+ height: 28px;
90
+ line-height: 28px;
91
+ cursor: default;
92
+ border-color: #69c471;
93
+ color: #388f40;
94
+ margin-left: 8px; }
95
+ .ac-addon ul li .addon-actions span.active:before,
96
+ .ac-addon ul li .addon-actions span.active:hover:before {
97
+ content: "\f147";
98
+ font-family: 'dashicons', sans-serif;
99
+ vertical-align: middle;
100
+ font-size: 17px;
101
+ margin: -2px 3px 0 -5px; }
102
+ .ac-addon ul li.ac-addon-types .addon-header .inner img {
103
+ max-height: 68px; }
assets/css/admin-page-addons.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ac-addon{display:inline-block;margin-right:16px;float:left}.ac-addon.group-default{float:none;clear:both;display:table}.ac-addon h2{border-bottom:1px solid #ccc;padding-bottom:10px}.ac-addon ul{overflow:hidden}.ac-addon ul li{width:200px;background:#fff;float:left;margin-right:16px;margin-bottom:16px;border:1px solid #ddd;box-shadow:0 3px 10px 0 rgba(0,0,0,.15)}.ac-addon ul li:last-child{margin-right:0}.ac-addon ul li:hover{box-shadow:0 3px 10px 0 rgba(0,0,0,.25)}.ac-addon ul li a{color:#444}.ac-addon ul li .addon-header{display:table;width:100%;height:125px;text-align:center;vertical-align:middle;border-top:1px solid #ddd;background:#0069a4;background:-webkit-gradient(radial,center center,0,center center,100%,color-stop(0,#0069a4),color-stop(100%,#085079));background:-webkit-radial-gradient(center,ellipse cover,#0069a4 0,#085079 100%);background:radial-gradient(ellipse at center,#0069a4 0,#085079 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="$addon-color-lightblue",endColorstr="$addon-color-blue",GradientType=1)}.ac-addon ul li .addon-header .inner{display:table-cell;vertical-align:middle;padding:15px 20px}.ac-addon ul li .addon-header .inner h3{padding:0 16px;color:#fff;line-height:150%}.ac-addon ul li .addon-header .inner img{display:inline-block;max-height:52px;max-width:100%}.ac-addon ul li .addon-notice{background-color:#fff8e5;margin:0;padding:15px}.ac-addon ul li .addon-notice a{font-weight:700;text-decoration:none;color:#0073aa}.ac-addon ul li .addon-content{width:100%;padding:25px 15px;box-sizing:border-box;min-height:160px}.ac-addon ul li .addon-content>:first-child{margin-top:0}.ac-addon ul li .addon-content>:last-child{margin-bottom:0}.ac-addon ul li .addon-actions{background:#eee;border-top:1px solid #ddd;padding:8px;overflow:hidden}.ac-addon ul li .addon-actions span.active,.ac-addon ul li .addon-actions span.active:hover{display:inline-block;height:28px;line-height:28px;cursor:default;border-color:#69c471;color:#388f40;margin-left:8px}.ac-addon ul li .addon-actions span.active:before,.ac-addon ul li .addon-actions span.active:hover:before{content:"\f147";font-family:dashicons,sans-serif;vertical-align:middle;font-size:17px;margin:-2px 3px 0 -5px}.ac-addon ul li.ac-addon-types .addon-header .inner img{max-height:68px}
assets/css/admin-page-columns.css ADDED
@@ -0,0 +1,861 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ @font-face {
3
+ font-family: "cpac_icons";
4
+ src: url("../fonts/cpac_icons.woff") format("woff"); }
5
+
6
+ [class^="cpacicon-"], [class*=" cpacicon-"] {
7
+ font-family: 'cpac_icons';
8
+ speak: none;
9
+ font-style: normal;
10
+ font-weight: normal;
11
+ font-variant: normal;
12
+ text-transform: none;
13
+ line-height: 1;
14
+ /* Better Font Rendering =========== */
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale; }
17
+ [class^="cpacicon-"]:before, [class*=" cpacicon-"]:before {
18
+ font-size: 100%; }
19
+
20
+ .cpacicon-move:before {
21
+ content: ""; }
22
+
23
+ /* Dynamic variables */
24
+ /**
25
+ * UI Sortable Plugin
26
+ * ----------------------------------------------------------------------------
27
+ */
28
+ .ui-sortable-helper {
29
+ -webkit-box-shadow: 1px 3px 6px 0 rgba(1, 1, 1, 0.4);
30
+ box-shadow: 1px 3px 6px 0 rgba(1, 1, 1, 0.4); }
31
+ .ui-sortable-helper .column-meta {
32
+ border-width: 1px; }
33
+
34
+ /**
35
+ * Dashicons used on list screens
36
+ * ----------------------------------------------------------------------------
37
+ */
38
+ .ac-column .comment-grey-bubble {
39
+ height: 16px;
40
+ width: 16px; }
41
+
42
+ .ac-column .comment-grey-bubble:before {
43
+ content: '\f101';
44
+ font: normal 20px/.5 'dashicons';
45
+ speak: none;
46
+ display: inline-block;
47
+ padding: 0;
48
+ top: 4px;
49
+ left: 0;
50
+ position: relative;
51
+ vertical-align: top;
52
+ -webkit-font-smoothing: antialiased;
53
+ -moz-osx-font-smoothing: grayscale;
54
+ text-decoration: none !important; }
55
+
56
+ .rtl .ac-column .comment-grey-bubble:before {
57
+ right: 0;
58
+ left: auto; }
59
+
60
+ /**
61
+ * Structure
62
+ * ----------------------------------------------------------------------------
63
+ */
64
+ .ac-admin {
65
+ margin-right: 300px;
66
+ max-width: 740px; }
67
+ .ac-admin #add-new-column-template {
68
+ display: none; }
69
+ .ac-admin .ac-left {
70
+ float: left;
71
+ width: 100%; }
72
+ .ac-admin .ac-left .column-footer a.add_column {
73
+ padding-left: 16px;
74
+ padding-right: 16px;
75
+ text-align: center; }
76
+ .ac-admin .ac-left .column-footer a.submit.save,
77
+ .ac-admin .ac-left .column-footer a.submit.update {
78
+ padding-left: 20px;
79
+ padding-right: 20px;
80
+ text-align: center; }
81
+ .ac-admin .ac-left .column-footer .submit.save {
82
+ display: inline-block; }
83
+ .ac-admin .ac-left .column-footer .submit.update {
84
+ display: none; }
85
+ .ac-admin .ac-right {
86
+ float: right;
87
+ margin-right: -300px;
88
+ width: 280px; }
89
+ .ac-admin .ac-right .ac-right-inside.fixed {
90
+ width: 280px; }
91
+ .ac-admin .column-footer .spinner {
92
+ display: none; }
93
+ .ac-admin.saving .ac-right-inside .spinner {
94
+ visibility: visible; }
95
+ .ac-admin.saving .column-footer .spinner {
96
+ margin: 4px 0 0;
97
+ background-position: center center;
98
+ float: none;
99
+ display: inline-block;
100
+ visibility: visible; }
101
+ .ac-admin.stored .ac-right .sidebox.form-actions .submit.save {
102
+ display: none; }
103
+ .ac-admin.stored .ac-right .sidebox.form-actions .submit.update {
104
+ display: block; }
105
+ .ac-admin.stored .ac-right .sidebox.form-actions .form-reset {
106
+ display: block; }
107
+ .ac-admin.stored .column-footer .submit.save {
108
+ display: none; }
109
+ .ac-admin.stored .column-footer .submit.update {
110
+ display: inline-block; }
111
+
112
+ /**
113
+ * Columns
114
+ * ----------------------------------------------------------------------------
115
+ */
116
+ .ac-left .ac-notice {
117
+ background: #fff;
118
+ border-left: 4px solid #ffba00;
119
+ -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
120
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
121
+ margin-bottom: 15px;
122
+ padding: 1px 12px; }
123
+
124
+ .ac-left .ajax-message {
125
+ display: none; }
126
+
127
+ .ac-left .ac-message {
128
+ margin-top: 0 !important; }
129
+
130
+ .ac-left .ac-boxes .ac-columns form {
131
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
132
+ margin: 0; }
133
+
134
+ .ac-left .ac-boxes.disabled {
135
+ opacity: 0.7; }
136
+ .ac-left .ac-boxes.disabled a.remove-button,
137
+ .ac-left .ac-boxes.disabled a.clone-button,
138
+ .ac-left .ac-boxes.disabled .column_action {
139
+ display: none !important; }
140
+ .ac-left .ac-boxes.disabled .column-meta td.column_sort {
141
+ display: none; }
142
+ .ac-left .ac-boxes.disabled .column-meta td.column_label {
143
+ padding-left: 10px; }
144
+ .ac-left .ac-boxes.disabled .meta span {
145
+ cursor: default !important;
146
+ opacity: 0.45; }
147
+ .ac-left .ac-boxes.disabled .meta span:before {
148
+ color: #808080 !important; }
149
+ .ac-left .ac-boxes.disabled .meta span.on {
150
+ opacity: 1; }
151
+ .ac-left .ac-boxes.disabled .column-footer {
152
+ display: none; }
153
+
154
+ /**
155
+ * Column States
156
+ * ----------------------------------------------------------------------------
157
+ */
158
+ .ac-column a {
159
+ cursor: pointer; }
160
+ .ac-column a:focus, .ac-column a:active {
161
+ box-shadow: none; }
162
+
163
+ .ac-column.loading .ac-column-body > .spinner {
164
+ position: absolute;
165
+ left: 50%;
166
+ top: 50%;
167
+ z-index: 200;
168
+ margin-left: -10px;
169
+ margin-top: -10px;
170
+ display: block; }
171
+
172
+ .ac-column.loading .ac-column-body:before {
173
+ content: '';
174
+ position: absolute;
175
+ width: 100%;
176
+ height: 100%;
177
+ background: #FFF;
178
+ z-index: 100;
179
+ opacity: 0.5; }
180
+
181
+ .ac-column.opened {
182
+ margin-bottom: -1px; }
183
+ .ac-column.opened .ac-column-header {
184
+ background-color: #eaeaea;
185
+ border-color: #cccccc; }
186
+ .ac-column.opened .ac-column-header:hover .column_label .inner > a.close-button {
187
+ display: inline-block; }
188
+ .ac-column.opened .ac-column-header .column_edit:after {
189
+ content: "\f142"; }
190
+ .ac-column.opened .ac-column-header table td {
191
+ border-color: #f8f8f8;
192
+ color: #333;
193
+ text-shadow: 0 1px 0 #FFFFFF; }
194
+ .ac-column.opened .ac-column-header table td a {
195
+ color: #333;
196
+ text-shadow: 0 1px 0 #FFFFFF; }
197
+ .ac-column.opened .ac-column-header table td.column_sort span {
198
+ color: #9b9b9b; }
199
+ .ac-column.opened .ac-column-header table td.column_label .meta span {
200
+ color: #8d8d8d;
201
+ text-shadow: none; }
202
+ .ac-column.opened .ac-column-header table td.column_label a.edit-button {
203
+ display: none; }
204
+ .ac-column.opened .ac-column-header table td.column_type {
205
+ color: #5C5C5C; }
206
+ .ac-column.opened .ac-column-header table td.column_edit:after {
207
+ color: #9b9b9b; }
208
+ .ac-column.opened .ac-column-body {
209
+ border: 1px solid #cccccc;
210
+ border-top: 1px solid #d4d4d4; }
211
+
212
+ /**
213
+ * Column Settings
214
+ * ----------------------------------------------------------------------------
215
+ */
216
+ .ac-column-setting {
217
+ width: 100%;
218
+ clear: both;
219
+ border-spacing: 0;
220
+ margin: 0;
221
+ border-top: 1px solid #e8e8e8; }
222
+ .ac-column-setting:first-child {
223
+ border-top: 0; }
224
+ .ac-column-setting tr.hide {
225
+ display: none; }
226
+ .ac-column-setting tr td {
227
+ vertical-align: top;
228
+ border: none;
229
+ padding: 0;
230
+ background: #fff; }
231
+ .ac-column-setting td.col-label {
232
+ position: relative;
233
+ line-height: 24px;
234
+ overflow: visible;
235
+ background: #f5f5f5;
236
+ border-right: 1px solid #dedede;
237
+ width: 34%;
238
+ padding: 10px;
239
+ padding-left: 12px; }
240
+ .ac-column-setting td.col-label span.label {
241
+ font-weight: bold;
242
+ display: block;
243
+ color: #333333;
244
+ font-style: normal; }
245
+ .ac-column-setting td.col-label div.tooltip {
246
+ font-size: 12px;
247
+ font-style: normal;
248
+ line-height: 16px;
249
+ margin: 0 !important;
250
+ display: none;
251
+ position: absolute;
252
+ max-width: 200px;
253
+ z-index: 99;
254
+ top: 40px;
255
+ left: 0;
256
+ font-weight: normal;
257
+ color: #fff;
258
+ background-color: #333;
259
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
260
+ padding: .618em 1em;
261
+ border-radius: 3px; }
262
+ .ac-column-setting td.col-label div.tooltip em {
263
+ margin-top: 3px;
264
+ display: block;
265
+ color: #999; }
266
+ .ac-column-setting td.col-input div.msg {
267
+ margin-top: 5px;
268
+ display: none;
269
+ color: #333;
270
+ padding: 6px 10px;
271
+ background-color: #ffebe8;
272
+ border: 1px solid #fff;
273
+ -moz-border-radius: 3px;
274
+ -webkit-border-radius: 3px;
275
+ border-radius: 3px; }
276
+ .ac-column-setting td.col-input div.msg p {
277
+ margin: 0.5em 0 1em 0; }
278
+ .ac-column-setting td.col-input div.msg a.button {
279
+ margin-bottom: 1em; }
280
+ .ac-column-setting td.col-input .help-msg {
281
+ margin: 10px 0 0;
282
+ color: #666;
283
+ font-size: 13px; }
284
+ .ac-column-setting .ac-column-setting td.col_label {
285
+ background-color: #fcfcfc; }
286
+ .ac-column-setting .ac-column-setting td.col_label .label {
287
+ font-size: 12px;
288
+ color: #595959; }
289
+ .ac-column-setting span.ac-setting-error {
290
+ display: block;
291
+ margin: 0;
292
+ background-color: #ffebe8;
293
+ padding: 7px 10px; }
294
+
295
+ .ac-column-setting-actions .col-settings p {
296
+ padding-left: 10px; }
297
+
298
+ .ac-column-setting-actions .col-settings a {
299
+ text-decoration: none; }
300
+ .ac-column-setting-actions .col-settings a.close-button, .ac-column-setting-actions .col-settings a.clone-button {
301
+ margin-right: 10px; }
302
+ .ac-column-setting-actions .col-settings a.remove-button {
303
+ color: #a00;
304
+ text-decoration: none;
305
+ text-shadow: none;
306
+ margin-right: 5px; }
307
+ .ac-column-setting-actions .col-settings a.remove-button:hover {
308
+ color: #f00; }
309
+
310
+ .ac-setting-input {
311
+ padding: 10px;
312
+ line-height: 24px; }
313
+ .ac-setting-input input, .ac-setting-input select {
314
+ width: 99.95%; }
315
+ .ac-setting-input input[type=checkbox],
316
+ .ac-setting-input input[type=radio] {
317
+ width: auto;
318
+ margin-right: 4px; }
319
+ .ac-setting-input .checkbox-labels > label,
320
+ .ac-setting-input .radio-labels > label {
321
+ padding-right: 10px;
322
+ vertical-align: top; }
323
+ .ac-setting-input .checkbox-labels.vertical input[type=radio],
324
+ .ac-setting-input .radio-labels.vertical input[type=radio] {
325
+ margin-right: 6px; }
326
+ .ac-setting-input .checkbox-labels.vertical > label,
327
+ .ac-setting-input .radio-labels.vertical > label {
328
+ display: block;
329
+ margin-bottom: 5px; }
330
+
331
+ .ac-setting-input-date .ac-setting-input-date__custom {
332
+ display: inline-block;
333
+ width: 71px;
334
+ margin-right: 5px; }
335
+
336
+ .ac-setting-input-date .ac-setting-input-date__value {
337
+ display: inline-block;
338
+ width: 165px; }
339
+
340
+ .ac-setting-input-date .ac-setting-input-date__example {
341
+ margin-left: 8px; }
342
+ .ac-setting-input-date .ac-setting-input-date__example .spinner {
343
+ float: none;
344
+ vertical-align: top; }
345
+
346
+ .ac-setting-input-date code {
347
+ display: inline-block;
348
+ min-width: 60px;
349
+ padding-top: 0;
350
+ padding-bottom: 0;
351
+ text-align: center; }
352
+
353
+ .ac-setting-input-width {
354
+ position: relative; }
355
+ .ac-setting-input-width div.description {
356
+ font-size: 12px;
357
+ width: 68px;
358
+ position: absolute;
359
+ display: table; }
360
+ .ac-setting-input-width div.description input {
361
+ margin: 0;
362
+ text-align: right;
363
+ vertical-align: middle;
364
+ display: table-cell; }
365
+ .ac-setting-input-width div.description input::-webkit-input-placeholder {
366
+ font-size: 13px; }
367
+ .ac-setting-input-width div.description input:-moz-placeholder {
368
+ font-size: 13px; }
369
+ .ac-setting-input-width div.description input::-moz-placeholder {
370
+ font-size: 13px; }
371
+ .ac-setting-input-width div.description input:-ms-input-placeholder {
372
+ font-size: 13px; }
373
+ .ac-setting-input-width div.description span {
374
+ background: #efefef;
375
+ display: table-cell;
376
+ width: 26px;
377
+ line-height: 23px;
378
+ text-align: center;
379
+ vertical-align: middle;
380
+ border: 1px solid #dedede;
381
+ border-left: none;
382
+ color: #505050; }
383
+ .ac-setting-input-width div.width-slider {
384
+ margin-left: 82px;
385
+ margin-right: 88px;
386
+ position: relative;
387
+ top: 8px; }
388
+ .ac-setting-input-width div.width-slider .ui-slider-handle {
389
+ cursor: ew-resize; }
390
+ .ac-setting-input-width div.unit-select {
391
+ position: absolute;
392
+ top: 11px;
393
+ right: 6px;
394
+ width: 82px;
395
+ text-align: right; }
396
+ .ac-setting-input-width div.unit-select .radio-labels {
397
+ padding: 0; }
398
+ .ac-setting-input-width div.unit-select .radio-labels label {
399
+ padding: 0;
400
+ margin-right: 6px; }
401
+ .ac-setting-input-width div.unit-select .radio-labels label input {
402
+ margin-right: 2px; }
403
+
404
+ /**
405
+ * Column Header
406
+ * ----------------------------------------------------------------------------
407
+ */
408
+ .ac-column-header {
409
+ border-style: solid;
410
+ border-color: #dfdfdf;
411
+ border-width: 1px 1px 0;
412
+ background: #fcfcfc; }
413
+ .ac-column-header:nth-child(2n) .column-meta {
414
+ background: #f9f9f9; }
415
+ .ac-column-header img {
416
+ margin-right: 3px; }
417
+ .ac-column-header table {
418
+ border: none;
419
+ background: transparent;
420
+ border-radius: 0; }
421
+ .ac-column-header table tr td {
422
+ vertical-align: top;
423
+ height: 18px;
424
+ padding: 12px 8px;
425
+ border-width: 1px 0 0;
426
+ border-style: solid;
427
+ border-color: transparent; }
428
+ .ac-column-header table tr td.column_sort {
429
+ position: relative;
430
+ cursor: move;
431
+ padding: 9px 16px; }
432
+ .ac-column-header table tr td.column_sort span.cpacicon-move {
433
+ position: absolute;
434
+ top: 12px;
435
+ left: 12px;
436
+ font-size: 22px;
437
+ display: inline-block;
438
+ color: #bdbdbd; }
439
+ .ac-column-header table tr td.column_label {
440
+ width: 70%;
441
+ font-weight: bold;
442
+ vertical-align: middle;
443
+ position: relative;
444
+ padding: 15px 0; }
445
+ .ac-column-header table tr td.column_label .inner {
446
+ position: relative;
447
+ overflow: hidden;
448
+ height: 18px; }
449
+ .ac-column-header table tr td.column_label .inner > a {
450
+ color: #5a5a5a;
451
+ padding: 0 4px; }
452
+ .ac-column-header table tr td.column_label .inner > a:hover {
453
+ color: #333333; }
454
+ .ac-column-header table tr td.column_label .inner > a.edit-button, .ac-column-header table tr td.column_label .inner > a.close-button, .ac-column-header table tr td.column_label .inner > a.remove-button, .ac-column-header table tr td.column_label .inner > a.clone-button {
455
+ display: none;
456
+ color: #0074a2;
457
+ text-decoration: none;
458
+ text-shadow: none;
459
+ font-weight: normal;
460
+ margin-left: 5px;
461
+ font-size: 12px; }
462
+ .ac-column-header table tr td.column_label .inner > a.edit-button:hover, .ac-column-header table tr td.column_label .inner > a.close-button:hover, .ac-column-header table tr td.column_label .inner > a.remove-button:hover, .ac-column-header table tr td.column_label .inner > a.clone-button:hover {
463
+ color: #2ea2cc; }
464
+ .ac-column-header table tr td.column_label .inner > a.remove-button {
465
+ color: #a00; }
466
+ .ac-column-header table tr td.column_label .inner > a.remove-button:hover {
467
+ color: #f00; }
468
+ .ac-column-header table tr td.column_label .inner .meta {
469
+ display: inline-block;
470
+ float: right;
471
+ font-weight: normal;
472
+ color: #b2b2b2;
473
+ font-size: 12px; }
474
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting {
475
+ cursor: pointer;
476
+ margin-left: 4px; }
477
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-heading-setting--width {
478
+ margin-right: 3px;
479
+ cursor: auto;
480
+ color: #737373; }
481
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator {
482
+ margin-left: 3px;
483
+ font-size: 24px;
484
+ line-height: 17px;
485
+ width: 22px; }
486
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.ac-column-indicator--filter {
487
+ font-size: 20px; }
488
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.on, .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.on span {
489
+ color: #21759B; }
490
+ .ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.disabled {
491
+ cursor: default; }
492
+ .ac-column-header table tr td.column_label span.vers {
493
+ float: left; }
494
+ .ac-column-header table tr td.column_type {
495
+ width: auto;
496
+ min-width: 120px;
497
+ text-align: right;
498
+ color: #999999;
499
+ padding-right: 0; }
500
+ .ac-column-header table tr td.column_type .inner {
501
+ display: inline-block;
502
+ height: 18px;
503
+ overflow: hidden;
504
+ text-overflow: ellipsis;
505
+ white-space: nowrap;
506
+ width: 120px;
507
+ vertical-align: middle; }
508
+ .ac-column-header table tr td.column_type .inner a {
509
+ margin-top: 2px;
510
+ color: #999999; }
511
+ .ac-column-header table tr td.column_edit {
512
+ width: 38px;
513
+ min-width: 38px;
514
+ text-align: center;
515
+ cursor: pointer; }
516
+ .ac-column-header table tr td.column_edit:after {
517
+ right: 0;
518
+ content: "\f140";
519
+ font: normal 20px/1 dashicons;
520
+ speak: none;
521
+ display: inline-block;
522
+ padding: 0 5px 0 0;
523
+ bottom: 0;
524
+ position: relative;
525
+ vertical-align: bottom;
526
+ -webkit-font-smoothing: antialiased;
527
+ -moz-osx-font-smoothing: grayscale;
528
+ text-decoration: none !important;
529
+ color: #b4b9be; }
530
+ .ac-column-header table tr:hover td.column_sort span {
531
+ color: #9b9b9b; }
532
+ .ac-column-header:hover .column_label .inner > a.remove-button, .ac-column-header:hover .column_label .inner > a.edit-button, .ac-column-header:hover .column_label .inner > a.clone-button {
533
+ display: inline-block; }
534
+ .ac-column-header span.vers {
535
+ padding-top: 2px; }
536
+ .ac-column-header span.vers .comment-grey-bubble {
537
+ float: right; }
538
+
539
+ /**
540
+ * Column Body
541
+ * ----------------------------------------------------------------------------
542
+ */
543
+ .ac-column-body {
544
+ display: none;
545
+ border-width: 1px 1px 0;
546
+ border-style: solid;
547
+ border-color: #dfdfdf;
548
+ position: relative; }
549
+
550
+ /**
551
+ * Column: Footer
552
+ * ----------------------------------------------------------------------------
553
+ */
554
+ .column-footer {
555
+ background: #EAF2FA;
556
+ border: 1px solid #c7d7e2;
557
+ min-height: 26px;
558
+ padding: 8px;
559
+ overflow: hidden; }
560
+ .column-footer .order-message {
561
+ background: transparent url("../images/order_arrow.png") no-repeat 0 0;
562
+ color: #7A9BBE;
563
+ float: left;
564
+ font-family: Comic Sans MS, sans-serif;
565
+ font-size: 11px;
566
+ height: 13px;
567
+ line-height: 1em;
568
+ margin-left: 4px;
569
+ padding: 7px 0 0 22px;
570
+ text-shadow: 0 1px 0 #FFFFFF;
571
+ display: inline-block; }
572
+ .column-footer .button-container {
573
+ float: right;
574
+ display: inline-block;
575
+ min-height: 29px; }
576
+ .column-footer .button-container a {
577
+ display: inline-block;
578
+ margin-left: 5px;
579
+ vertical-align: top; }
580
+ .column-footer .button-container a.clear-columns {
581
+ color: #BC0B0B;
582
+ text-decoration: none;
583
+ margin-right: 8px;
584
+ margin-top: 5px; }
585
+ .column-footer .button-container a.clear-columns:hover {
586
+ color: #f00; }
587
+
588
+ /**
589
+ * Sidebar
590
+ * ----------------------------------------------------------------------------
591
+ */
592
+ .ac-right .sidebox {
593
+ background: none repeat scroll 0 0 #FFFFFF;
594
+ border: 1px solid #dedede;
595
+ border-radius: 0 0 0 0;
596
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
597
+ position: relative;
598
+ margin-bottom: 14px; }
599
+ .ac-right .sidebox h3 {
600
+ padding: 10px;
601
+ margin: 0;
602
+ position: relative; }
603
+ .ac-right .sidebox h3.title {
604
+ font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
605
+ font-size: 15px;
606
+ font-weight: normal;
607
+ line-height: 1;
608
+ margin: 0;
609
+ padding: 7px 10px;
610
+ background: #f1f1f1;
611
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9));
612
+ background-image: -webkit-linear-gradient(bottom, #ececec, #f9f9f9);
613
+ background-image: -moz-linear-gradient(bottom, #ececec, #f9f9f9);
614
+ background-image: -o-linear-gradient(bottom, #ececec, #f9f9f9);
615
+ background-image: linear-gradient(to top, #ececec, #f9f9f9);
616
+ border-bottom-color: #dfdfdf;
617
+ text-shadow: #fff 0 1px 0;
618
+ -webkit-box-shadow: 0 1px 0 #fff;
619
+ box-shadow: 0 1px 0 #fff;
620
+ border-bottom-style: solid;
621
+ border-bottom-width: 1px; }
622
+ .ac-right .sidebox h3 span.left {
623
+ position: relative;
624
+ background: #fff;
625
+ z-index: 2;
626
+ padding-right: 8px; }
627
+ .ac-right .sidebox h3 span.contenttype {
628
+ display: block;
629
+ line-height: 20px;
630
+ font-size: 12px;
631
+ text-transform: uppercase;
632
+ color: #808080;
633
+ margin-top: 4px; }
634
+ .ac-right .sidebox h3 span.contenttype.right {
635
+ position: absolute;
636
+ display: inline-block;
637
+ z-index: 1;
638
+ right: 10px;
639
+ text-align: right;
640
+ margin-top: 0; }
641
+ .ac-right .sidebox .inside {
642
+ padding: 10px; }
643
+ .ac-right .sidebox .inside p {
644
+ margin-top: 0; }
645
+ .ac-right .sidebox.form-actions .form-reset {
646
+ display: none;
647
+ border-bottom: 1px solid #F5F5F5;
648
+ padding: 8px; }
649
+ .ac-right .sidebox.form-actions .reset-column-type {
650
+ text-decoration: none;
651
+ color: #BC0B0B;
652
+ line-height: 25px;
653
+ display: inline-block;
654
+ background: none;
655
+ border: none;
656
+ padding: 0;
657
+ font-size: 13px;
658
+ cursor: pointer;
659
+ margin: 0; }
660
+ .ac-right .sidebox.form-actions .reset-column-type:hover {
661
+ color: #f00; }
662
+ .ac-right .sidebox.form-actions .form-update {
663
+ padding: 8px;
664
+ overflow: hidden; }
665
+ .ac-right .sidebox.form-actions .submit {
666
+ display: none;
667
+ width: 100%;
668
+ height: 28px;
669
+ line-height: 28px;
670
+ text-align: center; }
671
+ .ac-right .sidebox.form-actions .submit.save {
672
+ display: block; }
673
+ .ac-right .sidebox#direct-feedback #feedback-support,
674
+ .ac-right .sidebox#direct-feedback #feedback-rate {
675
+ display: none; }
676
+ .ac-right .sidebox#direct-feedback .inside > a {
677
+ border-radius: 4px;
678
+ border: 1px solid #CCC;
679
+ width: 48%;
680
+ height: 64px;
681
+ text-align: center;
682
+ line-height: 64px;
683
+ font-weight: bold;
684
+ color: #222;
685
+ display: inline-block;
686
+ text-decoration: none; }
687
+ .ac-right .sidebox#direct-feedback .inside > a:hover {
688
+ background: #FAFAFA; }
689
+ .ac-right .sidebox#direct-feedback .inside form textarea {
690
+ width: 100%;
691
+ height: 120px; }
692
+ .ac-right .sidebox#direct-feedback .inside form input[type="submit"] {
693
+ display: inline-block;
694
+ float: right;
695
+ border-radius: 4px;
696
+ border: 1px solid #CCC;
697
+ height: 32px;
698
+ text-align: center;
699
+ line-height: 32px;
700
+ font-weight: bold;
701
+ font-size: 12px;
702
+ padding: 0 32px;
703
+ color: #CCC;
704
+ background: none;
705
+ text-decoration: none;
706
+ cursor: pointer; }
707
+ .ac-right .sidebox#direct-feedback .inside form input[type="submit"]:hover {
708
+ background: #FAFAFA; }
709
+ .ac-right .sidebox#direct-feedback .inside form p.description {
710
+ float: left;
711
+ font-size: 10px; }
712
+ .ac-right .sidebox#direct-feedback .inside ul {
713
+ margin: 0; }
714
+ .ac-right .sidebox#direct-feedback .inside ul.share li {
715
+ margin: 0;
716
+ display: block;
717
+ float: left;
718
+ margin-left: 9px;
719
+ width: 30%; }
720
+ .ac-right .sidebox#direct-feedback .inside ul.share li a {
721
+ text-decoration: none;
722
+ vertical-align: middle;
723
+ line-height: 20px;
724
+ padding: 16px 0;
725
+ width: 100%;
726
+ text-align: center;
727
+ border: 1px solid #CCC;
728
+ border-radius: 4px;
729
+ display: block; }
730
+ .ac-right .sidebox#direct-feedback .inside ul.share li a:hover {
731
+ background: #FAFAFA; }
732
+ .ac-right .sidebox#direct-feedback .inside ul.share li:first-child {
733
+ margin-left: 0; }
734
+ .ac-right .sidebox#direct-feedback #feedback-support .inside ul.share li {
735
+ width: 48%; }
736
+
737
+ /**
738
+ * Side box
739
+ * ----------------------------------------------------------------------------
740
+ */
741
+ #ac-pro-version {
742
+ background: none; }
743
+ #ac-pro-version .padding-box {
744
+ padding: 20px 10px 10px;
745
+ background: #3d4350;
746
+ color: #fff; }
747
+ #ac-pro-version .nopadding {
748
+ margin: 0;
749
+ padding: 0; }
750
+ #ac-pro-version h2 {
751
+ color: #fff; }
752
+ #ac-pro-version h3 {
753
+ font-size: 34px; }
754
+ #ac-pro-version h3 a {
755
+ text-decoration: none;
756
+ color: #fff; }
757
+ #ac-pro-version h3 a span {
758
+ color: #e9426e; }
759
+ #ac-pro-version .acp-button {
760
+ background: #e9426e;
761
+ border: none;
762
+ color: #fff;
763
+ text-decoration: none;
764
+ text-align: center;
765
+ display: block;
766
+ padding: 6px 20px;
767
+ border-radius: 3px;
768
+ cursor: pointer; }
769
+ #ac-pro-version .more {
770
+ color: #FFEE85;
771
+ text-decoration: none; }
772
+ #ac-pro-version .more:hover {
773
+ text-decoration: underline; }
774
+ #ac-pro-version p.center {
775
+ text-align: center; }
776
+ #ac-pro-version p.nomargin {
777
+ margin-bottom: 0; }
778
+ #ac-pro-version ul.features a:hover {
779
+ text-decoration: underline; }
780
+ #ac-pro-version ul li {
781
+ padding-bottom: 3px; }
782
+ #ac-pro-version ul li a {
783
+ color: #fff;
784
+ text-decoration: none; }
785
+ #ac-pro-version ul li a:before {
786
+ content: '\2713';
787
+ font-weight: bold;
788
+ font-size: 16px;
789
+ display: inline-block;
790
+ vertical-align: top;
791
+ margin-right: 10px; }
792
+ #ac-pro-version ul li.acp-integration {
793
+ padding: 0;
794
+ min-height: 23px;
795
+ line-height: 23px; }
796
+ #ac-pro-version ul li.acp-integration img {
797
+ height: 23px;
798
+ display: inline-block;
799
+ vertical-align: middle;
800
+ margin-right: 3px; }
801
+ #ac-pro-version ul li.acp-integration img.ac-addon-pods {
802
+ margin-top: -4px; }
803
+ #ac-pro-version ul li.acp-integration img.ac-addon-types {
804
+ height: 18px; }
805
+ #ac-pro-version ul li.acp-integration img.cac-addon-acf {
806
+ margin-top: -4px;
807
+ height: 15px; }
808
+ #ac-pro-version ul li.acp-integration a:before {
809
+ content: '+'; }
810
+ #ac-pro-version .padding-box.ac-pro-deal {
811
+ color: #3d4350;
812
+ padding-bottom: 20px;
813
+ text-align: center;
814
+ background: #ffef8f; }
815
+ #ac-pro-version .padding-box.ac-pro-deal h3 {
816
+ font-size: 20px;
817
+ line-height: 26px;
818
+ padding-top: 0;
819
+ padding-bottom: 0;
820
+ margin-bottom: 18px; }
821
+ #ac-pro-version .padding-box.ac-pro-deal a.acp-button {
822
+ font-size: 16px; }
823
+ #ac-pro-version .padding-box.ac-pro-newsletter {
824
+ background: #fff;
825
+ color: #3d4350; }
826
+ #ac-pro-version .padding-box.ac-pro-newsletter h3 {
827
+ font-size: 20px;
828
+ padding-bottom: 0; }
829
+ #ac-pro-version .padding-box.ac-pro-newsletter input {
830
+ width: 100%;
831
+ margin-bottom: 8px; }
832
+ #ac-pro-version .padding-box.ac-pro-newsletter .acp-button {
833
+ margin-top: 12px;
834
+ margin-bottom: 0;
835
+ padding: 7px 20px; }
836
+ #ac-pro-version .acp-button {
837
+ background: #e9426e;
838
+ border: none;
839
+ color: #fff;
840
+ text-decoration: none;
841
+ text-align: center;
842
+ display: block;
843
+ padding: 6px 20px;
844
+ border-radius: 3px; }
845
+
846
+ /**
847
+ * Responsive
848
+ * ----------------------------------------------------------------------------
849
+ */
850
+ @media only screen and (max-width: 900px) {
851
+ .ac-admin {
852
+ margin-right: 0; }
853
+ .ac-admin .menu {
854
+ float: none; }
855
+ .ac-admin .ac-left {
856
+ float: none; }
857
+ .ac-admin .ac-right {
858
+ float: none;
859
+ margin-top: 0;
860
+ margin-right: 0;
861
+ width: 100%; } }
assets/css/admin-page-columns.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @charset "UTF-8";@font-face{font-family:cpac_icons;src:url(../fonts/cpac_icons.woff) format("woff")}[class*=" cpacicon-"],[class^=cpacicon-]{font-family:cpac_icons;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[class*=" cpacicon-"]:before,[class^=cpacicon-]:before{font-size:100%}.cpacicon-move:before{content:""}.ui-sortable-helper{box-shadow:1px 3px 6px 0 rgba(1,1,1,.4)}.ui-sortable-helper .column-meta{border-width:1px}.ac-column .comment-grey-bubble{height:16px;width:16px}.ac-column .comment-grey-bubble:before{content:"\f101";font:normal 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;left:0;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.rtl .ac-column .comment-grey-bubble:before{right:0;left:auto}.ac-admin{margin-right:300px;max-width:740px}.ac-admin #add-new-column-template{display:none}.ac-admin .ac-left{float:left;width:100%}.ac-admin .ac-left .column-footer a.add_column{padding-left:16px;padding-right:16px;text-align:center}.ac-admin .ac-left .column-footer a.submit.save,.ac-admin .ac-left .column-footer a.submit.update{padding-left:20px;padding-right:20px;text-align:center}.ac-admin .ac-left .column-footer .submit.save{display:inline-block}.ac-admin .ac-left .column-footer .submit.update{display:none}.ac-admin .ac-right{float:right;margin-right:-300px;width:280px}.ac-admin .ac-right .ac-right-inside.fixed{width:280px}.ac-admin .column-footer .spinner{display:none}.ac-admin.saving .ac-right-inside .spinner{visibility:visible}.ac-admin.saving .column-footer .spinner{margin:4px 0 0;background-position:50%;float:none;display:inline-block;visibility:visible}.ac-admin.stored .ac-right .sidebox.form-actions .submit.save{display:none}.ac-admin.stored .ac-right .sidebox.form-actions .form-reset,.ac-admin.stored .ac-right .sidebox.form-actions .submit.update{display:block}.ac-admin.stored .column-footer .submit.save{display:none}.ac-admin.stored .column-footer .submit.update{display:inline-block}.ac-left .ac-notice{background:#fff;border-left:4px solid #ffba00;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin-bottom:15px;padding:1px 12px}.ac-left .ajax-message{display:none}.ac-left .ac-message{margin-top:0!important}.ac-left .ac-boxes .ac-columns form{box-shadow:0 1px 3px rgba(0,0,0,.1);margin:0}.ac-left .ac-boxes.disabled{opacity:.7}.ac-left .ac-boxes.disabled .column_action,.ac-left .ac-boxes.disabled a.clone-button,.ac-left .ac-boxes.disabled a.remove-button{display:none!important}.ac-left .ac-boxes.disabled .column-meta td.column_sort{display:none}.ac-left .ac-boxes.disabled .column-meta td.column_label{padding-left:10px}.ac-left .ac-boxes.disabled .meta span{cursor:default!important;opacity:.45}.ac-left .ac-boxes.disabled .meta span:before{color:gray!important}.ac-left .ac-boxes.disabled .meta span.on{opacity:1}.ac-left .ac-boxes.disabled .column-footer{display:none}.ac-column a{cursor:pointer}.ac-column a:active,.ac-column a:focus{box-shadow:none}.ac-column.loading .ac-column-body>.spinner{position:absolute;left:50%;top:50%;z-index:5;margin-left:-10px;margin-top:-10px;display:block}.ac-column.loading .ac-column-body:before{content:"";position:absolute;width:100%;height:100%;background:#fff;z-index:4;opacity:.5}.ac-column.opened{margin-bottom:-1px}.ac-column.opened .ac-column-header{background-color:#eaeaea;border-color:#ccc}.ac-column.opened .ac-column-header:hover .column_label .inner>a.close-button{display:inline-block}.ac-column.opened .ac-column-header .column_edit:after{content:"\f142"}.ac-column.opened .ac-column-header table td{border-color:#f8f8f8;color:#333;text-shadow:0 1px 0 #fff}.ac-column.opened .ac-column-header table td a{color:#333;text-shadow:0 1px 0 #fff}.ac-column.opened .ac-column-header table td.column_sort span{color:#9b9b9b}.ac-column.opened .ac-column-header table td.column_label .meta span{color:#8d8d8d;text-shadow:none}.ac-column.opened .ac-column-header table td.column_label a.edit-button{display:none}.ac-column.opened .ac-column-header table td.column_type{color:#5c5c5c}.ac-column.opened .ac-column-header table td.column_edit:after{color:#9b9b9b}.ac-column.opened .ac-column-body{border:1px solid #ccc;border-top:1px solid #d4d4d4}.ac-column-setting{width:100%;clear:both;border-spacing:0;margin:0;border-top:1px solid #e8e8e8}.ac-column-setting:first-child{border-top:0}.ac-column-setting tr.hide{display:none}.ac-column-setting tr td{vertical-align:top;border:none;padding:0;background:#fff}.ac-column-setting td.col-label{position:relative;line-height:24px;overflow:visible;background:#f5f5f5;border-right:1px solid #dedede;width:34%;padding:10px;padding-left:12px}.ac-column-setting td.col-label span.label{font-weight:700;display:block;color:#333;font-style:normal}.ac-column-setting td.col-label div.tooltip{font-size:12px;font-style:normal;line-height:16px;margin:0!important;display:none;position:absolute;max-width:200px;z-index:3;top:40px;left:0;font-weight:400;color:#fff;background-color:#333;box-shadow:0 1px 3px rgba(0,0,0,.2);padding:.618em 1em;border-radius:3px}.ac-column-setting td.col-label div.tooltip em{margin-top:3px;display:block;color:#999}.ac-column-setting td.col-input div.msg{margin-top:5px;display:none;color:#333;padding:6px 10px;background-color:#ffebe8;border:1px solid #fff;border-radius:3px}.ac-column-setting td.col-input div.msg p{margin:.5em 0 1em}.ac-column-setting td.col-input div.msg a.button{margin-bottom:1em}.ac-column-setting td.col-input .help-msg{margin:10px 0 0;color:#666;font-size:13px}.ac-column-setting .ac-column-setting td.col_label{background-color:#fcfcfc}.ac-column-setting .ac-column-setting td.col_label .label{font-size:12px;color:#595959}.ac-column-setting span.ac-setting-error{display:block;margin:0;background-color:#ffebe8;padding:7px 10px}.ac-column-setting-actions .col-settings p{padding-left:10px}.ac-column-setting-actions .col-settings a{text-decoration:none}.ac-column-setting-actions .col-settings a.clone-button,.ac-column-setting-actions .col-settings a.close-button{margin-right:10px}.ac-column-setting-actions .col-settings a.remove-button{color:#a00;text-decoration:none;text-shadow:none;margin-right:5px}.ac-column-setting-actions .col-settings a.remove-button:hover{color:red}.ac-setting-input{padding:10px;line-height:24px}.ac-setting-input input,.ac-setting-input select{width:99.95%}.ac-setting-input input[type=checkbox],.ac-setting-input input[type=radio]{width:auto;margin-right:4px}.ac-setting-input .checkbox-labels>label,.ac-setting-input .radio-labels>label{padding-right:10px;vertical-align:top}.ac-setting-input .checkbox-labels.vertical input[type=radio],.ac-setting-input .radio-labels.vertical input[type=radio]{margin-right:6px}.ac-setting-input .checkbox-labels.vertical>label,.ac-setting-input .radio-labels.vertical>label{display:block;margin-bottom:5px}.ac-setting-input-date .ac-setting-input-date__custom{display:inline-block;width:71px;margin-right:5px}.ac-setting-input-date .ac-setting-input-date__value{display:inline-block;width:165px}.ac-setting-input-date .ac-setting-input-date__example{margin-left:8px}.ac-setting-input-date .ac-setting-input-date__example .spinner{float:none;vertical-align:top}.ac-setting-input-date code{display:inline-block;min-width:60px;padding-top:0;padding-bottom:0;text-align:center}.ac-setting-input-width{position:relative}.ac-setting-input-width div.description{font-size:12px;width:68px;position:absolute;display:table}.ac-setting-input-width div.description input{margin:0;text-align:right;vertical-align:middle;display:table-cell}.ac-setting-input-width div.description input::-webkit-input-placeholder{font-size:13px}.ac-setting-input-width div.description input:-moz-placeholder,.ac-setting-input-width div.description input::-moz-placeholder{font-size:13px}.ac-setting-input-width div.description input:-ms-input-placeholder{font-size:13px}.ac-setting-input-width div.description span{background:#efefef;display:table-cell;width:26px;line-height:23px;text-align:center;vertical-align:middle;border:1px solid #dedede;border-left:none;color:#505050}.ac-setting-input-width div.width-slider{margin-left:82px;margin-right:88px;position:relative;top:8px}.ac-setting-input-width div.width-slider .ui-slider-handle{cursor:ew-resize}.ac-setting-input-width div.unit-select{position:absolute;top:11px;right:6px;width:82px;text-align:right}.ac-setting-input-width div.unit-select .radio-labels{padding:0}.ac-setting-input-width div.unit-select .radio-labels label{padding:0;margin-right:6px}.ac-setting-input-width div.unit-select .radio-labels label input{margin-right:2px}.ac-column-header{border-style:solid;border-color:#dfdfdf;border-width:1px 1px 0;background:#fcfcfc}.ac-column-header:nth-child(2n) .column-meta{background:#f9f9f9}.ac-column-header img{margin-right:3px}.ac-column-header table{border:none;background:transparent;border-radius:0}.ac-column-header table tr td{vertical-align:top;height:18px;padding:12px 8px;border-width:1px 0 0;border-style:solid;border-color:transparent}.ac-column-header table tr td.column_sort{position:relative;cursor:move;padding:9px 16px}.ac-column-header table tr td.column_sort span.cpacicon-move{position:absolute;top:12px;left:12px;font-size:22px;display:inline-block;color:#bdbdbd}.ac-column-header table tr td.column_label{width:70%;font-weight:700;vertical-align:middle;position:relative;padding:15px 0}.ac-column-header table tr td.column_label .inner{position:relative;overflow:hidden;height:18px}.ac-column-header table tr td.column_label .inner>a{color:#5a5a5a;padding:0 4px}.ac-column-header table tr td.column_label .inner>a:hover{color:#333}.ac-column-header table tr td.column_label .inner>a.clone-button,.ac-column-header table tr td.column_label .inner>a.close-button,.ac-column-header table tr td.column_label .inner>a.edit-button,.ac-column-header table tr td.column_label .inner>a.remove-button{display:none;color:#0074a2;text-decoration:none;text-shadow:none;font-weight:400;margin-left:5px;font-size:12px}.ac-column-header table tr td.column_label .inner>a.clone-button:hover,.ac-column-header table tr td.column_label .inner>a.close-button:hover,.ac-column-header table tr td.column_label .inner>a.edit-button:hover,.ac-column-header table tr td.column_label .inner>a.remove-button:hover{color:#2ea2cc}.ac-column-header table tr td.column_label .inner>a.remove-button{color:#a00}.ac-column-header table tr td.column_label .inner>a.remove-button:hover{color:red}.ac-column-header table tr td.column_label .inner .meta{display:inline-block;float:right;font-weight:400;color:#b2b2b2;font-size:12px}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting{cursor:pointer;margin-left:4px}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-heading-setting--width{margin-right:3px;cursor:auto;color:#737373}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator{margin-left:3px;font-size:24px;line-height:17px;width:22px}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.ac-column-indicator--filter{font-size:20px}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.on,.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.ac-column-indicator.on span{color:#21759b}.ac-column-header table tr td.column_label .inner .meta .ac-column-heading-setting.disabled{cursor:default}.ac-column-header table tr td.column_label span.vers{float:left}.ac-column-header table tr td.column_type{width:auto;min-width:120px;text-align:right;color:#999;padding-right:0}.ac-column-header table tr td.column_type .inner{display:inline-block;height:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:120px;vertical-align:middle}.ac-column-header table tr td.column_type .inner a{margin-top:2px;color:#999}.ac-column-header table tr td.column_edit{width:38px;min-width:38px;text-align:center;cursor:pointer}.ac-column-header table tr td.column_edit:after{right:0;content:"\f140";font:normal 20px/1 dashicons;speak:none;display:inline-block;padding:0 5px 0 0;bottom:0;position:relative;vertical-align:bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#b4b9be}.ac-column-header table tr:hover td.column_sort span{color:#9b9b9b}.ac-column-header:hover .column_label .inner>a.clone-button,.ac-column-header:hover .column_label .inner>a.edit-button,.ac-column-header:hover .column_label .inner>a.remove-button{display:inline-block}.ac-column-header span.vers{padding-top:2px}.ac-column-header span.vers .comment-grey-bubble{float:right}.ac-column-body{display:none;border-width:1px 1px 0;border-style:solid;border-color:#dfdfdf;position:relative}.column-footer{background:#eaf2fa;border:1px solid #c7d7e2;min-height:26px;padding:8px;overflow:hidden}.column-footer .order-message{background:transparent url(../images/order_arrow.png) no-repeat 0 0;color:#7a9bbe;float:left;font-family:Comic Sans MS,sans-serif;font-size:11px;height:13px;line-height:1em;margin-left:4px;padding:7px 0 0 22px;text-shadow:0 1px 0 #fff;display:inline-block}.column-footer .button-container{float:right;display:inline-block;min-height:29px}.column-footer .button-container a{display:inline-block;margin-left:5px;vertical-align:top}.column-footer .button-container a.clear-columns{color:#bc0b0b;text-decoration:none;margin-right:8px;margin-top:5px}.column-footer .button-container a.clear-columns:hover{color:red}.ac-right .sidebox{background:none repeat scroll 0 0 #fff;border:1px solid #dedede;border-radius:0 0 0 0;box-shadow:0 1px 3px rgba(0,0,0,.1);position:relative;margin-bottom:14px}.ac-right .sidebox h3{padding:10px;margin:0;position:relative}.ac-right .sidebox h3.title{font-family:Georgia,Times New Roman,Bitstream Charter,Times,serif;font-size:15px;font-weight:400;line-height:1;margin:0;padding:7px 10px;background:#f1f1f1;background-image:-webkit-gradient(linear,left bottom,left top,from(#ececec),to(#f9f9f9));background-image:-webkit-linear-gradient(bottom,#ececec,#f9f9f9);background-image:linear-gradient(0deg,#ececec,#f9f9f9);border-bottom-color:#dfdfdf;text-shadow:#fff 0 1px 0;box-shadow:0 1px 0 #fff;border-bottom-style:solid;border-bottom-width:1px}.ac-right .sidebox h3 span.left{position:relative;background:#fff;z-index:2;padding-right:8px}.ac-right .sidebox h3 span.contenttype{display:block;line-height:20px;font-size:12px;text-transform:uppercase;color:gray;margin-top:4px}.ac-right .sidebox h3 span.contenttype.right{position:absolute;display:inline-block;z-index:1;right:10px;text-align:right;margin-top:0}.ac-right .sidebox .inside{padding:10px}.ac-right .sidebox .inside p{margin-top:0}.ac-right .sidebox.form-actions .form-reset{display:none;border-bottom:1px solid #f5f5f5;padding:8px}.ac-right .sidebox.form-actions .reset-column-type{text-decoration:none;color:#bc0b0b;line-height:25px;display:inline-block;background:none;border:none;padding:0;font-size:13px;cursor:pointer;margin:0}.ac-right .sidebox.form-actions .reset-column-type:hover{color:red}.ac-right .sidebox.form-actions .form-update{padding:8px;overflow:hidden}.ac-right .sidebox.form-actions .submit{display:none;width:100%;height:28px;line-height:28px;text-align:center}.ac-right .sidebox.form-actions .submit.save{display:block}.ac-right .sidebox#direct-feedback #feedback-rate,.ac-right .sidebox#direct-feedback #feedback-support{display:none}.ac-right .sidebox#direct-feedback .inside>a{border-radius:4px;border:1px solid #ccc;width:48%;height:64px;text-align:center;line-height:64px;font-weight:700;color:#222;display:inline-block;text-decoration:none}.ac-right .sidebox#direct-feedback .inside>a:hover{background:#fafafa}.ac-right .sidebox#direct-feedback .inside form textarea{width:100%;height:120px}.ac-right .sidebox#direct-feedback .inside form input[type=submit]{display:inline-block;float:right;border-radius:4px;border:1px solid #ccc;height:32px;text-align:center;line-height:32px;font-weight:700;font-size:12px;padding:0 32px;color:#ccc;background:none;text-decoration:none;cursor:pointer}.ac-right .sidebox#direct-feedback .inside form input[type=submit]:hover{background:#fafafa}.ac-right .sidebox#direct-feedback .inside form p.description{float:left;font-size:10px}.ac-right .sidebox#direct-feedback .inside ul{margin:0}.ac-right .sidebox#direct-feedback .inside ul.share li{margin:0;display:block;float:left;margin-left:9px;width:30%}.ac-right .sidebox#direct-feedback .inside ul.share li a{text-decoration:none;vertical-align:middle;line-height:20px;padding:16px 0;width:100%;text-align:center;border:1px solid #ccc;border-radius:4px;display:block}.ac-right .sidebox#direct-feedback .inside ul.share li a:hover{background:#fafafa}.ac-right .sidebox#direct-feedback .inside ul.share li:first-child{margin-left:0}.ac-right .sidebox#direct-feedback #feedback-support .inside ul.share li{width:48%}#ac-pro-version{background:none}#ac-pro-version .padding-box{padding:20px 10px 10px;background:#3d4350;color:#fff}#ac-pro-version .nopadding{margin:0;padding:0}#ac-pro-version h2{color:#fff}#ac-pro-version h3{font-size:34px}#ac-pro-version h3 a{text-decoration:none;color:#fff}#ac-pro-version h3 a span{color:#e9426e}#ac-pro-version .acp-button{cursor:pointer}#ac-pro-version .more{color:#ffee85;text-decoration:none}#ac-pro-version .more:hover{text-decoration:underline}#ac-pro-version p.center{text-align:center}#ac-pro-version p.nomargin{margin-bottom:0}#ac-pro-version ul.features a:hover{text-decoration:underline}#ac-pro-version ul li{padding-bottom:3px}#ac-pro-version ul li a{color:#fff;text-decoration:none}#ac-pro-version ul li a:before{content:"\2713";font-weight:700;font-size:16px;display:inline-block;vertical-align:top;margin-right:10px}#ac-pro-version ul li.acp-integration{padding:0;min-height:23px;line-height:23px}#ac-pro-version ul li.acp-integration img{height:23px;display:inline-block;vertical-align:middle;margin-right:3px}#ac-pro-version ul li.acp-integration img.ac-addon-pods{margin-top:-4px}#ac-pro-version ul li.acp-integration img.ac-addon-types{height:18px}#ac-pro-version ul li.acp-integration img.cac-addon-acf{margin-top:-4px;height:15px}#ac-pro-version ul li.acp-integration a:before{content:"+"}#ac-pro-version .padding-box.ac-pro-deal{color:#3d4350;padding-bottom:20px;text-align:center;background:#ffef8f}#ac-pro-version .padding-box.ac-pro-deal h3{font-size:20px;line-height:26px;padding-top:0;padding-bottom:0;margin-bottom:18px}#ac-pro-version .padding-box.ac-pro-deal a.acp-button{font-size:16px}#ac-pro-version .padding-box.ac-pro-newsletter{background:#fff;color:#3d4350}#ac-pro-version .padding-box.ac-pro-newsletter h3{font-size:20px;padding-bottom:0}#ac-pro-version .padding-box.ac-pro-newsletter input{width:100%;margin-bottom:8px}#ac-pro-version .padding-box.ac-pro-newsletter .acp-button{margin-top:12px;margin-bottom:0;padding:7px 20px}#ac-pro-version .acp-button{background:#e9426e;border:none;color:#fff;text-decoration:none;text-align:center;display:block;padding:6px 20px;border-radius:3px}@media only screen and (max-width:900px){.ac-admin{margin-right:0}.ac-admin .ac-left,.ac-admin .menu{float:none}.ac-admin .ac-right{float:none;margin-top:0;margin-right:0;width:100%}}
assets/css/admin-page-help.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .ac-deprecated-message {
2
+ background: #fff;
3
+ padding: 12px 12px;
4
+ margin: 15px 0;
5
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
6
+ border-left: 4px solid #ffb900; }
7
+ .ac-deprecated-message p {
8
+ margin: 0;
9
+ line-height: 24px; }
10
+ .ac-deprecated-message a {
11
+ display: inline-block; }
assets/css/admin-page-help.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ac-deprecated-message{background:#fff;padding:12px;margin:15px 0;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);border-left:4px solid #ffb900}.ac-deprecated-message p{margin:0;line-height:24px}.ac-deprecated-message a{display:inline-block}
assets/css/admin-page-settings.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /**
2
+ * Settings Page
3
+ * ----------------------------------------------------------------------------
4
+ */
assets/css/admin-page-settings.min.css ADDED
File without changes
assets/css/admin-welcome.css ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ @font-face {
3
+ font-family: "cpac_icons";
4
+ src: url("../fonts/cpac_icons.woff") format("woff"); }
5
+
6
+ [class^="cpacicon-"], [class*=" cpacicon-"] {
7
+ font-family: 'cpac_icons';
8
+ speak: none;
9
+ font-style: normal;
10
+ font-weight: normal;
11
+ font-variant: normal;
12
+ text-transform: none;
13
+ line-height: 1;
14
+ /* Better Font Rendering =========== */
15
+ -webkit-font-smoothing: antialiased;
16
+ -moz-osx-font-smoothing: grayscale; }
17
+ [class^="cpacicon-"]:before, [class*=" cpacicon-"]:before {
18
+ font-size: 100%; }
19
+
20
+ .cpacicon-move:before {
21
+ content: ""; }
22
+
23
+ /* Dynamic variables */
24
+ /**
25
+ * Welcome Screen
26
+ * ----------------------------------------------------------------------------
27
+ */
28
+ .cpac-content-body hr {
29
+ -moz-border-bottom-colors: none;
30
+ -moz-border-left-colors: none;
31
+ -moz-border-right-colors: none;
32
+ -moz-border-top-colors: none;
33
+ background: none repeat scroll 0 0 transparent;
34
+ border-color: #DFDFDF;
35
+ border-image: none;
36
+ border-style: solid;
37
+ border-width: 1px 0 0;
38
+ clear: both;
39
+ margin: 30px 0;
40
+ opacity: 0.2; }
41
+
42
+ #cpac-welcome.about-wrap div.error {
43
+ display: block !important; }
44
+
45
+ .cpac-alert {
46
+ display: inline-block;
47
+ background: none repeat scroll 0 0 #FCF8E3;
48
+ border: 1px solid #FBEED5;
49
+ border-radius: 4px 4px 4px 4px;
50
+ color: #C09853;
51
+ margin: 20px 0;
52
+ padding: 16px 14px;
53
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
54
+
55
+ .cpac-alert p {
56
+ margin: 0; }
57
+
58
+ .cpac-alert.cpac-alert-success {
59
+ background-color: #DFF0D8;
60
+ border-color: #D6E9C6;
61
+ color: #468847; }
62
+
63
+ .cpac-alert.cpac-alert-error {
64
+ background-color: #F2DEDE;
65
+ border-color: #EED3D7;
66
+ color: #B94A48; }
67
+
68
+ .cpac-alert a.button-primary {
69
+ height: 28px;
70
+ line-height: 28px;
71
+ display: inline-block; }
72
+
73
+ #cpac-download-add-ons-table {
74
+ max-width: 600px; }
75
+
76
+ .wp-core-ui .button-large {
77
+ height: 40px;
78
+ line-height: 40px;
79
+ font-size: 16px;
80
+ padding: 0 15px;
81
+ text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); }
assets/css/admin-welcome.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @charset "UTF-8";@font-face{font-family:cpac_icons;src:url(../fonts/cpac_icons.woff) format("woff")}[class*=" cpacicon-"],[class^=cpacicon-]{font-family:cpac_icons;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}[class*=" cpacicon-"]:before,[class^=cpacicon-]:before{font-size:100%}.cpacicon-move:before{content:""}.cpac-content-body hr{border:none;background:none repeat scroll 0 0 transparent;border-color:#dfdfdf;border-image:none;border-style:solid;border-width:1px 0 0;clear:both;margin:30px 0;opacity:.2}#cpac-welcome.about-wrap div.error{display:block!important}.cpac-alert{display:inline-block;background:none repeat scroll 0 0 #fcf8e3;border:1px solid #fbeed5;border-radius:4px 4px 4px 4px;color:#c09853;margin:20px 0;padding:16px 14px;text-shadow:0 1px 0 hsla(0,0%,100%,.5)}.cpac-alert p{margin:0}.cpac-alert.cpac-alert-success{background-color:#dff0d8;border-color:#d6e9c6;color:#468847}.cpac-alert.cpac-alert-error{background-color:#f2dede;border-color:#eed3d7;color:#b94a48}.cpac-alert a.button-primary{height:28px;line-height:28px;display:inline-block}#cpac-download-add-ons-table{max-width:600px}.wp-core-ui .button-large{height:40px;line-height:40px;font-size:16px;padding:0 15px;text-shadow:0 1px 0 rgba(0,0,0,.5)}
assets/css/column.css DELETED
@@ -1,177 +0,0 @@
1
- /* =General
2
- -------------------------------------------------------------- */
3
- .cpac-divider {
4
- display: inline-block;
5
- width: 14px;
6
- height: 12px;
7
- background: transparent url(../images/square.png) no-repeat 50% 7px;
8
- }
9
- span.status-closed {
10
- color: red;
11
- }
12
- .actions #post-query-submit {
13
- float: left;
14
- vertical-align: middle;
15
- margin-bottom: 4px;
16
- }
17
- .tablenav.top .cpac-edit {
18
- top: 2px;
19
- display: inline-block;
20
- vertical-align: middle;
21
- float: left;
22
- margin-bottom: 4px;
23
- }
24
- body.edit-tags-php .tablenav.top .cpac-edit {
25
- float: none;
26
- }
27
- .cpac_status_yes {
28
- color: #46b450;
29
- }
30
- .cpac_status_no {
31
- color: #dc3232;
32
- }
33
- body.edit-php #delete_all {
34
- float: left;
35
- margin-right: 3px;
36
- }
37
- body.users-php .tablenav .actions a.add-new-h2 {
38
- float: none;
39
- vertical-align: middle !important;
40
- top: 2px !important;
41
- }
42
- @media screen and (max-width: 782px) {
43
- .tablenav.top .actions {
44
- display: block !important;
45
- margin-bottom: 4px;
46
- }
47
- .tablenav.top .actions * {
48
- display: none;
49
- }
50
- .tablenav.top .actions .cpac-edit {
51
- display: inline-block;
52
- }
53
- }
54
- body.upload-php .tablenav.top .cpac-edit {
55
- float: none;
56
- }
57
- /* =General Column
58
- -------------------------------------------------------------- */
59
- .cpac-inline-info {
60
- display: inline-block;
61
- border-radius: 3px;
62
- min-width: 8px;
63
- padding: 0 6px;
64
- min-height: 20px;
65
- background-color: #e9e9e9;
66
- text-align: center;
67
- margin-right: 7px;
68
- font-size: 11px;
69
- font-weight: bold;
70
- }
71
- .cpac-rounded {
72
- display: inline-block;
73
- border-radius: 10px;
74
- min-width: 8px;
75
- padding: 0 6px;
76
- height: 20px;
77
- background-color: #e0e0e0;
78
- text-align: center;
79
- margin-left: 7px;
80
- font-size: 12px;
81
- }
82
- .cpac-rounded.cpac-rounded-first {
83
- margin-left: 0;
84
- }
85
- .cpac-spacing {
86
- display: inline-block;
87
- margin-right: 10px;
88
- margin-bottom: 4px;
89
- }
90
- .cpac-suffix {
91
- margin-left: 8px;
92
- color: #808080;
93
- }
94
- /* =Images Column
95
- -------------------------------------------------------------- */
96
- .cpac-column-value-image {
97
- display: inline-block;
98
- background: transparent;
99
- margin-right: 2px;
100
- overflow: hidden;
101
- max-width: 100%;
102
- }
103
- .rtl .cpac-column-value-image {
104
- margin-left: 2px;
105
- margin-right: 0;
106
- }
107
- .cpac-column-value-image img {
108
- display: block;
109
- margin: 0 auto;
110
- }
111
- .column-column-attachment img {
112
- padding-right: 5px;
113
- padding-bottom: 4px;
114
- }
115
- .rtl .column-column-attachment img {
116
- padding-left: 5px;
117
- padding-right: 0;
118
- }
119
- /* =Color Column
120
- -------------------------------------------------------------- */
121
- div.cpac-color {
122
- line-height: 26px;
123
- }
124
- div.cpac-color span {
125
- display: block;
126
- -webkit-border-radius: 3px;
127
- border-radius: 3px;
128
- color: #ffffff;
129
- float: left;
130
- height: 16px;
131
- line-height: 16px;
132
- margin-right: 12px;
133
- min-width: 30px;
134
- overflow: hidden;
135
- padding: 4px 5px;
136
- font-size: 10px;
137
- font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
138
- min-width: 47px;
139
- text-align: center;
140
- }
141
- .rtl div.cpac-color span {
142
- float: right;
143
- margin-left: 12px;
144
- margin-right: 0;
145
- }
146
- /* =Available Sizes column
147
- -------------------------------------------------------------- */
148
- div.sizes span.not-available {
149
- color: #999;
150
- }
151
- /* =Actions column
152
- -------------------------------------------------------------- */
153
- .button.cpac-button-action {
154
- position: relative;
155
- text-indent: 9999px;
156
- margin-right: 4px;
157
- padding: 0 13px;
158
- overflow: hidden;
159
- }
160
- .button.cpac-button-action:before {
161
- position: absolute;
162
- top: 0;
163
- left: 0;
164
- width: 100%;
165
- height: 100%;
166
- text-indent: 0;
167
- }
168
- /* =qTip2
169
- -------------------------------------------------------------- */
170
- .cpac-tip {
171
- display: inline-block;
172
- }
173
- .qtip.qtip-tipsy {
174
- background: rgba(0, 0, 0, 0.75);
175
- font-weight: normal;
176
- min-width: 25px;
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/column.min.css DELETED
@@ -1 +0,0 @@
1
- .actions #post-query-submit,.tablenav.top .cpac-edit{vertical-align:middle;float:left;margin-bottom:4px}.cpac-inline-info,.cpac-rounded{min-width:8px;padding:0 6px;text-align:center}.cpac-divider{display:inline-block;width:14px;height:12px;background:url(../images/square.png) 50% 7px no-repeat}span.status-closed{color:red}.tablenav.top .cpac-edit{top:2px;display:inline-block}body.edit-tags-php .tablenav.top .cpac-edit{float:none}.cpac_status_yes{color:#46b450}.cpac_status_no{color:#dc3232}body.edit-php #delete_all{float:left;margin-right:3px}body.users-php .tablenav .actions a.add-new-h2{float:none;vertical-align:middle!important;top:2px!important}@media screen and (max-width:782px){.tablenav.top .actions{display:block!important;margin-bottom:4px}.tablenav.top .actions *{display:none}.tablenav.top .actions .cpac-edit{display:inline-block}}body.upload-php .tablenav.top .cpac-edit{float:none}.cpac-inline-info{display:inline-block;border-radius:3px;min-height:20px;background-color:#e9e9e9;margin-right:7px;font-size:11px;font-weight:700}.cpac-rounded{display:inline-block;border-radius:10px;height:20px;background-color:#e0e0e0;margin-left:7px;font-size:12px}.cpac-rounded.cpac-rounded-first{margin-left:0}.cpac-spacing{display:inline-block;margin-right:10px;margin-bottom:4px}.cpac-suffix{margin-left:8px;color:grey}.cpac-column-value-image{display:inline-block;background:0 0;margin-right:2px;overflow:hidden;max-width:100%}.rtl .cpac-column-value-image{margin-left:2px;margin-right:0}.cpac-column-value-image img{display:block;margin:0 auto}.column-column-attachment img{padding-right:5px;padding-bottom:4px}.rtl .column-column-attachment img{padding-left:5px;padding-right:0}div.cpac-color{line-height:26px}div.cpac-color span{display:block;-webkit-border-radius:3px;border-radius:3px;color:#fff;float:left;height:16px;line-height:16px;margin-right:12px;overflow:hidden;padding:4px 5px;font-size:10px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;min-width:47px;text-align:center}.rtl div.cpac-color span{float:right;margin-left:12px;margin-right:0}div.sizes span.not-available{color:#999}.button.cpac-button-action{position:relative;text-indent:9999px;margin-right:4px;padding:0 13px;overflow:hidden}.button.cpac-button-action:before{position:absolute;top:0;left:0;width:100%;height:100%;text-indent:0}.cpac-tip{display:inline-block}.qtip.qtip-tipsy{background:rgba(0,0,0,.75);font-weight:400;min-width:25px}
 
assets/css/message.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body .wrap .ac-message {
2
+ position: relative;
3
+ padding-right: 40px; }
4
+
5
+ .ac-message .spinner.right {
6
+ visibility: visible;
7
+ display: block;
8
+ right: 8px;
9
+ text-decoration: none;
10
+ text-align: right;
11
+ position: absolute;
12
+ top: 50%;
13
+ margin-top: -10px; }
14
+
15
+ .ac-message .spinner.inline {
16
+ display: inline-block;
17
+ position: absolute;
18
+ margin: 4px 0 0 4px;
19
+ padding: 0;
20
+ float: none; }
21
+
22
+ .ac-message .hide-notice {
23
+ right: 8px;
24
+ text-decoration: none;
25
+ width: 32px;
26
+ text-align: right;
27
+ position: absolute;
28
+ top: 50%;
29
+ height: 32px;
30
+ margin-top: -16px; }
31
+ .ac-message .hide-notice:before {
32
+ display: block;
33
+ content: '\f335';
34
+ font-family: 'Dashicons', serif;
35
+ margin: .5em 0;
36
+ padding: 2px; }
37
+
38
+ .ac-message .buttons {
39
+ margin-top: 8px; }
40
+ .ac-message .buttons .button {
41
+ margin-right: 3px; }
42
+
43
+ .ac-message.error.warning {
44
+ border-left: 4px solid #ffba00; }
assets/css/message.min.css ADDED
@@ -0,0 +1 @@
 
1
+ body .wrap .ac-message{position:relative;padding-right:40px}.ac-message .spinner.right{visibility:visible;display:block;right:8px;text-decoration:none;text-align:right;position:absolute;top:50%;margin-top:-10px}.ac-message .spinner.inline{display:inline-block;position:absolute;margin:4px 0 0 4px;padding:0;float:none}.ac-message .hide-notice{right:8px;text-decoration:none;width:32px;text-align:right;position:absolute;top:50%;height:32px;margin-top:-16px}.ac-message .hide-notice:before{display:block;content:"\f335";font-family:Dashicons,serif;margin:.5em 0;padding:2px}.ac-message .buttons{margin-top:8px}.ac-message .buttons .button{margin-right:3px}.ac-message.error.warning{border-left:4px solid #ffba00}
assets/css/plugin-screen.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tr.plugin-update-tr-admin-columns td div {
2
+ margin: 0 !important; }
3
+ tr.plugin-update-tr-admin-columns td div.icon p:before {
4
+ display: inline-block;
5
+ font: normal 20px/1 'dashicons';
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ vertical-align: middle;
9
+ color: #f56e28; }
10
+ tr.plugin-update-tr-admin-columns td div.icon.icon-info p:before {
11
+ content: "\f348"; }
12
+ tr.plugin-update-tr-admin-columns td div.icon.icon-update p:before {
13
+ content: "\f463"; }
14
+ tr.plugin-update-tr-admin-columns td div a.button {
15
+ margin-left: 10px; }
assets/css/plugin-screen.min.css ADDED
@@ -0,0 +1 @@
 
1
+ tr.plugin-update-tr-admin-columns td div{margin:0!important}tr.plugin-update-tr-admin-columns td div.icon p:before{display:inline-block;font:normal 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:middle;color:#f56e28}tr.plugin-update-tr-admin-columns td div.icon.icon-info p:before{content:"\f348"}tr.plugin-update-tr-admin-columns td div.icon.icon-update p:before{content:"\f463"}tr.plugin-update-tr-admin-columns td div a.button{margin-left:10px}
assets/css/table.css ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* =General
2
+ -------------------------------------------------------------- */
3
+ .ac-divider {
4
+ display: inline-block;
5
+ width: 14px;
6
+ height: 12px;
7
+ background: transparent url(../images/square.png) no-repeat 50% 7px; }
8
+
9
+ span.status-closed {
10
+ color: red; }
11
+
12
+ .actions #post-query-submit {
13
+ float: left;
14
+ vertical-align: middle;
15
+ margin-bottom: 4px; }
16
+
17
+ .tablenav.top .cpac-edit {
18
+ top: 2px;
19
+ display: inline-block;
20
+ vertical-align: middle;
21
+ float: left;
22
+ margin-bottom: 4px; }
23
+ body.edit-tags-php .tablenav.top .cpac-edit {
24
+ float: none; }
25
+
26
+ span.dashicons.green {
27
+ color: #46b450; }
28
+
29
+ span.dashicons.red {
30
+ color: #dc3232; }
31
+
32
+ body.edit-php #delete_all {
33
+ float: left;
34
+ margin-right: 3px; }
35
+
36
+ body.users-php .tablenav .actions a.add-new-h2 {
37
+ float: none;
38
+ vertical-align: middle !important;
39
+ top: 2px !important; }
40
+
41
+ @media screen and (max-width: 782px) {
42
+ .tablenav.top .actions {
43
+ display: block !important;
44
+ margin-bottom: 4px; }
45
+ .tablenav.top .actions * {
46
+ display: none; }
47
+ .tablenav.top .actions .cpac-edit {
48
+ display: inline-block; } }
49
+
50
+ body.upload-php .tablenav.top .cpac-edit {
51
+ float: none; }
52
+
53
+ /* =Column values
54
+ -------------------------------------------------------------- */
55
+ .ac-toggle-box-link:focus {
56
+ outline: none;
57
+ box-shadow: none; }
58
+
59
+ .ac-toggle-box-link .spinner {
60
+ float: none;
61
+ margin-top: -2px; }
62
+
63
+ .ac-toggle-box-link.loading .spinner {
64
+ visibility: visible; }
65
+
66
+ .ac-toggle-box-contents-ajax {
67
+ padding: 5px 0 0; }
68
+
69
+ .ac-toggle-box-contents {
70
+ display: none;
71
+ padding: 5px 0 0; }
72
+
73
+ table.ac-table-items {
74
+ border-spacing: 0; }
75
+ table.ac-table-items tr td {
76
+ border: 0;
77
+ margin: 0;
78
+ padding: 0 0 3px; }
79
+ table.ac-table-items tr td.ac-table-item-qty {
80
+ color: #999;
81
+ padding-right: 6px;
82
+ text-align: left; }
83
+
84
+ /* =Storage Space column
85
+ -------------------------------------------------------------- */
86
+ .ac-upload-space .ac-upload-space-labels {
87
+ display: table;
88
+ width: 100%; }
89
+ .ac-upload-space .ac-upload-space-labels .inner {
90
+ display: table-row; }
91
+ .ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-icon {
92
+ display: table-cell; }
93
+ .ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-icon:before {
94
+ color: #82878c;
95
+ content: "\f104";
96
+ display: inline-block;
97
+ font-family: 'dashicons', serif;
98
+ width: 20px;
99
+ height: 20px;
100
+ font-size: 18px;
101
+ line-height: 1;
102
+ text-decoration: inherit;
103
+ font-weight: normal;
104
+ font-style: normal;
105
+ vertical-align: top;
106
+ text-align: center;
107
+ margin-right: 4px; }
108
+ .ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-left {
109
+ display: table-cell;
110
+ white-space: nowrap; }
111
+ .ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-right {
112
+ width: 100%;
113
+ text-align: right;
114
+ padding-left: 6px;
115
+ display: table-cell;
116
+ white-space: nowrap; }
117
+
118
+ .ac-upload-space .ac-upload-space-progress {
119
+ margin-top: 6px;
120
+ height: 3px;
121
+ background: white;
122
+ border: 1px solid #dfdfdf;
123
+ position: relative; }
124
+ .ac-upload-space .ac-upload-space-progress .ac-upload-space-progress-bar {
125
+ background-color: #46b450;
126
+ height: 100%;
127
+ display: block; }
128
+
129
+ .ac-upload-space.warning .ac-upload-space-icon:before {
130
+ color: #ffb900;
131
+ content: "\f534";
132
+ margin-top: 1px; }
133
+
134
+ .ac-upload-space.warning .ac-upload-space-progress-bar {
135
+ background-color: #ffb900; }
136
+
137
+ .ac-upload-space.full .ac-upload-space-icon:before {
138
+ color: #d54e21;
139
+ content: "\f153";
140
+ margin-top: 1px; }
141
+
142
+ .ac-upload-space.full .ac-upload-space-progress-bar {
143
+ background-color: #dc3232; }
144
+
145
+ /* =Network screen
146
+ -------------------------------------------------------------- */
147
+ #form-site-list .tablenav .actions .cpac-edit {
148
+ float: none; }
149
+
150
+ /* =General Column
151
+ -------------------------------------------------------------- */
152
+ .ac-inline-info {
153
+ display: inline-block;
154
+ border-radius: 3px;
155
+ min-width: 8px;
156
+ padding: 0 6px;
157
+ min-height: 20px;
158
+ background-color: #e9e9e9;
159
+ text-align: center;
160
+ margin-right: 7px;
161
+ font-size: 11px;
162
+ font-weight: bold; }
163
+
164
+ .ac-rounded {
165
+ display: inline-block;
166
+ border-radius: 10px;
167
+ min-width: 8px;
168
+ padding: 0 6px;
169
+ height: 20px;
170
+ background-color: #e0e0e0;
171
+ text-align: center;
172
+ margin-left: 7px;
173
+ margin-right: 7px;
174
+ font-size: 12px; }
175
+ .ac-rounded.ac-rounded-first {
176
+ margin-left: 0; }
177
+
178
+ .ac-spacing {
179
+ display: inline-block;
180
+ margin-right: 10px;
181
+ margin-bottom: 4px; }
182
+
183
+ .cpac-suffix {
184
+ margin-left: 8px;
185
+ color: #808080; }
186
+
187
+ .ac-small-block {
188
+ display: inline-block;
189
+ border-radius: 3px;
190
+ background-color: rgba(224, 224, 224, 0.6);
191
+ padding: 2px 7px;
192
+ margin: 0 5px 5px 0; }
193
+
194
+ .ac-more-link-show {
195
+ cursor: pointer; }
196
+
197
+ .ac-show-more-block {
198
+ display: none; }
199
+
200
+ .ac-more-link-hide {
201
+ cursor: pointer; }
202
+
203
+ /* =Images Column
204
+ -------------------------------------------------------------- */
205
+ .ac-image {
206
+ display: inline-block;
207
+ margin-right: 2px;
208
+ overflow: hidden;
209
+ max-width: 100%;
210
+ background-color: #ccc; }
211
+ .ac-image img {
212
+ display: block;
213
+ margin: 0 auto; }
214
+ .ac-image .ac-extension {
215
+ font-size: 12px;
216
+ line-height: 22px;
217
+ display: block;
218
+ text-align: center;
219
+ text-transform: uppercase;
220
+ font-weight: bold; }
221
+ .ac-image.ac-icon {
222
+ background-color: transparent; }
223
+
224
+ .rtl .column-column-attachment img {
225
+ padding-left: 5px;
226
+ padding-right: 0; }
227
+
228
+ .ac-progress-bar {
229
+ width: 100%;
230
+ display: flex; }
231
+ .ac-progress-bar .ac-label-main {
232
+ width: 65px; }
233
+ .ac-progress-bar .ac-bar-container {
234
+ flex: auto;
235
+ background-color: #fff;
236
+ min-height: 22px;
237
+ line-height: 22px;
238
+ position: relative;
239
+ border: 1px solid #ccc;
240
+ border-radius: 2px; }
241
+ .ac-progress-bar .ac-bar-container .ac-bar {
242
+ height: 100%;
243
+ background-color: #69c471;
244
+ border-right: 1px solid #fff; }
245
+ .ac-progress-bar .ac-bar-container .ac-label-left,
246
+ .ac-progress-bar .ac-bar-container .ac-label-right {
247
+ text-shadow: rgba(255, 255, 255, 0.65) 0 0 5px;
248
+ color: #555;
249
+ position: absolute; }
250
+ .ac-progress-bar .ac-bar-container .ac-label-left {
251
+ left: 5px; }
252
+ .ac-progress-bar .ac-bar-container .ac-label-right {
253
+ right: 5px; }
254
+ .ac-progress-bar.full .ac-bar-container .ac-bar {
255
+ background-color: rgba(255, 0, 0, 0.45);
256
+ border: none; }
257
+ .ac-progress-bar.dark .ac-bar-container {
258
+ flex: auto;
259
+ background-color: #a6a6a6;
260
+ min-height: 22px;
261
+ line-height: 22px;
262
+ position: relative; }
263
+ .ac-progress-bar.dark .ac-bar-container .ac-bar {
264
+ height: 100%;
265
+ background-color: #46b450;
266
+ border-right: 1px solid #fff; }
267
+ .ac-progress-bar.dark .ac-bar-container .ac-label-left {
268
+ color: #fff;
269
+ position: absolute;
270
+ left: 5px; }
271
+ .ac-progress-bar.dark .ac-bar-container .ac-label-right {
272
+ color: #fff;
273
+ position: absolute;
274
+ right: 5px; }
275
+ .ac-progress-bar.dark.full .ac-bar-container .ac-bar {
276
+ background-color: rgba(255, 0, 0, 0.68);
277
+ border: none; }
278
+
279
+ /* =Color Column
280
+ -------------------------------------------------------------- */
281
+ div.cpac-color {
282
+ line-height: 26px; }
283
+
284
+ div.cpac-color span {
285
+ display: block;
286
+ -webkit-border-radius: 3px;
287
+ border-radius: 3px;
288
+ color: #ffffff;
289
+ float: left;
290
+ height: 16px;
291
+ line-height: 16px;
292
+ margin-right: 12px;
293
+ overflow: hidden;
294
+ padding: 4px 5px;
295
+ font-size: 10px;
296
+ font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
297
+ min-width: 47px;
298
+ text-align: center; }
299
+
300
+ .rtl div.cpac-color span {
301
+ float: right;
302
+ margin-left: 12px;
303
+ margin-right: 0; }
304
+
305
+ /* =Available Sizes column
306
+ -------------------------------------------------------------- */
307
+ div.sizes span.not-available {
308
+ color: #999; }
309
+
310
+ /* =Actions column
311
+ -------------------------------------------------------------- */
312
+ .button.cpac-button-action {
313
+ position: relative;
314
+ text-indent: 9999px;
315
+ margin-right: 4px;
316
+ padding: 0 13px;
317
+ overflow: hidden; }
318
+ .button.cpac-button-action:before {
319
+ position: absolute;
320
+ top: 0;
321
+ left: 0;
322
+ width: 100%;
323
+ height: 100%;
324
+ text-indent: 0; }
325
+
326
+ .cpac_wp_button, .column-actions.cpac_use_icons .row-actions > span a {
327
+ color: #555;
328
+ background: #f7f7f7;
329
+ box-shadow: 0 1px 0 #ccc;
330
+ vertical-align: top;
331
+ display: inline-block;
332
+ text-decoration: none;
333
+ font-size: 13px;
334
+ line-height: 26px;
335
+ height: 28px;
336
+ margin: 0;
337
+ padding: 0 10px 1px;
338
+ cursor: pointer;
339
+ border: 1px solid #ccc;
340
+ border-radius: 3px;
341
+ white-space: nowrap;
342
+ box-sizing: border-box; }
343
+ .cpac_wp_button:hover, .column-actions.cpac_use_icons .row-actions > span a:hover {
344
+ background: #fafafa;
345
+ color: #23282d;
346
+ border-color: #999; }
347
+
348
+ .column-actions .row-actions {
349
+ left: 0;
350
+ position: relative; }
351
+
352
+ .column-actions.cpac_use_icons .row-actions > span {
353
+ color: transparent;
354
+ margin-right: -8px; }
355
+ .column-actions.cpac_use_icons .row-actions > span a {
356
+ display: inline-block;
357
+ position: relative;
358
+ min-width: 26px;
359
+ margin-bottom: 5px; }
360
+ .column-actions.cpac_use_icons .row-actions > span a:before {
361
+ text-indent: 0;
362
+ font-family: Dashicons, sans-serif;
363
+ font-size: 16px;
364
+ position: absolute;
365
+ padding-left: 4px;
366
+ top: 0;
367
+ left: 0;
368
+ width: 100%;
369
+ height: 100%; }
370
+ .column-actions.cpac_use_icons .row-actions > span.edit a, .column-actions.cpac_use_icons .row-actions > span.inline a, .column-actions.cpac_use_icons .row-actions > span.trash a, .column-actions.cpac_use_icons .row-actions > span.view a, .column-actions.cpac_use_icons .row-actions > span.quickedit a, .column-actions.cpac_use_icons .row-actions > span.approve a, .column-actions.cpac_use_icons .row-actions > span.unapprove a, .column-actions.cpac_use_icons .row-actions > span.spam a, .column-actions.cpac_use_icons .row-actions > span.untrash a, .column-actions.cpac_use_icons .row-actions > span.unspam a, .column-actions.cpac_use_icons .row-actions > span.reply a, .column-actions.cpac_use_icons .row-actions > span.delete a {
371
+ text-indent: -3000px; }
372
+ .column-actions.cpac_use_icons .row-actions > span.edit a:before, .column-actions.cpac_use_icons .row-actions > span.inline a:before, .column-actions.cpac_use_icons .row-actions > span.trash a:before, .column-actions.cpac_use_icons .row-actions > span.view a:before, .column-actions.cpac_use_icons .row-actions > span.quickedit a:before, .column-actions.cpac_use_icons .row-actions > span.approve a:before, .column-actions.cpac_use_icons .row-actions > span.unapprove a:before, .column-actions.cpac_use_icons .row-actions > span.spam a:before, .column-actions.cpac_use_icons .row-actions > span.untrash a:before, .column-actions.cpac_use_icons .row-actions > span.unspam a:before, .column-actions.cpac_use_icons .row-actions > span.reply a:before, .column-actions.cpac_use_icons .row-actions > span.delete a:before {
373
+ text-indent: 0;
374
+ font-family: Dashicons, sans-serif; }
375
+ .column-actions.cpac_use_icons .row-actions > span.edit a:before {
376
+ content: "\f464"; }
377
+ .column-actions.cpac_use_icons .row-actions > span.inline a:before, .column-actions.cpac_use_icons .row-actions > span.quickedit a:before {
378
+ content: "\f119"; }
379
+ .column-actions.cpac_use_icons .row-actions > span.trash a {
380
+ border-radius: 3px;
381
+ border: 1px solid #ccc; }
382
+ .column-actions.cpac_use_icons .row-actions > span.trash a:before {
383
+ content: "\f182"; }
384
+ .column-actions.cpac_use_icons .row-actions > span.trash a:hover {
385
+ border-color: #999; }
386
+ .column-actions.cpac_use_icons .row-actions > span.view a:before {
387
+ content: "\f177"; }
388
+ .column-actions.cpac_use_icons .row-actions > span.unapprove a:before {
389
+ content: "\f158"; }
390
+ .column-actions.cpac_use_icons .row-actions > span.approve a:before {
391
+ content: "\f147"; }
392
+ .column-actions.cpac_use_icons .row-actions > span.spam a:before {
393
+ content: "\f117"; }
394
+ .column-actions.cpac_use_icons .row-actions > span.reply a:before {
395
+ content: "\f473"; }
396
+ .column-actions.cpac_use_icons .row-actions > span.untrash a:before, .column-actions.cpac_use_icons .row-actions > span.unspam a:before {
397
+ content: "\f171"; }
398
+ .column-actions.cpac_use_icons .row-actions > span.delete a:before {
399
+ content: "\f182"; }
400
+
401
+ /* Responsive table screen
402
+ -------------------------------------------------------------- */
403
+ @media screen and (max-width: 782px) {
404
+ .wp-list-table.widefat thead th {
405
+ display: none; }
406
+ .wp-list-table.widefat thead th.column-primary {
407
+ display: table-cell; }
408
+ .wp-list-table.widefat tbody tr:not(.inline-edit-row):not(.no-items) td {
409
+ display: none; }
410
+ .wp-list-table.widefat tbody tr:not(.inline-edit-row):not(.no-items) td.column-primary {
411
+ display: block; } }
412
+
413
+ /* =qTip2
414
+ -------------------------------------------------------------- */
415
+ .ac-tip {
416
+ display: inline-block; }
417
+
418
+ .qtip.qtip-tipsy {
419
+ background: rgba(0, 0, 0, 0.75);
420
+ font-weight: normal;
421
+ min-width: 25px; }
assets/css/table.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ac-divider{display:inline-block;width:14px;height:12px;background:transparent url(../images/square.png) no-repeat 50% 7px}span.status-closed{color:red}.actions #post-query-submit,.tablenav.top .cpac-edit{float:left;vertical-align:middle;margin-bottom:4px}.tablenav.top .cpac-edit{top:2px;display:inline-block}body.edit-tags-php .tablenav.top .cpac-edit{float:none}span.dashicons.green{color:#46b450}span.dashicons.red{color:#dc3232}body.edit-php #delete_all{float:left;margin-right:3px}body.users-php .tablenav .actions a.add-new-h2{float:none;vertical-align:middle!important;top:2px!important}@media screen and (max-width:782px){.tablenav.top .actions{display:block!important;margin-bottom:4px}.tablenav.top .actions *{display:none}.tablenav.top .actions .cpac-edit{display:inline-block}}body.upload-php .tablenav.top .cpac-edit{float:none}.ac-toggle-box-link:focus{outline:none;box-shadow:none}.ac-toggle-box-link .spinner{float:none;margin-top:-2px}.ac-toggle-box-link.loading .spinner{visibility:visible}.ac-toggle-box-contents-ajax{padding:5px 0 0}.ac-toggle-box-contents{display:none;padding:5px 0 0}table.ac-table-items{border-spacing:0}table.ac-table-items tr td{border:0;margin:0;padding:0 0 3px}table.ac-table-items tr td.ac-table-item-qty{color:#999;padding-right:6px;text-align:left}.ac-upload-space .ac-upload-space-labels{display:table;width:100%}.ac-upload-space .ac-upload-space-labels .inner{display:table-row}.ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-icon{display:table-cell}.ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-icon:before{color:#82878c;content:"\f104";display:inline-block;font-family:dashicons,serif;width:20px;height:20px;font-size:18px;line-height:1;text-decoration:inherit;font-weight:400;font-style:normal;vertical-align:top;text-align:center;margin-right:4px}.ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-left{display:table-cell;white-space:nowrap}.ac-upload-space .ac-upload-space-labels .inner .ac-upload-space-right{width:100%;text-align:right;padding-left:6px;display:table-cell;white-space:nowrap}.ac-upload-space .ac-upload-space-progress{margin-top:6px;height:3px;background:#fff;border:1px solid #dfdfdf;position:relative}.ac-upload-space .ac-upload-space-progress .ac-upload-space-progress-bar{background-color:#46b450;height:100%;display:block}.ac-upload-space.warning .ac-upload-space-icon:before{color:#ffb900;content:"\f534";margin-top:1px}.ac-upload-space.warning .ac-upload-space-progress-bar{background-color:#ffb900}.ac-upload-space.full .ac-upload-space-icon:before{color:#d54e21;content:"\f153";margin-top:1px}.ac-upload-space.full .ac-upload-space-progress-bar{background-color:#dc3232}#form-site-list .tablenav .actions .cpac-edit{float:none}.ac-inline-info{border-radius:3px;min-height:20px;background-color:#e9e9e9;font-size:11px;font-weight:700}.ac-inline-info,.ac-rounded{display:inline-block;min-width:8px;padding:0 6px;text-align:center;margin-right:7px}.ac-rounded{border-radius:10px;height:20px;background-color:#e0e0e0;margin-left:7px;font-size:12px}.ac-rounded.ac-rounded-first{margin-left:0}.ac-spacing{display:inline-block;margin-right:10px;margin-bottom:4px}.cpac-suffix{margin-left:8px;color:gray}.ac-small-block{display:inline-block;border-radius:3px;background-color:hsla(0,0%,88%,.6);padding:2px 7px;margin:0 5px 5px 0}.ac-more-link-show{cursor:pointer}.ac-show-more-block{display:none}.ac-more-link-hide{cursor:pointer}.ac-image{display:inline-block;margin-right:2px;overflow:hidden;max-width:100%;background-color:#ccc}.ac-image img{display:block;margin:0 auto}.ac-image .ac-extension{font-size:12px;line-height:22px;display:block;text-align:center;text-transform:uppercase;font-weight:700}.ac-image.ac-icon{background-color:transparent}.rtl .column-column-attachment img{padding-left:5px;padding-right:0}.ac-progress-bar{width:100%;display:flex}.ac-progress-bar .ac-label-main{width:65px}.ac-progress-bar .ac-bar-container{flex:auto;background-color:#fff;min-height:22px;line-height:22px;position:relative;border:1px solid #ccc;border-radius:2px}.ac-progress-bar .ac-bar-container .ac-bar{height:100%;background-color:#69c471;border-right:1px solid #fff}.ac-progress-bar .ac-bar-container .ac-label-left,.ac-progress-bar .ac-bar-container .ac-label-right{text-shadow:hsla(0,0%,100%,.65) 0 0 5px;color:#555;position:absolute}.ac-progress-bar .ac-bar-container .ac-label-left{left:5px}.ac-progress-bar .ac-bar-container .ac-label-right{right:5px}.ac-progress-bar.full .ac-bar-container .ac-bar{background-color:rgba(255,0,0,.45);border:none}.ac-progress-bar.dark .ac-bar-container{flex:auto;background-color:#a6a6a6;min-height:22px;line-height:22px;position:relative}.ac-progress-bar.dark .ac-bar-container .ac-bar{height:100%;background-color:#46b450;border-right:1px solid #fff}.ac-progress-bar.dark .ac-bar-container .ac-label-left{color:#fff;position:absolute;left:5px}.ac-progress-bar.dark .ac-bar-container .ac-label-right{color:#fff;position:absolute;right:5px}.ac-progress-bar.dark.full .ac-bar-container .ac-bar{background-color:rgba(255,0,0,.68);border:none}div.cpac-color{line-height:26px}div.cpac-color span{display:block;border-radius:3px;color:#fff;float:left;height:16px;line-height:16px;margin-right:12px;overflow:hidden;padding:4px 5px;font-size:10px;font-family:Monaco,Menlo,Consolas,Courier New,monospace;min-width:47px;text-align:center}.rtl div.cpac-color span{float:right;margin-left:12px;margin-right:0}div.sizes span.not-available{color:#999}.button.cpac-button-action{position:relative;text-indent:9999px;margin-right:4px;padding:0 13px;overflow:hidden}.button.cpac-button-action:before{position:absolute;top:0;left:0;width:100%;height:100%;text-indent:0}.column-actions.cpac_use_icons .row-actions>span a,.cpac_wp_button{color:#555;background:#f7f7f7;box-shadow:0 1px 0 #ccc;vertical-align:top;display:inline-block;text-decoration:none;font-size:13px;line-height:26px;height:28px;margin:0;padding:0 10px 1px;cursor:pointer;border:1px solid #ccc;border-radius:3px;white-space:nowrap;box-sizing:border-box}.column-actions.cpac_use_icons .row-actions>span a:hover,.cpac_wp_button:hover{background:#fafafa;color:#23282d;border-color:#999}.column-actions .row-actions{left:0;position:relative}.column-actions.cpac_use_icons .row-actions>span{color:transparent;margin-right:-8px}.column-actions.cpac_use_icons .row-actions>span a{display:inline-block;position:relative;min-width:26px;margin-bottom:5px}.column-actions.cpac_use_icons .row-actions>span a:before{text-indent:0;font-family:Dashicons,sans-serif;font-size:16px;position:absolute;padding-left:4px;top:0;left:0;width:100%;height:100%}.column-actions.cpac_use_icons .row-actions>span.approve a,.column-actions.cpac_use_icons .row-actions>span.delete a,.column-actions.cpac_use_icons .row-actions>span.edit a,.column-actions.cpac_use_icons .row-actions>span.inline a,.column-actions.cpac_use_icons .row-actions>span.quickedit a,.column-actions.cpac_use_icons .row-actions>span.reply a,.column-actions.cpac_use_icons .row-actions>span.spam a,.column-actions.cpac_use_icons .row-actions>span.trash a,.column-actions.cpac_use_icons .row-actions>span.unapprove a,.column-actions.cpac_use_icons .row-actions>span.unspam a,.column-actions.cpac_use_icons .row-actions>span.untrash a,.column-actions.cpac_use_icons .row-actions>span.view a{text-indent:-3000px}.column-actions.cpac_use_icons .row-actions>span.approve a:before,.column-actions.cpac_use_icons .row-actions>span.delete a:before,.column-actions.cpac_use_icons .row-actions>span.edit a:before,.column-actions.cpac_use_icons .row-actions>span.inline a:before,.column-actions.cpac_use_icons .row-actions>span.quickedit a:before,.column-actions.cpac_use_icons .row-actions>span.reply a:before,.column-actions.cpac_use_icons .row-actions>span.spam a:before,.column-actions.cpac_use_icons .row-actions>span.trash a:before,.column-actions.cpac_use_icons .row-actions>span.unapprove a:before,.column-actions.cpac_use_icons .row-actions>span.unspam a:before,.column-actions.cpac_use_icons .row-actions>span.untrash a:before,.column-actions.cpac_use_icons .row-actions>span.view a:before{text-indent:0;font-family:Dashicons,sans-serif}.column-actions.cpac_use_icons .row-actions>span.edit a:before{content:"\f464"}.column-actions.cpac_use_icons .row-actions>span.inline a:before,.column-actions.cpac_use_icons .row-actions>span.quickedit a:before{content:"\f119"}.column-actions.cpac_use_icons .row-actions>span.trash a{border-radius:3px;border:1px solid #ccc}.column-actions.cpac_use_icons .row-actions>span.trash a:before{content:"\f182"}.column-actions.cpac_use_icons .row-actions>span.trash a:hover{border-color:#999}.column-actions.cpac_use_icons .row-actions>span.view a:before{content:"\f177"}.column-actions.cpac_use_icons .row-actions>span.unapprove a:before{content:"\f158"}.column-actions.cpac_use_icons .row-actions>span.approve a:before{content:"\f147"}.column-actions.cpac_use_icons .row-actions>span.spam a:before{content:"\f117"}.column-actions.cpac_use_icons .row-actions>span.reply a:before{content:"\f473"}.column-actions.cpac_use_icons .row-actions>span.unspam a:before,.column-actions.cpac_use_icons .row-actions>span.untrash a:before{content:"\f171"}.column-actions.cpac_use_icons .row-actions>span.delete a:before{content:"\f182"}@media screen and (max-width:782px){.wp-list-table.widefat thead th{display:none}.wp-list-table.widefat thead th.column-primary{display:table-cell}.wp-list-table.widefat tbody tr:not(.inline-edit-row):not(.no-items) td{display:none}.wp-list-table.widefat tbody tr:not(.inline-edit-row):not(.no-items) td.column-primary{display:block}}.ac-tip{display:inline-block}.qtip.qtip-tipsy{background:rgba(0,0,0,.75);font-weight:400;min-width:25px}
assets/fonts/cpac_icons.eot ADDED
Binary file
assets/fonts/cpac_icons.ttf ADDED
Binary file
assets/fonts/cpac_icons.woff ADDED
Binary file
assets/images/{logo-woocommerce.png → addons/acf-icon.png} RENAMED
Binary file
assets/images/addons/acf.png CHANGED
Binary file
assets/images/addons/pods-icon.png ADDED
Binary file
assets/images/addons/pods.png ADDED
Binary file
assets/images/addons/toolset-types-icon-alt.png ADDED
Binary file
assets/images/addons/toolset-types-icon.png ADDED
Binary file
assets/images/addons/toolset-types.png ADDED
Binary file
assets/images/addons/woocommerce-icon.png ADDED
Binary file
assets/images/addons/woocommerce.png CHANGED
Binary file
assets/images/drag.svg ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="6px" height="26px" viewBox="0 0 6 26" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 3.6.1 (26313) - http://www.bohemiancoding.com/sketch -->
4
+ <title>Group 2</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Group-2" fill="#000000">
9
+ <g id="Group">
10
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
11
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
12
+ </g>
13
+ <g id="Group" transform="translate(0.000000, 4.000000)">
14
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
15
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
16
+ </g>
17
+ <g id="Group" transform="translate(0.000000, 8.000000)">
18
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
19
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
20
+ </g>
21
+ <g id="Group" transform="translate(0.000000, 12.000000)">
22
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
23
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
24
+ </g>
25
+ <g id="Group" transform="translate(0.000000, 16.000000)">
26
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
27
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
28
+ </g>
29
+ <g id="Group" transform="translate(0.000000, 20.000000)">
30
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
31
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
32
+ </g>
33
+ <g id="Group" transform="translate(0.000000, 24.000000)">
34
+ <rect id="Rectangle-1" x="0" y="0" width="2" height="2"></rect>
35
+ <rect id="Rectangle-1" x="4" y="0" width="2" height="2"></rect>
36
+ </g>
37
+ </g>
38
+ </g>
39
+ </svg>
assets/images/drag_2x.png ADDED
Binary file
assets/images/get_the_addon.png DELETED
Binary file
assets/images/logo-acf.png DELETED
Binary file
assets/js/admin-columns.js DELETED
@@ -1,40 +0,0 @@
1
- jQuery( document ).ready( function( $ ) {
2
- cpac_tooltips();
3
- cpac_quickedit_events();
4
- } );
5
-
6
- /**
7
- * @since 2.2.4
8
- */
9
- function cpac_tooltips() {
10
-
11
- if ( typeof jQuery.fn.qtip === 'undefined' ) {
12
- return;
13
- }
14
-
15
- jQuery( '.cpac-tip' ).qtip( {
16
- content : {
17
- attr : 'data-tip'
18
- },
19
- position : {
20
- my : 'top center',
21
- at : 'bottom center'
22
- },
23
- style : {
24
- tip : true,
25
- classes : 'qtip-tipsy'
26
- }
27
- } );
28
- }
29
-
30
- function cpac_quickedit_events() {
31
- var $ = jQuery;
32
-
33
- $( document ).ajaxComplete( function( event, request, settings ) {
34
- var $result = $( '<div>' ).append( request.responseText );
35
- if ( $result.find( 'tr.iedit' ).length == 1 ) {
36
- var id = $result.find( 'tr.iedit' ).attr( 'id' );
37
- $( 'tr#' + id ).trigger( 'updated' );
38
- }
39
- } );
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin-columns.min.js DELETED
@@ -1 +0,0 @@
1
- function cpac_tooltips(){"undefined"!=typeof jQuery.fn.qtip&&jQuery(".cpac-tip").qtip({content:{attr:"data-tip"},position:{my:"top center",at:"bottom center"},style:{tip:!0,classes:"qtip-tipsy"}})}function cpac_quickedit_events(){var t=jQuery;t(document).ajaxComplete(function(e,i,n){var c=t("<div>").append(i.responseText);if(1==c.find("tr.iedit").length){var p=c.find("tr.iedit").attr("id");t("tr#"+p).trigger("updated")}})}jQuery(document).ready(function(t){cpac_tooltips(),cpac_quickedit_events()});
 
assets/js/admin-general.js ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function( $ ) {
2
+
3
+ if ( $( '#cpac' ).length === 0 ) {
4
+ return false;
5
+ }
6
+
7
+ ac_pointer( $ );
8
+ ac_help( $ );
9
+
10
+ } );
11
+
12
+ /*
13
+ * WP Pointer
14
+ *
15
+ */
16
+ function ac_pointer( $ ) {
17
+
18
+ $( '.ac-pointer' ).each( function() {
19
+ // vars
20
+ var el = $( this ),
21
+ html = el.attr( 'rel' ),
22
+ pos = el.attr( 'data-pos' ),
23
+ w = el.attr( 'data-width' ),
24
+ noclick = el.attr( 'data-noclick' );
25
+
26
+ var position = {
27
+ at : 'left top', // position of wp-pointer relative to the element which triggers the pointer event
28
+ my : 'right top', // position of wp-pointer relative to the at-coordinates
29
+ edge : 'right', // position of arrow
30
+ };
31
+
32
+ var width = w ? w : 250;
33
+
34
+ if ( 'right' == pos ) {
35
+ position = {
36
+ at : 'right middle',
37
+ my : 'left middle',
38
+ edge : 'left'
39
+ };
40
+ }
41
+
42
+ if ( 'left' == pos ) {
43
+ position = {
44
+ at : 'left middle',
45
+ my : 'right middle',
46
+ edge : 'right'
47
+ };
48
+ }
49
+
50
+ // create pointer
51
+ el.pointer( {
52
+ content : $( '#' + html ).html(),
53
+ position : position,
54
+ pointerWidth : width,
55
+ // bug fix. with an arrow on the right side the position of wp-pointer is incorrect. it does not take
56
+ // into account the padding of the arrow. adding "wp-pointer-' + position.edge" will fix that.
57
+ pointerClass : 'ac-wp-pointer wp-pointer wp-pointer-' + position.edge + ( noclick ? ' noclick' : '' )
58
+ } );
59
+
60
+ // click
61
+ if ( !noclick ) {
62
+ el.click( function() {
63
+ if ( el.hasClass( 'open' ) ) {
64
+ el.removeClass( 'open' );
65
+ }
66
+ else {
67
+ el.addClass( 'open' );
68
+ }
69
+ } );
70
+ }
71
+
72
+ // show on hover
73
+ el.hover( function() {
74
+ $( this ).pointer( 'open' );
75
+ }, function() {
76
+ var el = $( this );
77
+ setTimeout( function() {
78
+ if ( !el.hasClass( 'open' ) && $( '.ac-wp-pointer.hover' ).length == 0 ) {
79
+ el.pointer( 'close' );
80
+ }
81
+ }, 100 );
82
+
83
+ } ).on( 'close', function() {
84
+ if ( !el.hasClass( 'open' ) && $( '.ac-wp-pointer.hover' ).length == 0 ) {
85
+ el.pointer( 'close' );
86
+ }
87
+ } );
88
+ } );
89
+
90
+ $( '.ac-wp-pointer' ).hover( function() {
91
+ $( this ).addClass( 'hover' );
92
+ }, function() {
93
+ $( this ).removeClass( 'hover' );
94
+ $( '.ac-pointer' ).trigger( 'close' );
95
+ } );
96
+
97
+ }
98
+
99
+ /*
100
+ * Help
101
+ *
102
+ * usage: <a href="javascript:;" class="help" data-help="tab-2"></a>
103
+ */
104
+ function ac_help( $ ) {
105
+ $( 'a.help' ).click( function( e ) {
106
+ e.preventDefault();
107
+
108
+ var panel = $( '#contextual-help-wrap' );
109
+
110
+ panel.parent().show();
111
+ $( 'a[href="#tab-panel-cpac-' + $( this ).attr( 'data-help' ) + '"]', panel ).trigger( 'click' );
112
+ panel.slideDown( 'fast', function() {
113
+ panel.focus();
114
+ } );
115
+ } );
116
+ }
assets/js/admin-general.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function ac_pointer(t){t(".ac-pointer").each(function(){var e=t(this),n=e.attr("rel"),o=e.attr("data-pos"),i=e.attr("data-width"),a=e.attr("data-noclick"),r={at:"left top",my:"right top",edge:"right"},c=i||250;"right"==o&&(r={at:"right middle",my:"left middle",edge:"left"}),"left"==o&&(r={at:"left middle",my:"right middle",edge:"right"}),e.pointer({content:t("#"+n).html(),position:r,pointerWidth:c,pointerClass:"ac-wp-pointer wp-pointer wp-pointer-"+r.edge+(a?" noclick":"")}),a||e.click(function(){e.hasClass("open")?e.removeClass("open"):e.addClass("open")}),e.hover(function(){t(this).pointer("open")},function(){var e=t(this);setTimeout(function(){e.hasClass("open")||0!=t(".ac-wp-pointer.hover").length||e.pointer("close")},100)}).on("close",function(){e.hasClass("open")||0!=t(".ac-wp-pointer.hover").length||e.pointer("close")})}),t(".ac-wp-pointer").hover(function(){t(this).addClass("hover")},function(){t(this).removeClass("hover"),t(".ac-pointer").trigger("close")})}function ac_help(t){t("a.help").click(function(e){e.preventDefault();var n=t("#contextual-help-wrap");n.parent().show(),t('a[href="#tab-panel-cpac-'+t(this).attr("data-help")+'"]',n).trigger("click"),n.slideDown("fast",function(){n.focus()})})}jQuery(document).ready(function(t){if(0===t("#cpac").length)return!1;ac_pointer(t),ac_help(t)});
assets/js/admin-page-columns.js ADDED
@@ -0,0 +1,936 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AC variables. Defined in DOM.
3
+ * @param AC {Object}
4
+ * @param AC.list_screen {String}
5
+ * @param AC.layout {String}
6
+ * @param AC.i81n {String}
7
+ */
8
+ var AC;
9
+
10
+ /**
11
+ * Temporary column name used for form elements.
12
+ *
13
+ * @type {number}
14
+ */
15
+ var incremental_column_name = 0;
16
+
17
+ /**
18
+ * DOM ready
19
+ */
20
+ jQuery( document ).ready( function( $ ) {
21
+
22
+ if ( $( '#cpac' ).length === 0 ) {
23
+ return false;
24
+ }
25
+
26
+ cpac_init( $ );
27
+ cpac_submit_form( $ );
28
+ cpac_reset_columns( $ );
29
+ cpac_menu( $ );
30
+ cpac_add_column( $ );
31
+ cpac_sidebar_feedback( $ );
32
+
33
+ } );
34
+
35
+ function ac_show_ajax_message( message, attr_class ) {
36
+ var msg = jQuery( '<div class="ac-message hidden ' + attr_class + '"><p>' + message + '</p></div>' );
37
+ jQuery( '.ac-boxes' ).before( msg );
38
+ msg.slideDown();
39
+ }
40
+
41
+ /*
42
+ * Submit Form
43
+ *
44
+ * @since 2.0.2
45
+ */
46
+ function cpac_submit_form( $ ) {
47
+
48
+ var $save_buttons = $( '.sidebox a.submit, .column-footer a.submit' );
49
+
50
+ $save_buttons.click( function() {
51
+
52
+ var $button = $( this );
53
+ var $container = $button.closest( '.ac-admin' ).addClass( 'saving' );
54
+ var columns_data = $container.find( '.ac-columns form' ).serialize();
55
+
56
+ $save_buttons.attr( 'disabled', 'disabled' );
57
+
58
+ // reset
59
+ $container.find( '.ac-message' ).remove(); // placed by restore button
60
+
61
+ var xhr = $.post( ajaxurl, {
62
+ action : 'ac_columns_save',
63
+ data : columns_data,
64
+ _ajax_nonce : AC._ajax_nonce,
65
+ list_screen : AC.list_screen,
66
+ layout : AC.layout,
67
+ original_columns : AC.original_columns
68
+ },
69
+
70
+ // JSON response
71
+ function( response ) {
72
+ if ( response ) {
73
+ if ( response.success ) {
74
+ ac_show_ajax_message( response.data, 'updated' );
75
+
76
+ $container.addClass( 'stored' );
77
+ }
78
+
79
+ // Error message
80
+ else if ( response.data ) {
81
+ ac_show_ajax_message( response.data.message, 'notice notice-warning' );
82
+ }
83
+ }
84
+
85
+ // No response
86
+ else {
87
+ }
88
+
89
+ }, 'json' );
90
+
91
+ // No JSON
92
+ xhr.fail( function( error ) {
93
+ // We choose not to notify the user of errors, because the settings will have
94
+ // been saved correctly despite of PHP notices/errors from plugin or themes.
95
+ } );
96
+
97
+ // Always
98
+ xhr.always( function() {
99
+ $save_buttons.removeAttr( 'disabled', 'disabled' );
100
+ $container.removeClass( 'saving' );
101
+ } );
102
+
103
+ $( document ).trigger( 'cac_update', $container );
104
+ } );
105
+ }
106
+
107
+ /*
108
+ * Add Column
109
+ *
110
+ * @since 2.0
111
+ */
112
+ function cpac_add_column( $ ) {
113
+
114
+ $( '.add_column' ).click( function( e ) {
115
+ e.preventDefault();
116
+
117
+ var clone = $( '#add-new-column-template' ).find( '.ac-column' ).clone();
118
+
119
+ // increment clone id ( before adding to DOM, otherwise radio buttons will reset )
120
+ clone.cpac_update_clone_id();
121
+
122
+ // Open
123
+ clone.addClass( 'opened' ).find( '.ac-column-body' ).slideDown( 150, function() {
124
+ $( 'html, body' ).animate( { scrollTop : clone.offset().top - 58 }, 300 );
125
+ } );
126
+
127
+ // add to DOM
128
+ $( '.ac-columns form' ).append( clone );
129
+
130
+ // TODO: better?
131
+ clone.column_bind_toggle();
132
+ clone.column_bind_remove();
133
+ clone.column_bind_clone();
134
+ clone.column_bind_events();
135
+
136
+ // hook for addons
137
+ $( document ).trigger( 'column_add', clone );
138
+ } );
139
+
140
+ }
141
+
142
+ /**
143
+ * @since 2.2.1
144
+ */
145
+ function cpac_sidebar_feedback( $ ) {
146
+ var sidebox = $( '.sidebox#direct-feedback' );
147
+
148
+ sidebox.find( '#feedback-choice a.no' ).click( function( e ) {
149
+ e.preventDefault();
150
+
151
+ sidebox.find( '#feedback-choice' ).slideUp();
152
+ sidebox.find( '#feedback-support' ).slideDown();
153
+ } );
154
+
155
+ sidebox.find( '#feedback-choice a.yes' ).click( function( e ) {
156
+ e.preventDefault();
157
+
158
+ sidebox.find( '#feedback-choice' ).slideUp();
159
+ sidebox.find( '#feedback-rate' ).slideDown();
160
+ } );
161
+ }
162
+
163
+ function cpac_init( $ ) {
164
+
165
+ var container = $( '.ac-admin' );
166
+ var boxes = container.find( '.ac-boxes' );
167
+
168
+ // Written for PHP Export
169
+ if ( boxes.hasClass( 'disabled' ) ) {
170
+ boxes.find( '.ac-column' ).each( function( i, col ) {
171
+ $( col ).column_bind_toggle();
172
+ $( col ).find( 'input, select' ).prop( 'disabled', true );
173
+ } );
174
+ }
175
+
176
+ else {
177
+ var columns = boxes.find( '.ac-columns' );
178
+
179
+ // we start by binding the toggle and remove events.
180
+ columns.find( '.ac-column' ).each( function( i, col ) {
181
+ $( col ).column_bind_toggle();
182
+ $( col ).column_bind_remove();
183
+ $( col ).column_bind_clone();
184
+ $( col ).cpac_bind_indicator_events();
185
+ } );
186
+
187
+ // ordering of columns
188
+ columns.cpac_bind_ordering();
189
+ }
190
+
191
+ // hook for addons
192
+ $( document ).trigger( 'cac_menu_change', columns ); // deprecated
193
+ $( document ).trigger( 'cac_model_ready', container.data( 'type' ) );
194
+ }
195
+
196
+ /*
197
+ * Menu
198
+ *
199
+ * @since 1.5
200
+ */
201
+ function cpac_menu( $ ) {
202
+ $( '#ac_list_screen' ).on( 'change', function() {
203
+ $( '.view-link' ).hide();
204
+ $( this ).parents( 'form' ).submit();
205
+
206
+ $( this ).prop( 'disabled', true ).next( '.spinner' ).css( 'display', 'inline-block' );
207
+ } );
208
+ }
209
+
210
+ /*
211
+ * Reset columns
212
+ *
213
+ * @since NEWVERSION
214
+ */
215
+ function cpac_reset_columns( $ ) {
216
+ var $container = $( '.ac-admin' );
217
+
218
+ $( 'a[data-clear-columns]' ).on( 'click', function() {
219
+ $container.find( '.ac-column' ).each( function() {
220
+ $( this ).find( '.remove-button' ).trigger( 'click' );
221
+ } );
222
+ } );
223
+ }
224
+
225
+ /*
226
+ * jQuery functions
227
+ *
228
+ * @since 2.0
229
+ */
230
+ (function( $ ) {
231
+
232
+ /*
233
+ * Column: bind toggle events
234
+ *
235
+ * For performance we bind all other events after the click event.
236
+ *
237
+ * @since 2.0
238
+ */
239
+ $.fn.column_bind_toggle = function() {
240
+
241
+ var $column = $( this );
242
+ var is_disabled = $column.closest( '.ac-boxes' ).hasClass( 'disabled' );
243
+
244
+ $column.find( '[data-toggle="column"]' ).click( function( e ) {
245
+ e.preventDefault();
246
+
247
+ $column.toggleClass( 'opened' ).find( '.ac-column-body' ).slideToggle( 150 );
248
+
249
+ if ( is_disabled ) {
250
+ return;
251
+ }
252
+
253
+ if ( !$column.hasClass( 'events-binded' ) ) {
254
+ $column.column_bind_events();
255
+ }
256
+
257
+ $column.addClass( 'events-binded' );
258
+
259
+ // hook for addons
260
+ $( document ).trigger( 'column_init', $column );
261
+ } ).css( 'cursor', 'pointer' );
262
+ };
263
+
264
+ /*
265
+ * Column: bind remove events
266
+ *
267
+ * @since 2.0
268
+ */
269
+ $.fn.column_bind_remove = function() {
270
+ $( this ).find( '.remove-button' ).click( function( e ) {
271
+ $( this ).closest( '.ac-column' ).column_remove();
272
+
273
+ e.preventDefault();
274
+ } );
275
+ };
276
+
277
+ /**
278
+ * Column: bind clone events
279
+ *
280
+ * @since 2.3.4
281
+ */
282
+ $.fn.column_bind_clone = function() {
283
+ $( this ).find( '.clone-button' ).click( function( e ) {
284
+ e.preventDefault();
285
+
286
+ var $clone = $( this ).closest( '.ac-column' ).column_clone();
287
+
288
+ if ( typeof $clone !== 'undefined' ) {
289
+ $clone.removeClass( 'loading' ).hide().slideDown();
290
+ }
291
+ } );
292
+ };
293
+
294
+ $.fn.cpac_column_refresh = function() {
295
+
296
+ var el = $( this );
297
+ var select = el.find( '[data-refresh="column"]' );
298
+ var column_name = $( this ).attr( 'data-column-name' );
299
+
300
+ // Allow plugins to hook into this event
301
+ $( document ).trigger( 'pre_column_refresh', el );
302
+
303
+ var data = $( this ).find( ':input' ).serializeArray();
304
+ var request_data = {
305
+ action : 'ac_column_refresh',
306
+ _ajax_nonce : AC._ajax_nonce,
307
+ list_screen : AC.list_screen,
308
+ layout : AC.layout,
309
+ column_name : column_name,
310
+ original_columns : AC.original_columns
311
+ };
312
+
313
+ $.each( request_data, function( name, value ) {
314
+ data.push( {
315
+ name : name,
316
+ value : value
317
+ } );
318
+ } );
319
+
320
+ // Mark column as loading
321
+ el.addClass( 'loading' );
322
+ select.prop( 'disabled', 1 );
323
+
324
+ // Fetch new form HTML
325
+ var xhr = $.post( ajaxurl, data, function( response ) {
326
+
327
+ if ( response ) {
328
+ // Replace current form by new form
329
+ var newel = $( '<div>' + response.data + '</div>' ).children();
330
+ el.replaceWith( newel );
331
+ el = newel;
332
+
333
+ // Bind events
334
+ el.column_bind_toggle();
335
+ el.column_bind_remove();
336
+ el.column_bind_clone();
337
+ el.column_bind_events();
338
+
339
+ // Open settings
340
+ el.addClass( 'opened' ).find( '.ac-column-body' ).show();
341
+
342
+ // Allow plugins to hook into this event
343
+
344
+ // TODO: change to column_refresh?
345
+ $( document ).trigger( 'column_change', el );
346
+ }
347
+
348
+ // Do nothing
349
+ else {
350
+
351
+ }
352
+ }, 'json' );
353
+
354
+ xhr.fail( function( error ) {
355
+ var $msg = el.closest( '.ac-admin' ).find( '.ajax-message' );
356
+
357
+ $msg.addClass( 'error' ).find( 'p' ).html( AC.i18n.error );
358
+ $msg.slideDown();
359
+
360
+ el.slideUp( function() { el.remove() } );
361
+
362
+ console.log( 'responseText: ' + error.responseText );
363
+ } );
364
+
365
+ xhr.always( function() {
366
+ // Remove "loading" marking from column
367
+ el.removeClass( 'loading' );
368
+ select.prop( 'disabled', false );
369
+ } );
370
+ };
371
+
372
+ /*
373
+ * Form Events
374
+ *
375
+ * @since 2.0
376
+ */
377
+ $.fn.column_bind_events = function() {
378
+ var column = $( this );
379
+ var container = column.closest( '.ac-admin ' );
380
+
381
+ // Current column type
382
+ var default_value = column.find( 'select.ac-setting-input_type option:selected' ).val();
383
+
384
+ // Type selector
385
+ column.find( 'select.ac-setting-input_type' ).change( function() {
386
+ var option = $( 'optgroup', this ).children( ':selected' );
387
+ var type = option.val();
388
+ var msg = $( this ).next( '.msg' ).hide();
389
+ var $select = $( this );
390
+
391
+ var current_original_columns = [];
392
+ container.find( '.ac-column[data-original=1]' ).each( function() {
393
+ current_original_columns.push( $( this ).data( 'type' ) );
394
+ } );
395
+
396
+ column.addClass( 'loading' );
397
+
398
+ $.ajax( {
399
+ url : ajaxurl,
400
+ method : 'post',
401
+ dataType : 'json',
402
+ data : {
403
+ action : 'ac_column_select',
404
+ type : type,
405
+ current_original_columns : current_original_columns,
406
+ original_columns : AC.original_columns,
407
+ list_screen : AC.list_screen,
408
+ layout : AC.layout,
409
+ _ajax_nonce : AC._ajax_nonce,
410
+ }
411
+ } )
412
+ .done( function( response ) {
413
+ if ( response ) {
414
+
415
+ if ( response.success ) {
416
+ var el = column.closest( '.ac-column' );
417
+
418
+ // Replace current form by new form
419
+ var newel = $( '<div>' + response.data + '</div>' ).children();
420
+ el.replaceWith( newel );
421
+ el = newel;
422
+
423
+ // Bind events
424
+ el.column_bind_toggle();
425
+ el.column_bind_remove();
426
+ el.column_bind_clone();
427
+ el.column_bind_events();
428
+
429
+ // Open settings
430
+ el.addClass( 'opened' ).find( '.ac-column-body' ).show();
431
+
432
+ el.cpac_update_clone_id();
433
+
434
+ // Allow plugins to hook into this event
435
+ $( document ).trigger( 'column_change', el );
436
+ }
437
+
438
+ // Error message
439
+ else if ( response.data ) {
440
+ if ( 'message' === response.data.type ) {
441
+ msg.html( response.data.error ).show();
442
+
443
+ // Set to default
444
+ $select.find( 'option' ).removeAttr( 'selected' );
445
+ $select.find( 'option[value="' + default_value + '"]' ).attr( 'selected', 'selected' );
446
+ }
447
+ }
448
+ }
449
+ } )
450
+
451
+ .always( function() {
452
+ column.removeClass( 'loading' );
453
+ } );
454
+
455
+ } );
456
+
457
+ /** change label */
458
+ column.find( '.ac-column-setting--label input' ).bind( 'keyup change', function() {
459
+ var value = $( this ).val();
460
+ $( this ).closest( '.ac-column' ).find( 'td.column_label .inner > a.toggle' ).html( value );
461
+ } );
462
+
463
+ /** tooltip */
464
+ column.find( '.ac-column-body .col-label .label' ).hover( function() {
465
+ $( this ).parents( '.col-label' ).find( 'div.tooltip' ).show();
466
+ }, function() {
467
+ $( this ).parents( '.col-label' ).find( 'div.tooltip' ).hide();
468
+ } );
469
+
470
+ /**
471
+ * Populates the main Label with the selected label from the dropdown,
472
+ */
473
+ column.find( 'select[data-label="update"]' ).change( function() {
474
+ var $label = column.find( 'input.ac-setting-input_label' );
475
+ var field_label = $( this ).find( 'option:selected' ).text();
476
+
477
+ // Set new label
478
+ $label.val( field_label );
479
+ $label.trigger( 'change' );
480
+ } );
481
+
482
+ // refresh column and re-bind all events
483
+ column.find( '[data-refresh="column"]' ).change( function() {
484
+ column.cpac_column_refresh();
485
+ } );
486
+
487
+ $( document ).trigger( 'init_settings', column );
488
+ };
489
+
490
+ $.fn.column_bind_settings = function() {
491
+ var $column = $( this );
492
+
493
+ $column.find( '.ac-column-setting--image_size' ).cpac_column_setting_image_size();
494
+ $column.find( '.ac-column-setting--width' ).cpac_column_setting_width();
495
+ };
496
+
497
+ /*
498
+ * Column: remove from DOM
499
+ *
500
+ * @since 2.0
501
+ */
502
+ $.fn.column_remove = function() {
503
+ $( this ).addClass( 'deleting' ).animate( { opacity : 0, height : 0 }, 350, function() {
504
+ $( this ).remove();
505
+ } );
506
+ };
507
+
508
+ /*
509
+ * Column: clone
510
+ *
511
+ * @since 2.3.4
512
+ */
513
+ $.fn.column_clone = function() {
514
+
515
+ var column = $( this );
516
+ var columns = $( this ).closest( 'ac-columns' );
517
+
518
+ if ( '1' === column.attr( 'data-original' ) ) {
519
+
520
+ var message = AC.i18n.clone.replace( '%s', '<strong>' + column.find( '.column_label .toggle' ).text() + '</strong>' );
521
+
522
+ column.addClass( 'opened' ).find( '.ac-column-body' ).slideDown( 150 );
523
+ column.find( '.ac-setting-input_type' ).next( '.msg' ).html( message ).show();
524
+
525
+ return;
526
+ }
527
+
528
+ var clone = $( this ).clone();
529
+
530
+ clone.cpac_update_clone_id();
531
+
532
+ $( this ).after( clone );
533
+
534
+ // rebind events
535
+ clone.column_bind_toggle();
536
+ clone.column_bind_remove();
537
+ clone.column_bind_clone();
538
+
539
+ // rebind all other events
540
+ clone.column_bind_events();
541
+
542
+ // reinitialize sortability
543
+ columns.cpac_bind_ordering();
544
+
545
+ // hook for addons
546
+ $( document ).trigger( 'column_add', clone );
547
+
548
+ return clone;
549
+ };
550
+
551
+ /*
552
+ * Update clone ID
553
+ *
554
+ * @since 2.0
555
+ */
556
+ $.fn.cpac_update_clone_id = function() {
557
+ var $el = $( this );
558
+ var original_column_name = $el.attr( 'data-column-name' );
559
+ var temp_column_name = '_new_column_' + incremental_column_name;
560
+
561
+ // update input names with clone ID
562
+ var inputs = $el.find( 'input, select, label' );
563
+ $( inputs ).each( function( i, v ) {
564
+
565
+ // name
566
+ if ( $( v ).attr( 'name' ) ) {
567
+ $( v ).attr( 'name', $( v ).attr( 'name' ).replace( 'columns[' + original_column_name + ']', 'columns[' + temp_column_name + ']' ) );
568
+ }
569
+
570
+ // id
571
+ if ( $( v ).attr( 'id' ) ) {
572
+ $( v ).attr( 'id', $( v ).attr( 'id' ).replace( '-' + original_column_name + '-', '-' + temp_column_name + '-' ) );
573
+ }
574
+
575
+ // TODO for
576
+ } );
577
+
578
+ $el.attr( 'data-column-name', temp_column_name );
579
+
580
+ // increment
581
+ incremental_column_name++;
582
+ };
583
+
584
+ /*
585
+ * Bind events: triggered after column is init, changed or added
586
+ *
587
+ */
588
+ $( document ).bind( 'column_init column_change column_add', function( e, column ) {
589
+ var is_disabled = $( column ).closest( '.ac-boxes' ).hasClass( 'disabled' );
590
+
591
+ if ( is_disabled ) {
592
+ return;
593
+ }
594
+
595
+ $( column ).cpac_bind_column_addon_events();
596
+ $( column ).cpac_bind_indicator_events();
597
+ } );
598
+
599
+ /*
600
+ * Optional Radio Click events
601
+ *
602
+ */
603
+ $.fn.cpac_bind_column_addon_events = function() {
604
+
605
+ var column = $( this );
606
+ var inputs = column.find( '[data-trigger] label' );
607
+
608
+ inputs.on( 'click', function() {
609
+
610
+ var id = $( this ).closest( 'td.input' ).data( 'trigger' );
611
+ var state = $( 'input', this ).val();
612
+
613
+ // Toggle indicator icon
614
+ var label = column.find( '[data-indicator-id="' + id + '"]' ).removeClass( 'on' );
615
+ if ( 'on' == state ) {
616
+ label.addClass( 'on' );
617
+ }
618
+
619
+ // Toggle additional options
620
+ var additional = column.find( '[data-handle="' + id + '"]' ).addClass( 'hide' );
621
+ if ( 'on' == state ) {
622
+ additional.removeClass( 'hide' );
623
+ }
624
+ } );
625
+
626
+ // On load
627
+ column.find( '[data-trigger]' ).each( function() {
628
+
629
+ var trigger = $( this ).data( 'trigger' );
630
+
631
+ // Hide additional column settings
632
+ var additional = column.find( '[data-handle="' + trigger + '"]' ).addClass( 'hide' );
633
+ if ( 'on' == $( 'input:checked', this ).val() ) {
634
+ additional.removeClass( 'hide' );
635
+ }
636
+ } );
637
+ };
638
+
639
+ /*
640
+ * Indicator Click Events
641
+ *
642
+ */
643
+ $.fn.cpac_bind_indicator_events = function() {
644
+ var $column = $( this );
645
+ var $indicators = $column.find( '.ac-column-header [data-indicator-toggle]' );
646
+
647
+ $indicators.each( function() {
648
+ var $indicator = $( this );
649
+ var setting = $( this ).data( 'setting' );
650
+ var $setting = $column.find( '.ac-column-setting[data-setting=' + setting + ']' );
651
+ var $input = $setting.find( '.col-input:first .ac-setting-input:first input[type=radio]' );
652
+
653
+ $indicator.unbind( 'click' ).on( 'click', function( e ) {
654
+ e.preventDefault();
655
+ $indicator.toggleClass( 'on' );
656
+ if ( $( this ).hasClass( 'on' ) ) {
657
+ $input.filter( '[value=on]' ).prop( 'checked', true ).trigger( 'click' ).trigger( 'change' );
658
+ }
659
+ else {
660
+ $input.filter( '[value=off]' ).prop( 'checked', true ).trigger( 'click' ).trigger( 'change' );
661
+ }
662
+ } );
663
+
664
+ $input.on( 'change', function() {
665
+ var value = $input.filter( ':checked' ).val();
666
+ if ( 'on' == value ) {
667
+ $indicator.addClass( 'on' );
668
+ } else {
669
+ $indicator.removeClass( 'on' );
670
+ }
671
+ } );
672
+ } );
673
+
674
+ };
675
+
676
+ /*
677
+ * Sortable
678
+ *
679
+ * @since 1.5
680
+ */
681
+ $.fn.cpac_bind_ordering = function() {
682
+ $( this ).each( function() {
683
+ if ( $( this ).hasClass( 'ui-sortable' ) ) {
684
+ $( this ).sortable( 'refresh' );
685
+ }
686
+ else {
687
+ $( this ).sortable( {
688
+ items : '.ac-column',
689
+ handle : '.column_sort'
690
+ } );
691
+ }
692
+ } );
693
+ };
694
+
695
+ // Settings fields: Image _size
696
+ $.fn.cpac_column_setting_image_size = function() {
697
+ function initState( $setting, $select ) {
698
+ if ( 'cpac-custom' == $select.val() ) {
699
+ $setting.find( '.ac-column-setting' ).show();
700
+ } else {
701
+ $setting.find( '.ac-column-setting' ).hide();
702
+ }
703
+ }
704
+
705
+ $( this ).each( function() {
706
+ var $setting = $( this );
707
+ var $select = $( this ).find( '.ac-setting-input select' );
708
+
709
+ initState( $setting, $select );
710
+ $select.on( 'change', function() {
711
+ initState( $setting, $( this ) );
712
+ } );
713
+
714
+ } );
715
+ };
716
+
717
+ $( document ).on( 'init_settings', function( e, column ) {
718
+ $( column ).find( '.ac-column-setting--image' ).cpac_column_setting_image_size();
719
+ } );
720
+
721
+ // Settings fields: Width
722
+ $.fn.column_width_slider = function() {
723
+
724
+ var column_width = $( this ).find( '.ac-setting-input-width' );
725
+
726
+ var input_width = column_width.find( '.description input' ),
727
+ input_unit = column_width.find( '.unit-select input' ),
728
+ unit = input_unit.filter( ':checked' ).val(),
729
+ width = input_width.val(),
730
+ slider = column_width.find( '.width-slider' ),
731
+ indicator = $( this ).find( '.ac-column-header .ac-column-heading-setting--width' );
732
+
733
+ // width
734
+ if ( '%' == unit && width > 100 ) {
735
+ width = 100;
736
+ }
737
+
738
+ input_width.val( width );
739
+
740
+ slider.slider( {
741
+ range : 'min',
742
+ min : 0,
743
+ max : '%' == unit ? 100 : 500,
744
+ value : width,
745
+ slide : function( event, ui ) {
746
+
747
+ input_width.val( ui.value );
748
+ indicator.trigger( 'update' );
749
+ input_width.trigger( 'validate' );
750
+ }
751
+ } );
752
+ };
753
+
754
+ $.fn.cpac_column_setting_width = function() {
755
+
756
+ $( this ).each( function() {
757
+ var $column = $( this ).parents( '.ac-column' );
758
+ $column.column_width_slider();
759
+
760
+ // indicator
761
+ var $width_indicator = $column.find( '.ac-column-header .ac-column-heading-setting--width' );
762
+
763
+ $width_indicator.on( 'update', function() {
764
+ var _width = $column.find( '.ac-setting-input-width .description input' ).val();
765
+ var _unit = $column.find( '.ac-setting-input-width .description .unit' ).text();
766
+ if ( _width > 0 ) {
767
+ $( this ).text( _width + _unit );
768
+ } else {
769
+ $( this ).text( '' );
770
+ }
771
+ } );
772
+
773
+ // unit selector
774
+ var width_unit_select = $column.find( '.ac-setting-input-width .unit-select label' );
775
+ width_unit_select.on( 'click', function() {
776
+
777
+ $column.find( 'span.unit' ).text( $( this ).find( 'input' ).val() );
778
+ $column.column_width_slider(); // re-init slider
779
+ $width_indicator.trigger( 'update' ); // update indicator
780
+ } );
781
+
782
+ // width_input
783
+ var width_input = $column.find( '.ac-setting-input-width .description input' )
784
+ .on( 'keyup', function() {
785
+ $column.column_width_slider(); // re-init slider
786
+ $( this ).trigger( 'validate' ); // validate input
787
+ $width_indicator.trigger( 'update' ); // update indicator
788
+ } )
789
+
790
+ // width_input:validate
791
+ .on( 'validate', function() {
792
+ var _width = width_input.val();
793
+ var _new_width = $.trim( _width );
794
+
795
+ if ( !$.isNumeric( _new_width ) ) {
796
+ _new_width = _new_width.replace( /\D/g, '' );
797
+ }
798
+ if ( _new_width.length > 3 ) {
799
+ _new_width = _new_width.substring( 0, 3 );
800
+ }
801
+ if ( _new_width <= 0 ) {
802
+ _new_width = '';
803
+ }
804
+ if ( _new_width !== _width ) {
805
+ width_input.val( _new_width );
806
+ }
807
+ } );
808
+
809
+ } );
810
+ };
811
+
812
+ $.fn.cpac_column_sub_setting_toggle = function( options ) {
813
+ var settings = $.extend( {
814
+ value_show : "on",
815
+ subfield : '.ac-column-setting'
816
+ }, options );
817
+
818
+ function initState( $setting, $input ) {
819
+ var value = $input.filter( ':checked' ).val();
820
+ var $subfields = $setting.find( settings.subfield );
821
+
822
+ if ( settings.value_show == value ) {
823
+ $subfields.show();
824
+ } else {
825
+ $subfields.hide();
826
+ }
827
+ }
828
+
829
+ $( this ).each( function() {
830
+ var $setting = $( this );
831
+ var $input = $( this ).find( '.ac-setting-input input[type="radio"]' );
832
+
833
+ initState( $setting, $input );
834
+ $input.on( 'change', function() {
835
+ initState( $setting, $input );
836
+ } );
837
+
838
+ } );
839
+ };
840
+
841
+ $.fn.cpac_column_setting_date = function() {
842
+
843
+ $( this ).each( function() {
844
+
845
+ var $container = $( this );
846
+
847
+ // Custom input
848
+ var $radio_custom = $container.find( 'input.custom' );
849
+ var $input_custom = $container.find( '.ac-setting-input-date__custom' );
850
+ var $example_custom = $container.find( '.ac-setting-input-date__example' );
851
+ var $selected = $container.find( 'input[type=radio]:checked' );
852
+ var $help_msg = $container.find( '.help-msg' );
853
+
854
+ // Click Event
855
+ $container.find( 'input[type=radio]' ).on( 'change', function() {
856
+
857
+ var $input = $( this );
858
+ var $input_container = $input.closest( 'label' );
859
+ var date_format = $input_container.find( 'code' ).text();
860
+ var description = $input_container.find( '.ac-setting-input-date__more' ).html();
861
+
862
+ if ( date_format ) {
863
+ $input_custom.val( date_format ).trigger( 'change' );
864
+ }
865
+
866
+ if ( $input.hasClass( 'diff' ) ) {
867
+ $input_custom.val( '' );
868
+ $example_custom.text( '' );
869
+ }
870
+
871
+ $input_custom.prop( 'disabled', true );
872
+
873
+ // Custom input selected
874
+ if ( $input.hasClass( 'custom' ) ) {
875
+ $input.val( $input_custom.val() );
876
+ $input_custom.prop( 'disabled', false );
877
+ $help_msg.show();
878
+ }
879
+
880
+ // Show more description
881
+ $help_msg.hide();
882
+ if ( description ) {
883
+ $help_msg.html( description ).show();
884
+ }
885
+
886
+ } );
887
+
888
+ // Custom input
889
+ $input_custom.on( 'change', function() {
890
+
891
+ $example_custom.html( '<span class="spinner is-active"></span>' );
892
+ $radio_custom.val( $input_custom.val() );
893
+
894
+ var $custom_value = $( this ).val();
895
+
896
+ if ( !$custom_value ) {
897
+ $example_custom.text( '' );
898
+ return;
899
+ }
900
+
901
+ $.ajax( {
902
+ url : ajaxurl,
903
+ method : 'post',
904
+ data : {
905
+ action : 'date_format',
906
+ date : $custom_value
907
+ }
908
+ } ).done( function( date ) {
909
+ $example_custom.text( date );
910
+ } );
911
+
912
+ } );
913
+
914
+ // Update date example box
915
+ $selected.trigger( 'change' );
916
+
917
+ // Select custom input as a default
918
+ if ( 0 === $selected.length ) {
919
+ $radio_custom.trigger( 'click' );
920
+ }
921
+
922
+ } );
923
+
924
+ };
925
+
926
+ $( document ).on( 'init_settings', function( e, column ) {
927
+ $( column ).find( '.ac-column-setting--width' ).cpac_column_setting_width();
928
+ $( column ).find( '.ac-column-setting--date' ).cpac_column_setting_date();
929
+
930
+ // TODO: pro?
931
+ $( column ).find( '.ac-column-setting--filter' ).cpac_column_sub_setting_toggle();
932
+ $( column ).find( '.ac-column-setting--sort' ).cpac_column_sub_setting_toggle();
933
+ $( column ).find( '.ac-column-setting--edit' ).cpac_column_sub_setting_toggle();
934
+ } );
935
+
936
+ }( jQuery ));
assets/js/admin-page-columns.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function ac_show_ajax_message(n,e){var t=jQuery('<div class="ac-message hidden '+e+'"><p>'+n+"</p></div>");jQuery(".ac-boxes").before(t),t.slideDown()}function cpac_submit_form(n){var e=n(".sidebox a.submit, .column-footer a.submit");e.click(function(){var t=n(this),i=t.closest(".ac-admin").addClass("saving"),a=i.find(".ac-columns form").serialize();e.attr("disabled","disabled"),i.find(".ac-message").remove();var c=n.post(ajaxurl,{action:"ac_columns_save",data:a,_ajax_nonce:AC._ajax_nonce,list_screen:AC.list_screen,layout:AC.layout,original_columns:AC.original_columns},function(n){n&&(n.success?(ac_show_ajax_message(n.data,"updated"),i.addClass("stored")):n.data&&ac_show_ajax_message(n.data.message,"notice notice-warning"))},"json");c.fail(function(n){}),c.always(function(){e.removeAttr("disabled","disabled"),i.removeClass("saving")}),n(document).trigger("cac_update",i)})}function cpac_add_column(n){n(".add_column").click(function(e){e.preventDefault();var t=n("#add-new-column-template").find(".ac-column").clone();t.cpac_update_clone_id(),t.addClass("opened").find(".ac-column-body").slideDown(150,function(){n("html, body").animate({scrollTop:t.offset().top-58},300)}),n(".ac-columns form").append(t),t.column_bind_toggle(),t.column_bind_remove(),t.column_bind_clone(),t.column_bind_events(),n(document).trigger("column_add",t)})}function cpac_sidebar_feedback(n){var e=n(".sidebox#direct-feedback");e.find("#feedback-choice a.no").click(function(n){n.preventDefault(),e.find("#feedback-choice").slideUp(),e.find("#feedback-support").slideDown()}),e.find("#feedback-choice a.yes").click(function(n){n.preventDefault(),e.find("#feedback-choice").slideUp(),e.find("#feedback-rate").slideDown()})}function cpac_init(n){var e=n(".ac-admin"),t=e.find(".ac-boxes");if(t.hasClass("disabled"))t.find(".ac-column").each(function(e,t){n(t).column_bind_toggle(),n(t).find("input, select").prop("disabled",!0)});else{var i=t.find(".ac-columns");i.find(".ac-column").each(function(e,t){n(t).column_bind_toggle(),n(t).column_bind_remove(),n(t).column_bind_clone(),n(t).cpac_bind_indicator_events()}),i.cpac_bind_ordering()}n(document).trigger("cac_menu_change",i),n(document).trigger("cac_model_ready",e.data("type"))}function cpac_menu(n){n("#ac_list_screen").on("change",function(){n(".view-link").hide(),n(this).parents("form").submit(),n(this).prop("disabled",!0).next(".spinner").css("display","inline-block")})}function cpac_reset_columns(n){var e=n(".ac-admin");n("a[data-clear-columns]").on("click",function(){e.find(".ac-column").each(function(){n(this).find(".remove-button").trigger("click")})})}var AC,incremental_column_name=0;jQuery(document).ready(function(n){if(0===n("#cpac").length)return!1;cpac_init(n),cpac_submit_form(n),cpac_reset_columns(n),cpac_menu(n),cpac_add_column(n),cpac_sidebar_feedback(n)}),function(n){n.fn.column_bind_toggle=function(){var e=n(this),t=e.closest(".ac-boxes").hasClass("disabled");e.find('[data-toggle="column"]').click(function(i){i.preventDefault(),e.toggleClass("opened").find(".ac-column-body").slideToggle(150),t||(e.hasClass("events-binded")||e.column_bind_events(),e.addClass("events-binded"),n(document).trigger("column_init",e))}).css("cursor","pointer")},n.fn.column_bind_remove=function(){n(this).find(".remove-button").click(function(e){n(this).closest(".ac-column").column_remove(),e.preventDefault()})},n.fn.column_bind_clone=function(){n(this).find(".clone-button").click(function(e){e.preventDefault();var t=n(this).closest(".ac-column").column_clone();void 0!==t&&t.removeClass("loading").hide().slideDown()})},n.fn.cpac_column_refresh=function(){var e=n(this),t=e.find('[data-refresh="column"]'),i=n(this).attr("data-column-name");n(document).trigger("pre_column_refresh",e);var a=n(this).find(":input").serializeArray(),c={action:"ac_column_refresh",_ajax_nonce:AC._ajax_nonce,list_screen:AC.list_screen,layout:AC.layout,column_name:i,original_columns:AC.original_columns};n.each(c,function(n,e){a.push({name:n,value:e})}),e.addClass("loading"),t.prop("disabled",1);var o=n.post(ajaxurl,a,function(t){if(t){var i=n("<div>"+t.data+"</div>").children();e.replaceWith(i),e=i,e.column_bind_toggle(),e.column_bind_remove(),e.column_bind_clone(),e.column_bind_events(),e.addClass("opened").find(".ac-column-body").show(),n(document).trigger("column_change",e)}},"json");o.fail(function(n){var t=e.closest(".ac-admin").find(".ajax-message");t.addClass("error").find("p").html(AC.i18n.error),t.slideDown(),e.slideUp(function(){e.remove()}),console.log("responseText: "+n.responseText)}),o.always(function(){e.removeClass("loading"),t.prop("disabled",!1)})},n.fn.column_bind_events=function(){var e=n(this),t=e.closest(".ac-admin "),i=e.find("select.ac-setting-input_type option:selected").val();e.find("select.ac-setting-input_type").change(function(){var a=n("optgroup",this).children(":selected"),c=a.val(),o=n(this).next(".msg").hide(),s=n(this),l=[];t.find(".ac-column[data-original=1]").each(function(){l.push(n(this).data("type"))}),e.addClass("loading"),n.ajax({url:ajaxurl,method:"post",dataType:"json",data:{action:"ac_column_select",type:c,current_original_columns:l,original_columns:AC.original_columns,list_screen:AC.list_screen,layout:AC.layout,_ajax_nonce:AC._ajax_nonce}}).done(function(t){if(t)if(t.success){var a=e.closest(".ac-column"),c=n("<div>"+t.data+"</div>").children();a.replaceWith(c),a=c,a.column_bind_toggle(),a.column_bind_remove(),a.column_bind_clone(),a.column_bind_events(),a.addClass("opened").find(".ac-column-body").show(),a.cpac_update_clone_id(),n(document).trigger("column_change",a)}else t.data&&"message"===t.data.type&&(o.html(t.data.error).show(),s.find("option").removeAttr("selected"),s.find('option[value="'+i+'"]').attr("selected","selected"))}).always(function(){e.removeClass("loading")})}),e.find(".ac-column-setting--label input").bind("keyup change",function(){var e=n(this).val();n(this).closest(".ac-column").find("td.column_label .inner > a.toggle").html(e)}),e.find(".ac-column-body .col-label .label").hover(function(){n(this).parents(".col-label").find("div.tooltip").show()},function(){n(this).parents(".col-label").find("div.tooltip").hide()}),e.find('select[data-label="update"]').change(function(){var t=e.find("input.ac-setting-input_label"),i=n(this).find("option:selected").text();t.val(i),t.trigger("change")}),e.find('[data-refresh="column"]').change(function(){e.cpac_column_refresh()}),n(document).trigger("init_settings",e)},n.fn.column_bind_settings=function(){var e=n(this);e.find(".ac-column-setting--image_size").cpac_column_setting_image_size(),e.find(".ac-column-setting--width").cpac_column_setting_width()},n.fn.column_remove=function(){n(this).addClass("deleting").animate({opacity:0,height:0},350,function(){n(this).remove()})},n.fn.column_clone=function(){var e=n(this),t=n(this).closest("ac-columns");if("1"===e.attr("data-original")){var i=AC.i18n.clone.replace("%s","<strong>"+e.find(".column_label .toggle").text()+"</strong>");return e.addClass("opened").find(".ac-column-body").slideDown(150),void e.find(".ac-setting-input_type").next(".msg").html(i).show()}var a=n(this).clone();return a.cpac_update_clone_id(),n(this).after(a),a.column_bind_toggle(),a.column_bind_remove(),a.column_bind_clone(),a.column_bind_events(),t.cpac_bind_ordering(),n(document).trigger("column_add",a),a},n.fn.cpac_update_clone_id=function(){var e=n(this),t=e.attr("data-column-name"),i="_new_column_"+incremental_column_name,a=e.find("input, select, label");n(a).each(function(e,a){n(a).attr("name")&&n(a).attr("name",n(a).attr("name").replace("columns["+t+"]","columns["+i+"]")),n(a).attr("id")&&n(a).attr("id",n(a).attr("id").replace("-"+t+"-","-"+i+"-"))}),e.attr("data-column-name",i),incremental_column_name++},n(document).bind("column_init column_change column_add",function(e,t){n(t).closest(".ac-boxes").hasClass("disabled")||(n(t).cpac_bind_column_addon_events(),n(t).cpac_bind_indicator_events())}),n.fn.cpac_bind_column_addon_events=function(){var e=n(this);e.find("[data-trigger] label").on("click",function(){var t=n(this).closest("td.input").data("trigger"),i=n("input",this).val(),a=e.find('[data-indicator-id="'+t+'"]').removeClass("on");"on"==i&&a.addClass("on");var c=e.find('[data-handle="'+t+'"]').addClass("hide");"on"==i&&c.removeClass("hide")}),e.find("[data-trigger]").each(function(){var t=n(this).data("trigger"),i=e.find('[data-handle="'+t+'"]').addClass("hide");"on"==n("input:checked",this).val()&&i.removeClass("hide")})},n.fn.cpac_bind_indicator_events=function(){var e=n(this);e.find(".ac-column-header [data-indicator-toggle]").each(function(){var t=n(this),i=n(this).data("setting"),a=e.find(".ac-column-setting[data-setting="+i+"]"),c=a.find(".col-input:first .ac-setting-input:first input[type=radio]");t.unbind("click").on("click",function(e){e.preventDefault(),t.toggleClass("on"),n(this).hasClass("on")?c.filter("[value=on]").prop("checked",!0).trigger("click").trigger("change"):c.filter("[value=off]").prop("checked",!0).trigger("click").trigger("change")}),c.on("change",function(){"on"==c.filter(":checked").val()?t.addClass("on"):t.removeClass("on")})})},n.fn.cpac_bind_ordering=function(){n(this).each(function(){n(this).hasClass("ui-sortable")?n(this).sortable("refresh"):n(this).sortable({items:".ac-column",handle:".column_sort"})})},n.fn.cpac_column_setting_image_size=function(){function e(n,e){"cpac-custom"==e.val()?n.find(".ac-column-setting").show():n.find(".ac-column-setting").hide()}n(this).each(function(){var t=n(this),i=n(this).find(".ac-setting-input select");e(t,i),i.on("change",function(){e(t,n(this))})})},n(document).on("init_settings",function(e,t){n(t).find(".ac-column-setting--image").cpac_column_setting_image_size()}),n.fn.column_width_slider=function(){var e=n(this).find(".ac-setting-input-width"),t=e.find(".description input"),i=e.find(".unit-select input"),a=i.filter(":checked").val(),c=t.val(),o=e.find(".width-slider"),s=n(this).find(".ac-column-header .ac-column-heading-setting--width");"%"==a&&c>100&&(c=100),t.val(c),o.slider({range:"min",min:0,max:"%"==a?100:500,value:c,slide:function(n,e){t.val(e.value),s.trigger("update"),t.trigger("validate")}})},n.fn.cpac_column_setting_width=function(){n(this).each(function(){var e=n(this).parents(".ac-column");e.column_width_slider();var t=e.find(".ac-column-header .ac-column-heading-setting--width");t.on("update",function(){var t=e.find(".ac-setting-input-width .description input").val(),i=e.find(".ac-setting-input-width .description .unit").text();t>0?n(this).text(t+i):n(this).text("")}),e.find(".ac-setting-input-width .unit-select label").on("click",function(){e.find("span.unit").text(n(this).find("input").val()),e.column_width_slider(),t.trigger("update")});var i=e.find(".ac-setting-input-width .description input").on("keyup",function(){e.column_width_slider(),n(this).trigger("validate"),t.trigger("update")}).on("validate",function(){var e=i.val(),t=n.trim(e);n.isNumeric(t)||(t=t.replace(/\D/g,"")),t.length>3&&(t=t.substring(0,3)),t<=0&&(t=""),t!==e&&i.val(t)})})},n.fn.cpac_column_sub_setting_toggle=function(e){function t(n,e){var t=e.filter(":checked").val(),a=n.find(i.subfield);i.value_show==t?a.show():a.hide()}var i=n.extend({value_show:"on",subfield:".ac-column-setting"},e);n(this).each(function(){var e=n(this),i=n(this).find('.ac-setting-input input[type="radio"]');t(e,i),i.on("change",function(){t(e,i)})})},n.fn.cpac_column_setting_date=function(){n(this).each(function(){var e=n(this),t=e.find("input.custom"),i=e.find(".ac-setting-input-date__custom"),a=e.find(".ac-setting-input-date__example"),c=e.find("input[type=radio]:checked"),o=e.find(".help-msg");e.find("input[type=radio]").on("change",function(){var e=n(this),t=e.closest("label"),c=t.find("code").text(),s=t.find(".ac-setting-input-date__more").html();c&&i.val(c).trigger("change"),e.hasClass("diff")&&(i.val(""),a.text("")),i.prop("disabled",!0),e.hasClass("custom")&&(e.val(i.val()),i.prop("disabled",!1),o.show()),o.hide(),s&&o.html(s).show()}),i.on("change",function(){a.html('<span class="spinner is-active"></span>'),t.val(i.val());var e=n(this).val();if(!e)return void a.text("");n.ajax({url:ajaxurl,method:"post",data:{action:"date_format",date:e}}).done(function(n){a.text(n)})}),c.trigger("change"),0===c.length&&t.trigger("click")})},n(document).on("init_settings",function(e,t){n(t).find(".ac-column-setting--width").cpac_column_setting_width(),n(t).find(".ac-column-setting--date").cpac_column_setting_date(),n(t).find(".ac-column-setting--filter").cpac_column_sub_setting_toggle(),n(t).find(".ac-column-setting--sort").cpac_column_sub_setting_toggle(),n(t).find(".ac-column-setting--edit").cpac_column_sub_setting_toggle()})}(jQuery);
assets/js/admin-settings.js DELETED
@@ -1,876 +0,0 @@
1
- /*
2
- * Fires when the dom is ready
3
- *
4
- */
5
- jQuery( document ).ready( function() {
6
-
7
- if ( jQuery( '#cpac' ).length === 0 ) {
8
- return false;
9
- }
10
-
11
- // General
12
- cpac_init();
13
- cpac_pointer();
14
- cpac_submit_form();
15
-
16
- // Settings Page
17
- cpac_clear_input_defaults();
18
-
19
- // Columns Page
20
- cpac_menu(); // trigger for all other column events
21
- cpac_help();
22
- cpac_add_column();
23
- cpac_importexport();
24
- cpac_sidebar_feedback();
25
- } );
26
-
27
- function cpac_importexport() {
28
- jQuery( '#php-export-results textarea' ).on( 'focus, mouseup', function() {
29
- jQuery( this ).select();
30
- } ).select().focus();
31
- }
32
-
33
- /*
34
- * Submit Form
35
- *
36
- * @since 2.0.2
37
- */
38
- function cpac_submit_form() {
39
-
40
- var $save_buttons = jQuery( '.sidebox a.submit, .column-footer a.submit' );
41
-
42
- $save_buttons.click( function( e ) {
43
-
44
- var $button = jQuery( this );
45
- var $container = $button.closest( '.columns-container' ).addClass( 'saving' );
46
- var columns_data = $container.find( '.cpac-columns form' ).serialize();
47
- var $msg = $container.find( '.ajax-message' );
48
-
49
- $save_buttons.attr( 'disabled', 'disabled' );
50
-
51
- // reset
52
- $container.find( '.ajax-message' ).hide().removeClass( 'error updated' );
53
- jQuery( '.cpac_message' ).remove(); // placed by restore button
54
-
55
- var xhr = jQuery.post( ajaxurl, {
56
- action : 'cpac_columns_update',
57
- data : columns_data,
58
- _ajax_nonce : cpac._ajax_nonce,
59
- storage_model : $container.data( 'type' ),
60
- layout : $container.data( 'layout' )
61
- },
62
-
63
- // JSON repsonse
64
- function( response ) {
65
- if ( response ) {
66
- if ( response.success ) {
67
- $msg.addClass( 'updated' ).find( 'p' ).html( response.data );
68
- $msg.slideDown();//.delay( 2000 ).slideUp();
69
-
70
- $container.addClass( 'stored' );
71
- }
72
-
73
- // Error message
74
- else if ( response.data ) {
75
- $msg.addClass( response.data.type ).find( 'p' ).html( response.data.message );
76
- $msg.slideDown();
77
- }
78
- }
79
-
80
- // No response
81
- else {
82
- }
83
-
84
- }, 'json' );
85
-
86
- // No JSON
87
- xhr.fail( function( error ) {
88
- // We choose not to notify the user of errors, because the settings will have
89
- // been saved correctly despite of PHP notices/errors from plugin or themes.
90
- } );
91
-
92
- // Always
93
- xhr.always( function() {
94
- $save_buttons.removeAttr( 'disabled', 'disabled' );
95
- $container.removeClass( 'saving' );
96
- } );
97
-
98
- jQuery( document ).trigger( 'cac_update', $container );
99
- } );
100
- }
101
-
102
- /*
103
- * Column: bind toggle events
104
- *
105
- * For performance we bind all other events after the click event.
106
- *
107
- * @since 2.0
108
- */
109
- jQuery.fn.column_bind_toggle = function() {
110
-
111
- var column = jQuery( this );
112
- var is_disabled = column.closest( 'cpac-boxes' ).hasClass( 'disabled' );
113
-
114
- column.find( 'td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button' ).click( function( e ) {
115
- e.preventDefault();
116
-
117
- column.toggleClass( 'opened' ).find( '.column-form' ).slideToggle( 150 );
118
-
119
- if ( is_disabled ) {
120
- return;
121
- }
122
-
123
- if ( !column.hasClass( 'events-binded' ) ) {
124
- column.column_bind_events();
125
- }
126
-
127
- column.addClass( 'events-binded' );
128
-
129
- // hook for addons
130
- jQuery( document ).trigger( 'column_init', column );
131
- } );
132
- };
133
-
134
- /*
135
- * Column: bind remove events
136
- *
137
- * @since 2.0
138
- */
139
- jQuery.fn.column_bind_remove = function() {
140
-
141
- jQuery( this ).find( '.remove-button' ).click( function( e ) {
142
- jQuery( this ).closest( '.cpac-column' ).column_remove();
143
-
144
- e.preventDefault();
145
- } );
146
- };
147
-
148
- /**
149
- * Column: bind clone events
150
- *
151
- * @since 2.3.4
152
- */
153
- jQuery.fn.column_bind_clone = function() {
154
-
155
- jQuery( this ).find( '.clone-button' ).click( function( e ) {
156
- var column, clone;
157
-
158
- e.preventDefault();
159
-
160
- column = jQuery( this ).closest( '.cpac-column' );
161
-
162
- clone = column.column_clone();
163
-
164
- if ( typeof clone !== 'undefined' ) {
165
- clone.removeClass( 'loading' ).hide().slideDown();
166
- }
167
- } );
168
- };
169
-
170
- jQuery.fn.cpac_column_refresh = function() {
171
- var el = jQuery( this );
172
- var select = el.find( '.column_type select' );
173
- var $container = jQuery( this ).closest( '.columns-container' );
174
-
175
- // Mark column as loading
176
- el.addClass( 'loading' );
177
- select.prop( 'disabled', 1 );
178
-
179
- // Fetch new form HTML
180
- var xhr = jQuery.post( ajaxurl, {
181
- plugin_id : 'cpac',
182
- action : 'cpac_column_refresh',
183
- _ajax_nonce : cpac._ajax_nonce,
184
- column : jQuery( this ).find( 'input.column-name' ).val(),
185
- formdata : jQuery( this ).parents( 'form' ).serialize(),
186
- storage_model : $container.data( 'type' ),
187
- layout : $container.data( 'layout' ),
188
- }, function( data ) {
189
-
190
- if ( data ) {
191
- // Replace current form by new form
192
- var newel = jQuery( '<div>' + data.data + '</div>' ).children();
193
- el.replaceWith( newel );
194
- el = newel;
195
-
196
- // Bind events
197
- el.column_bind_toggle();
198
- el.column_bind_remove();
199
- el.column_bind_clone();
200
- el.column_bind_events();
201
-
202
- el.addClass( 'opened' ).find( '.column-form' ).show();
203
-
204
- // Allow plugins to hook into this event
205
- jQuery( document ).trigger( 'column_change', el );
206
- }
207
-
208
- // Do nothing
209
- else {
210
-
211
- }
212
- }, 'json' );
213
-
214
- xhr.fail( function( error ) {
215
- var $msg = el.closest( '.columns-container' ).find( '.ajax-message' );
216
-
217
- $msg.addClass( 'error' ).find( 'p' ).html( cpac_i18n.error );
218
- $msg.slideDown();
219
-
220
- el.slideUp( function() { el.remove() } );
221
-
222
- console.log( error.responseText );
223
- } );
224
-
225
- xhr.always( function() {
226
- // Remove "loading" marking from column
227
- el.removeClass( 'loading' );
228
- select.prop( 'disabled', false );
229
- } );
230
- };
231
-
232
- /*
233
- * Form Events
234
- *
235
- * @since 2.0
236
- */
237
- jQuery.fn.column_bind_events = function() {
238
-
239
- var column = jQuery( this );
240
- var container = column.closest( '.columns-container ' );
241
- var storage_model = container.attr( 'data-type' );
242
-
243
- // Current column type
244
- var default_value = column.find( '.column_type select option:selected' ).val();
245
-
246
- column.find( '.column_type select' ).change( function() {
247
- var option = jQuery( 'optgroup', this ).children( ':selected' );
248
- var type = option.val();
249
- var label = option.text();
250
- var msg = jQuery( this ).next( '.msg' ).hide();
251
-
252
- // Find template element for this field type
253
- var template = container.find( '.for-cloning-only .cpac-column[data-type="' + type + '"]' );
254
-
255
- if ( template.length ) {
256
- if ( template.find( '.is-disabled' ).length ) {
257
- msg.html( template.find( '.is-disabled' ).html() ).show();
258
-
259
- // Set to default
260
- jQuery( this ).find( 'option' ).removeAttr( 'selected' );
261
- jQuery( this ).find( 'option[value="' + default_value + '"]' ).attr( 'selected', 'selected' );
262
- }
263
- // Prevent column types that do not allow it to have multiple instances
264
- else if ( typeof template.attr( 'data-clone' ) === 'undefined' && jQuery( '.cpac-columns', container ).find( '[data-type="' + type + '"]' ).length ) {
265
- msg.html( cpac_i18n.clone.replace( '%s', '<strong>' + label + '</strong>' ) ).show();
266
-
267
- // Set to default
268
- jQuery( this ).find( 'option' ).removeAttr( 'selected' );
269
- jQuery( this ).find( 'option[value="' + default_value + '"]' ).attr( 'selected', 'selected' );
270
-
271
- return;
272
- }
273
- else {
274
- var clone = template.clone();
275
-
276
- // Open settings
277
- clone.addClass( 'opened' ).find( '.column-form' ).show();
278
- clone.find( '.column-meta' ).replaceWith( column.find( '.column-meta' ) );
279
- clone.find( '.column-form' ).replaceWith( column.find( '.column-form' ) );
280
-
281
- // Increment clone id
282
- clone.cpac_update_clone_id( storage_model );
283
-
284
- // Load clone
285
- column.replaceWith( clone );
286
- clone.cpac_column_refresh();
287
- }
288
- }
289
- } );
290
-
291
- /** change label */
292
- column.find( '.column_label .input input' ).bind( 'keyup change', function() {
293
-
294
- var value = jQuery( this ).val();
295
- jQuery( this ).closest( '.cpac-column' ).find( 'td.column_label .inner > a.toggle' ).text( value );
296
- } );
297
-
298
- /** width */
299
-
300
- // slider
301
- column.column_width_slider();
302
-
303
- // indicator
304
- var width_indicator = column.find( '.column-meta span.width' );
305
- width_indicator.on( 'update', function() {
306
- var _width = column.find( 'input.width' ).val();
307
- var _unit = column.find( 'input.unit' ).filter( ':checked' ).val();
308
- if ( _width > 0 ) {
309
- jQuery( this ).text( _width + _unit );
310
- } else {
311
- jQuery( this ).text( '' );
312
- }
313
- } );
314
-
315
- // unit selector
316
- var width_unit_select = column.find( '.column_width .unit-select label' );
317
- width_unit_select.on( 'click', function() {
318
-
319
- column.find( 'span.unit' ).text( jQuery( this ).find( 'input' ).val() );
320
- column.column_width_slider(); // re-init slider
321
- width_indicator.trigger( 'update' ); // update indicator
322
- } );
323
-
324
- // width_input
325
- var width_input = column.find( 'input.width' )
326
- .on( 'keyup', function() {
327
- column.column_width_slider(); // re-init slider
328
- jQuery( this ).trigger( 'validate' ); // validate input
329
- width_indicator.trigger( 'update' ); // update indicator
330
- } )
331
-
332
- // width_input:validate
333
- .on( 'validate', function() {
334
- var _width = width_input.val();
335
- var _new_width = jQuery.trim( _width );
336
-
337
- if ( !jQuery.isNumeric( _new_width ) ) {
338
- _new_width = _new_width.replace( /\D/g, '' );
339
- }
340
- if ( _new_width.length > 3 ) {
341
- _new_width = _new_width.substring( 0, 3 );
342
- }
343
- if ( _new_width <= 0 ) {
344
- _new_width = '';
345
- }
346
- if ( _new_width !== _width ) {
347
- width_input.val( _new_width );
348
- }
349
- } );
350
-
351
- /** display custom image size */
352
- column.find( '.column_image_size label.custom-size' ).click( function() {
353
-
354
- var parent = jQuery( this ).closest( '.input' );
355
-
356
- if ( jQuery( this ).hasClass( 'image-size-custom' ) ) {
357
- jQuery( '.custom-size-w', parent ).removeClass( 'hidden' );
358
- jQuery( '.custom-size-h', parent ).removeClass( 'hidden' );
359
- }
360
-
361
- else {
362
- jQuery( '.custom-size-w', parent ).addClass( 'hidden' );
363
- jQuery( '.custom-size-h', parent ).addClass( 'hidden' );
364
- }
365
- } );
366
-
367
- /** tooltip */
368
- column.find( '.column-form .label label, .column-form .label .info' ).hover( function() {
369
- jQuery( this ).parents( '.label' ).find( 'p.description' ).show();
370
- }, function() {
371
- jQuery( this ).parents( '.label' ).find( 'p.description' ).hide();
372
- } );
373
-
374
- // refresh column and re-bind all events
375
- column.find( '[data-refresh="1"] select' ).change( function() {
376
- column.cpac_column_refresh();
377
- } );
378
- };
379
-
380
- /*
381
- * Column: remove from DOM
382
- *
383
- * @since 2.0
384
- */
385
- jQuery.fn.column_remove = function() {
386
- jQuery( this ).addClass( 'deleting' ).animate( { opacity : 0, height : 0 }, 350, function( e ) {
387
- jQuery( this ).remove();
388
- } );
389
- };
390
-
391
- /*
392
- * Column: remove from DOM
393
- *
394
- * @since 2.0
395
- */
396
- jQuery.fn.column_width_slider = function() {
397
-
398
- var column_width = jQuery( this ).find( '.column_width' );
399
-
400
- var input_width = column_width.find( 'input.width' ),
401
- input_unit = column_width.find( 'input.unit' ),
402
- unit = input_unit.filter( ':checked' ).val(),
403
- width = input_width.val(),
404
- slider = column_width.find( '.width-slider' ),
405
- indicator = jQuery( this ).find( '.column-meta span.width' );
406
-
407
- // width
408
- if ( '%' == unit && width > 100 ) {
409
- width = 100;
410
- }
411
-
412
- input_width.val( width );
413
-
414
- slider.slider( {
415
- range : 'min',
416
- min : 0,
417
- max : '%' == unit ? 100 : 500,
418
- value : width,
419
- slide : function( event, ui ) {
420
-
421
- input_width.val( ui.value );
422
- indicator.trigger( 'update' );
423
- input_width.trigger( 'validate' );
424
- }
425
- } );
426
- };
427
-
428
- /*
429
- * Column: clone
430
- *
431
- * @since 2.3.4
432
- */
433
- jQuery.fn.column_clone = function() {
434
-
435
- var container = jQuery( this ).closest( '.columns-container' );
436
- var column = jQuery( this );
437
- var columns = jQuery( this ).closest( 'cpac-columns' );
438
-
439
- if ( typeof column.attr( 'data-clone' ) === 'undefined' ) {
440
- var message = cpac_i18n.clone.replace( '%s', '<strong>' + column.find( '.column_label .toggle' ).text() + '</strong>' );
441
-
442
- column.addClass( 'opened' ).find( '.column-form' ).slideDown( 150 );
443
- column.find( '.msg' ).html( message ).show();
444
-
445
- return;
446
- }
447
-
448
- var clone = jQuery( this ).clone();
449
-
450
- clone.cpac_update_clone_id( container.attr( 'data-type' ) );
451
- jQuery( this ).after( clone );
452
-
453
- // rebind toggle events
454
- clone.column_bind_toggle();
455
-
456
- // rebind remove events
457
- clone.column_bind_remove();
458
-
459
- // rebind clone events
460
- clone.column_bind_clone();
461
-
462
- // rebind all other events
463
- clone.column_bind_events();
464
-
465
- // reinitialize sortability
466
- columns.cpac_bind_ordering();
467
-
468
- // hook for addons
469
- jQuery( document ).trigger( 'column_add', clone );
470
-
471
- return clone;
472
- };
473
-
474
- /*
475
- * Update clone ID
476
- *
477
- * @since 2.0
478
- */
479
- jQuery.fn.cpac_update_clone_id = function( storage_model ) {
480
-
481
- var el = jQuery( this );
482
-
483
- var type = el.attr( 'data-type' );
484
- var all_columns = jQuery( '.columns-container[data-type="' + storage_model + '"]' ).find( '.cpac-columns' );
485
- var columns = jQuery( all_columns ).find( '*[data-type="' + type + '"]' ).not( el );
486
-
487
- // get clone ID
488
- var ids = jQuery.map( columns, function( e, i ) {
489
- if ( jQuery( e ).attr( 'data-clone' ) ) {
490
- return parseInt( jQuery( e ).attr( 'data-clone' ), 10 );
491
- }
492
- return 0;
493
- } );
494
-
495
- ids.sort();
496
- var max_id = Math.max.apply( null, ids ) + 1;
497
- for ( var id = 0; id <= max_id; id++ ) {
498
- if ( -1 === jQuery.inArray( id, ids ) ) {
499
- break;
500
- }
501
- }
502
-
503
- // only increment when needed
504
- //if ( 0 === id )
505
- // return;
506
-
507
- // get original clone ID
508
- var clone_id = el.attr( 'data-clone' );
509
- var clone_suffix = '';
510
-
511
- if ( clone_id ) {
512
- clone_suffix = '-' + clone_id;
513
- }
514
-
515
- // set clone ID
516
- el.attr( 'data-clone', id );
517
- el.find( 'input.clone' ).val( id );
518
- el.find( 'input.column-name' ).val( type + '-' + id );
519
-
520
- // update input names with clone ID
521
- var inputs = el.find( 'input, select, label' );
522
- jQuery( inputs ).each( function( i, v ) {
523
-
524
- var new_name = type + '-' + id;
525
-
526
- // name
527
- if ( jQuery( v ).attr( 'name' ) ) {
528
- jQuery( v ).attr( 'name', jQuery( v ).attr( 'name' ).replace( type + clone_suffix, new_name ) );
529
- }
530
-
531
- // for
532
- if ( jQuery( v ).attr( 'for' ) ) {
533
- jQuery( v ).attr( 'for', jQuery( v ).attr( 'for' ).replace( type + clone_suffix, new_name ) );
534
- }
535
-
536
- // id
537
- if ( jQuery( v ).attr( 'id' ) ) {
538
- jQuery( v ).attr( 'id', jQuery( v ).attr( 'id' ).replace( type + clone_suffix, new_name ) );
539
- }
540
- } );
541
- };
542
-
543
- function cpac_create_column( container ) {
544
-
545
- var clone = jQuery( '.for-cloning-only .cpac-column', container ).not( '[data-default="1"]' ).first().clone();
546
- var storage_model = container.attr( 'data-type' );
547
- var columns = container.find( 'cpac-columns' );
548
-
549
- if ( clone.length > 0 ) {
550
- // increment clone id ( before adding to DOM, otherwise radio buttons will reset )
551
- clone.cpac_update_clone_id( storage_model );
552
-
553
- // add to DOM
554
- jQuery( '.cpac-columns form', container ).append( clone );
555
-
556
- // refresh column
557
- clone.cpac_column_refresh();
558
-
559
- // hook for addons
560
- jQuery( document ).trigger( 'column_add', clone );
561
- }
562
-
563
- return clone;
564
- }
565
-
566
- /*
567
- * Add Column
568
- *
569
- * @since 2.0
570
- */
571
- function cpac_add_column() {
572
-
573
- jQuery( '#cpac .add_column' ).click( function( e ) {
574
- var container = jQuery( this ).closest( '.columns-container' );
575
- var clone = cpac_create_column( container );
576
-
577
- // open settings
578
- clone.addClass( 'opened' ).find( '.column-form' ).slideDown( 150, function() {
579
- jQuery( 'html, body' ).animate( { scrollTop : clone.offset().top - 58 }, 300 );
580
- } );
581
-
582
- e.preventDefault();
583
- } );
584
- }
585
-
586
- /**
587
- * @since 2.2.1
588
- */
589
- function cpac_sidebar_feedback() {
590
- jQuery( function( $ ) {
591
- var sidebox = $( '.sidebox#direct-feedback' );
592
-
593
- sidebox.find( '#feedback-choice a.no' ).click( function( e ) {
594
- e.preventDefault();
595
-
596
- sidebox.find( '#feedback-choice' ).slideUp();
597
- sidebox.find( '#feedback-support' ).slideDown();
598
- } );
599
-
600
- sidebox.find( '#feedback-choice a.yes' ).click( function( e ) {
601
- e.preventDefault();
602
-
603
- sidebox.find( '#feedback-choice' ).slideUp();
604
- sidebox.find( '#feedback-rate' ).slideDown();
605
- } );
606
- } );
607
- }
608
-
609
- /*
610
- * Clear Input Defaults
611
- *
612
- */
613
- function cpac_clear_input_defaults() {
614
- jQuery.fn.cleardefault = function() {
615
- return this.focus( function() {
616
- if ( this.value == this.defaultValue ) {
617
- this.value = "";
618
- }
619
- } ).blur( function() {
620
- if ( !this.value.length ) {
621
- this.value = this.defaultValue;
622
- }
623
- } );
624
- };
625
- jQuery( "#cpac-box-plugin_settings .addons input" ).cleardefault();
626
- }
627
-
628
- /*
629
- * Help
630
- *
631
- * usage: <a href="javascript:;" class="help" data-help="tab-2"></a>
632
- */
633
- function cpac_help() {
634
- jQuery( '#cpac a.help' ).click( function( e ) {
635
- e.preventDefault();
636
-
637
- var panel = jQuery( '#contextual-help-wrap' );
638
-
639
- panel.parent().show();
640
- jQuery( 'a[href="#tab-panel-cpac-' + jQuery( this ).attr( 'data-help' ) + '"]', panel ).trigger( 'click' );
641
- panel.slideDown( 'fast', function() {
642
- panel.focus();
643
- } );
644
- } );
645
- }
646
-
647
- /*
648
- * WP Pointer
649
- *
650
- */
651
- function cpac_pointer() {
652
- jQuery( '.cpac-pointer' ).each( function() {
653
-
654
- // vars
655
- var el = jQuery( this ),
656
- html = el.attr( 'rel' ),
657
- pos = el.attr( 'data-pos' ),
658
- w = el.attr( 'data-width' ),
659
- noclick = el.attr( 'data-noclick' );
660
-
661
- var position = {
662
- at : 'left top', // position of wp-pointer relative to the element which triggers the pointer event
663
- my : 'right top', // position of wp-pointer relative to the at-coordinates
664
- edge : 'right', // position of arrow
665
- };
666
-
667
- var width = w ? w : 250;
668
-
669
- if ( 'right' == pos ) {
670
- position = {
671
- at : 'right middle',
672
- my : 'left middle',
673
- edge : 'left'
674
- };
675
- }
676
-
677
- if ( 'left' == pos ) {
678
- position = {
679
- at : 'left middle',
680
- my : 'right middle',
681
- edge : 'right'
682
- };
683
- }
684
-
685
- // create pointer
686
- el.pointer( {
687
- content : jQuery( '#' + html ).html(),
688
- position : position,
689
- pointerWidth : width,
690
- // bug fix. with an arrow on the right side the position of wp-pointer is incorrect. it does not take
691
- // into account the padding of the arrow. adding "wp-pointer-' + position.edge" will fix that.
692
- pointerClass : 'cpac-wp-pointer wp-pointer wp-pointer-' + position.edge + ( noclick ? ' noclick' : '' )
693
- } );
694
-
695
- // click
696
- if ( !noclick ) {
697
- el.click( function() {
698
- if ( el.hasClass( 'open' ) ) {
699
- el.removeClass( 'open' );
700
- }
701
- else {
702
- el.addClass( 'open' );
703
- }
704
- } );
705
- }
706
-
707
- // show on hover
708
- el.hover( function() {
709
- jQuery( this ).pointer( 'open' );
710
- }, function() {
711
- var el = jQuery( this );
712
- setTimeout( function(){
713
- if ( !el.hasClass( 'open' ) && jQuery('.cpac-wp-pointer.hover' ).length == 0 ) {
714
- el.pointer( 'close' );
715
- }
716
- }, 100 );
717
-
718
- } ).on( 'close', function(){
719
- if ( !el.hasClass( 'open' ) && jQuery('.cpac-wp-pointer.hover' ).length == 0 ) {
720
- el.pointer( 'close' );
721
- }
722
- });
723
- } );
724
-
725
- jQuery('.cpac-wp-pointer' ).hover( function(){
726
- jQuery(this ).addClass('hover');
727
- }, function(){
728
- jQuery(this ).removeClass('hover');
729
- jQuery( '.cpac-pointer' ).trigger('close');
730
- } );
731
-
732
- }
733
-
734
- /*
735
- * Sortable
736
- *
737
- * @since 1.5
738
- */
739
- jQuery.fn.cpac_bind_ordering = function() {
740
- jQuery( this ).each( function() {
741
- if ( jQuery( this ).hasClass( 'ui-sortable' ) ) {
742
- jQuery( this ).sortable( 'refresh' );
743
- }
744
- else {
745
- jQuery( this ).sortable( {
746
- items : '.cpac-column'
747
- } );
748
- }
749
- } );
750
- };
751
-
752
- function cpac_init() {
753
-
754
- var container = jQuery( '.columns-container' );
755
- var boxes = container.find( '.cpac-boxes' );
756
-
757
- // Written for PHP Export
758
- if ( boxes.hasClass( 'disabled' ) ) {
759
- boxes.find( '.cpac-column' ).each( function( i, col ) {
760
- jQuery( col ).column_bind_toggle();
761
- jQuery( col ).find( 'input, select' ).prop( 'disabled', true );
762
- } );
763
- }
764
-
765
- else {
766
- var columns = boxes.find( '.cpac-columns' );
767
-
768
- // we start by binding the toggle and remove events.
769
- columns.find( '.cpac-column' ).each( function( i, col ) {
770
- jQuery( col ).column_bind_toggle();
771
- jQuery( col ).column_bind_remove();
772
- jQuery( col ).column_bind_clone();
773
- jQuery( col ).cpac_bind_indicator_events();
774
- } );
775
-
776
- // ordering of columns
777
- columns.cpac_bind_ordering();
778
- }
779
-
780
- // hook for addons
781
- jQuery( document ).trigger( 'cac_menu_change', columns ); // deprecated
782
- jQuery( document ).trigger( 'cac_model_ready', container.data( 'type' ) );
783
- }
784
-
785
- /*
786
- * Menu
787
- *
788
- * @since 1.5
789
- */
790
- function cpac_menu() {
791
-
792
- //jQuery( '.spinner' ).css( 'visibility', 'visible' );
793
-
794
- jQuery( '#cpac_storage_modal_select' ).on( 'change', function() {
795
- jQuery( this ).prop( 'disabled', true ).next( '.spinner' ).css( 'display', 'inline-block' );
796
- jQuery( '.view-link' ).hide();
797
- window.location = jQuery( this ).val();
798
- } );
799
- }
800
-
801
- /*
802
- * Bind events: triggered after column is init, changed or added
803
- *
804
- */
805
- jQuery( document ).bind( 'column_init column_change column_add', function( e, column ) {
806
-
807
- var is_disabled = jQuery( column ).closest( '.cpac-boxes' ).hasClass( 'disabled' );
808
-
809
- if ( is_disabled ) {
810
- return;
811
- }
812
-
813
- jQuery( column ).cpac_bind_column_addon_events();
814
- jQuery( column ).cpac_bind_indicator_events();
815
- } );
816
-
817
- /*
818
- * Optional Radio Click events
819
- *
820
- */
821
- jQuery.fn.cpac_bind_column_addon_events = function() {
822
-
823
- var column = jQuery( this );
824
- var inputs = column.find( '[data-toggle-id] label' );
825
-
826
- inputs.on( 'click', function() {
827
-
828
- var id = jQuery( this ).closest( 'td.input' ).data( 'toggle-id' );
829
- var state = jQuery( 'input', this ).val();
830
-
831
- // Toggle indicator icon
832
- var label = column.find( '[data-indicator-id="' + id + '"]' ).removeClass( 'on' );
833
- if ( 'on' == state ) {
834
- label.addClass( 'on' );
835
- }
836
-
837
- // Toggle additional options
838
- var additional = column.find( '[data-additional-option-id="' + id + '"]' ).addClass( 'hide' );
839
- if ( 'on' == state ) {
840
- additional.removeClass( 'hide' );
841
- }
842
- } );
843
-
844
- // Toggle additional column settings
845
- column.find( '[data-toggle-id]' ).each( function() {
846
- var additional = column.find( '[data-additional-option-id="' + jQuery( this ).data( 'toggle-id' ) + '"]' ).addClass( 'hide' );
847
- if ( 'on' == jQuery( 'input:checked', this ).val() ) {
848
- additional.removeClass( 'hide' );
849
- }
850
- } );
851
- };
852
-
853
- /*
854
- * Indicator Click Events
855
- *
856
- */
857
- jQuery.fn.cpac_bind_indicator_events = function() {
858
-
859
- var column = jQuery( this );
860
- var indicator = column.find( '[data-indicator-id]' );
861
-
862
- indicator.unbind( 'click' ).click( function() {
863
-
864
- var id = jQuery( this ).data( 'indicator-id' );
865
- var radio = column.find( '[data-toggle-id="' + id + '"] input' );
866
-
867
- if ( jQuery( this ).hasClass( 'on' ) ) {
868
- jQuery( this ).removeClass( 'on' ).addClass( 'off' );
869
- radio.filter( '[value=off]' ).prop( 'checked', true );
870
- }
871
- else {
872
- jQuery( this ).removeClass( 'off' ).addClass( 'on' );
873
- radio.filter( '[value=on]' ).prop( 'checked', true );
874
- }
875
- } );
876
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin-settings.min.js DELETED
@@ -1 +0,0 @@
1
- function cpac_importexport(){jQuery("#php-export-results textarea").on("focus, mouseup",function(){jQuery(this).select()}).select().focus()}function cpac_submit_form(){var e=jQuery(".sidebox a.submit, .column-footer a.submit");e.click(function(n){var t=jQuery(this),a=t.closest(".columns-container").addClass("saving"),i=a.find(".cpac-columns form").serialize(),c=a.find(".ajax-message");e.attr("disabled","disabled"),a.find(".ajax-message").hide().removeClass("error updated"),jQuery(".cpac_message").remove();var o=jQuery.post(ajaxurl,{action:"cpac_columns_update",data:i,_ajax_nonce:cpac._ajax_nonce,storage_model:a.data("type"),layout:a.data("layout")},function(e){e&&(e.success?(c.addClass("updated").find("p").html(e.data),c.slideDown(),a.addClass("stored")):e.data&&(c.addClass(e.data.type).find("p").html(e.data.message),c.slideDown()))},"json");o.fail(function(e){}),o.always(function(){e.removeAttr("disabled","disabled"),a.removeClass("saving")}),jQuery(document).trigger("cac_update",a)})}function cpac_create_column(e){var n=jQuery(".for-cloning-only .cpac-column",e).not('[data-default="1"]').first().clone(),t=e.attr("data-type");e.find("cpac-columns");return n.length>0&&(n.cpac_update_clone_id(t),jQuery(".cpac-columns form",e).append(n),n.cpac_column_refresh(),jQuery(document).trigger("column_add",n)),n}function cpac_add_column(){jQuery("#cpac .add_column").click(function(e){var n=jQuery(this).closest(".columns-container"),t=cpac_create_column(n);t.addClass("opened").find(".column-form").slideDown(150,function(){jQuery("html, body").animate({scrollTop:t.offset().top-58},300)}),e.preventDefault()})}function cpac_sidebar_feedback(){jQuery(function(e){var n=e(".sidebox#direct-feedback");n.find("#feedback-choice a.no").click(function(e){e.preventDefault(),n.find("#feedback-choice").slideUp(),n.find("#feedback-support").slideDown()}),n.find("#feedback-choice a.yes").click(function(e){e.preventDefault(),n.find("#feedback-choice").slideUp(),n.find("#feedback-rate").slideDown()})})}function cpac_clear_input_defaults(){jQuery.fn.cleardefault=function(){return this.focus(function(){this.value==this.defaultValue&&(this.value="")}).blur(function(){this.value.length||(this.value=this.defaultValue)})},jQuery("#cpac-box-plugin_settings .addons input").cleardefault()}function cpac_help(){jQuery("#cpac a.help").click(function(e){e.preventDefault();var n=jQuery("#contextual-help-wrap");n.parent().show(),jQuery('a[href="#tab-panel-cpac-'+jQuery(this).attr("data-help")+'"]',n).trigger("click"),n.slideDown("fast",function(){n.focus()})})}function cpac_pointer(){jQuery(".cpac-pointer").each(function(){var e=jQuery(this),n=e.attr("rel"),t=e.attr("data-pos"),a=e.attr("data-width"),i=e.attr("data-noclick"),c={at:"left top",my:"right top",edge:"right"},o=a?a:250;"right"==t&&(c={at:"right middle",my:"left middle",edge:"left"}),"left"==t&&(c={at:"left middle",my:"right middle",edge:"right"}),e.pointer({content:jQuery("#"+n).html(),position:c,pointerWidth:o,pointerClass:"cpac-wp-pointer wp-pointer wp-pointer-"+c.edge+(i?" noclick":"")}),i||e.click(function(){e.hasClass("open")?e.removeClass("open"):e.addClass("open")}),e.hover(function(){jQuery(this).pointer("open")},function(){var e=jQuery(this);setTimeout(function(){e.hasClass("open")||0!=jQuery(".cpac-wp-pointer.hover").length||e.pointer("close")},100)}).on("close",function(){e.hasClass("open")||0!=jQuery(".cpac-wp-pointer.hover").length||e.pointer("close")})}),jQuery(".cpac-wp-pointer").hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover"),jQuery(".cpac-pointer").trigger("close")})}function cpac_init(){var e=jQuery(".columns-container"),n=e.find(".cpac-boxes");if(n.hasClass("disabled"))n.find(".cpac-column").each(function(e,n){jQuery(n).column_bind_toggle(),jQuery(n).find("input, select").prop("disabled",!0)});else{var t=n.find(".cpac-columns");t.find(".cpac-column").each(function(e,n){jQuery(n).column_bind_toggle(),jQuery(n).column_bind_remove(),jQuery(n).column_bind_clone(),jQuery(n).cpac_bind_indicator_events()}),t.cpac_bind_ordering()}jQuery(document).trigger("cac_menu_change",t),jQuery(document).trigger("cac_model_ready",e.data("type"))}function cpac_menu(){jQuery("#cpac_storage_modal_select").on("change",function(){jQuery(this).prop("disabled",!0).next(".spinner").css("display","inline-block"),jQuery(".view-link").hide(),window.location=jQuery(this).val()})}jQuery(document).ready(function(){return 0!==jQuery("#cpac").length&&(cpac_init(),cpac_pointer(),cpac_submit_form(),cpac_clear_input_defaults(),cpac_menu(),cpac_help(),cpac_add_column(),cpac_importexport(),void cpac_sidebar_feedback())}),jQuery.fn.column_bind_toggle=function(){var e=jQuery(this),n=e.closest("cpac-boxes").hasClass("disabled");e.find("td.column_type a, td.column_edit, td.column_label a.toggle, td.column_label .edit-button").click(function(t){t.preventDefault(),e.toggleClass("opened").find(".column-form").slideToggle(150),n||(e.hasClass("events-binded")||e.column_bind_events(),e.addClass("events-binded"),jQuery(document).trigger("column_init",e))})},jQuery.fn.column_bind_remove=function(){jQuery(this).find(".remove-button").click(function(e){jQuery(this).closest(".cpac-column").column_remove(),e.preventDefault()})},jQuery.fn.column_bind_clone=function(){jQuery(this).find(".clone-button").click(function(e){var n,t;e.preventDefault(),n=jQuery(this).closest(".cpac-column"),t=n.column_clone(),"undefined"!=typeof t&&t.removeClass("loading").hide().slideDown()})},jQuery.fn.cpac_column_refresh=function(){var e=jQuery(this),n=e.find(".column_type select"),t=jQuery(this).closest(".columns-container");e.addClass("loading"),n.prop("disabled",1);var a=jQuery.post(ajaxurl,{plugin_id:"cpac",action:"cpac_column_refresh",_ajax_nonce:cpac._ajax_nonce,column:jQuery(this).find("input.column-name").val(),formdata:jQuery(this).parents("form").serialize(),storage_model:t.data("type"),layout:t.data("layout")},function(n){if(n){var t=jQuery("<div>"+n.data+"</div>").children();e.replaceWith(t),e=t,e.column_bind_toggle(),e.column_bind_remove(),e.column_bind_clone(),e.column_bind_events(),e.addClass("opened").find(".column-form").show(),jQuery(document).trigger("column_change",e)}},"json");a.fail(function(n){var t=e.closest(".columns-container").find(".ajax-message");t.addClass("error").find("p").html(cpac_i18n.error),t.slideDown(),e.slideUp(function(){e.remove()}),console.log(n.responseText)}),a.always(function(){e.removeClass("loading"),n.prop("disabled",!1)})},jQuery.fn.column_bind_events=function(){var e=jQuery(this),n=e.closest(".columns-container "),t=n.attr("data-type"),a=e.find(".column_type select option:selected").val();e.find(".column_type select").change(function(){var i=jQuery("optgroup",this).children(":selected"),c=i.val(),o=i.text(),r=jQuery(this).next(".msg").hide(),l=n.find('.for-cloning-only .cpac-column[data-type="'+c+'"]');if(l.length)if(l.find(".is-disabled").length)r.html(l.find(".is-disabled").html()).show(),jQuery(this).find("option").removeAttr("selected"),jQuery(this).find('option[value="'+a+'"]').attr("selected","selected");else{if("undefined"==typeof l.attr("data-clone")&&jQuery(".cpac-columns",n).find('[data-type="'+c+'"]').length)return r.html(cpac_i18n.clone.replace("%s","<strong>"+o+"</strong>")).show(),jQuery(this).find("option").removeAttr("selected"),void jQuery(this).find('option[value="'+a+'"]').attr("selected","selected");var u=l.clone();u.addClass("opened").find(".column-form").show(),u.find(".column-meta").replaceWith(e.find(".column-meta")),u.find(".column-form").replaceWith(e.find(".column-form")),u.cpac_update_clone_id(t),e.replaceWith(u),u.cpac_column_refresh()}}),e.find(".column_label .input input").bind("keyup change",function(){var e=jQuery(this).val();jQuery(this).closest(".cpac-column").find("td.column_label .inner > a.toggle").text(e)}),e.column_width_slider();var i=e.find(".column-meta span.width");i.on("update",function(){var n=e.find("input.width").val(),t=e.find("input.unit").filter(":checked").val();n>0?jQuery(this).text(n+t):jQuery(this).text("")});var c=e.find(".column_width .unit-select label");c.on("click",function(){e.find("span.unit").text(jQuery(this).find("input").val()),e.column_width_slider(),i.trigger("update")});var o=e.find("input.width").on("keyup",function(){e.column_width_slider(),jQuery(this).trigger("validate"),i.trigger("update")}).on("validate",function(){var e=o.val(),n=jQuery.trim(e);jQuery.isNumeric(n)||(n=n.replace(/\D/g,"")),n.length>3&&(n=n.substring(0,3)),n<=0&&(n=""),n!==e&&o.val(n)});e.find(".column_image_size label.custom-size").click(function(){var e=jQuery(this).closest(".input");jQuery(this).hasClass("image-size-custom")?(jQuery(".custom-size-w",e).removeClass("hidden"),jQuery(".custom-size-h",e).removeClass("hidden")):(jQuery(".custom-size-w",e).addClass("hidden"),jQuery(".custom-size-h",e).addClass("hidden"))}),e.find(".column-form .label label, .column-form .label .info").hover(function(){jQuery(this).parents(".label").find("p.description").show()},function(){jQuery(this).parents(".label").find("p.description").hide()}),e.find('[data-refresh="1"] select').change(function(){e.cpac_column_refresh()})},jQuery.fn.column_remove=function(){jQuery(this).addClass("deleting").animate({opacity:0,height:0},350,function(e){jQuery(this).remove()})},jQuery.fn.column_width_slider=function(){var e=jQuery(this).find(".column_width"),n=e.find("input.width"),t=e.find("input.unit"),a=t.filter(":checked").val(),i=n.val(),c=e.find(".width-slider"),o=jQuery(this).find(".column-meta span.width");"%"==a&&i>100&&(i=100),n.val(i),c.slider({range:"min",min:0,max:"%"==a?100:500,value:i,slide:function(e,t){n.val(t.value),o.trigger("update"),n.trigger("validate")}})},jQuery.fn.column_clone=function(){var e=jQuery(this).closest(".columns-container"),n=jQuery(this),t=jQuery(this).closest("cpac-columns");if("undefined"==typeof n.attr("data-clone")){var a=cpac_i18n.clone.replace("%s","<strong>"+n.find(".column_label .toggle").text()+"</strong>");return n.addClass("opened").find(".column-form").slideDown(150),void n.find(".msg").html(a).show()}var i=jQuery(this).clone();return i.cpac_update_clone_id(e.attr("data-type")),jQuery(this).after(i),i.column_bind_toggle(),i.column_bind_remove(),i.column_bind_clone(),i.column_bind_events(),t.cpac_bind_ordering(),jQuery(document).trigger("column_add",i),i},jQuery.fn.cpac_update_clone_id=function(e){var n=jQuery(this),t=n.attr("data-type"),a=jQuery('.columns-container[data-type="'+e+'"]').find(".cpac-columns"),i=jQuery(a).find('*[data-type="'+t+'"]').not(n),c=jQuery.map(i,function(e,n){return jQuery(e).attr("data-clone")?parseInt(jQuery(e).attr("data-clone"),10):0});c.sort();for(var o=Math.max.apply(null,c)+1,r=0;r<=o&&-1!==jQuery.inArray(r,c);r++);var l=n.attr("data-clone"),u="";l&&(u="-"+l),n.attr("data-clone",r),n.find("input.clone").val(r),n.find("input.column-name").val(t+"-"+r);var d=n.find("input, select, label");jQuery(d).each(function(e,n){var a=t+"-"+r;jQuery(n).attr("name")&&jQuery(n).attr("name",jQuery(n).attr("name").replace(t+u,a)),jQuery(n).attr("for")&&jQuery(n).attr("for",jQuery(n).attr("for").replace(t+u,a)),jQuery(n).attr("id")&&jQuery(n).attr("id",jQuery(n).attr("id").replace(t+u,a))})},jQuery.fn.cpac_bind_ordering=function(){jQuery(this).each(function(){jQuery(this).hasClass("ui-sortable")?jQuery(this).sortable("refresh"):jQuery(this).sortable({items:".cpac-column"})})},jQuery(document).bind("column_init column_change column_add",function(e,n){var t=jQuery(n).closest(".cpac-boxes").hasClass("disabled");t||(jQuery(n).cpac_bind_column_addon_events(),jQuery(n).cpac_bind_indicator_events())}),jQuery.fn.cpac_bind_column_addon_events=function(){var e=jQuery(this),n=e.find("[data-toggle-id] label");n.on("click",function(){var n=jQuery(this).closest("td.input").data("toggle-id"),t=jQuery("input",this).val(),a=e.find('[data-indicator-id="'+n+'"]').removeClass("on");"on"==t&&a.addClass("on");var i=e.find('[data-additional-option-id="'+n+'"]').addClass("hide");"on"==t&&i.removeClass("hide")}),e.find("[data-toggle-id]").each(function(){var n=e.find('[data-additional-option-id="'+jQuery(this).data("toggle-id")+'"]').addClass("hide");"on"==jQuery("input:checked",this).val()&&n.removeClass("hide")})},jQuery.fn.cpac_bind_indicator_events=function(){var e=jQuery(this),n=e.find("[data-indicator-id]");n.unbind("click").click(function(){var n=jQuery(this).data("indicator-id"),t=e.find('[data-toggle-id="'+n+'"] input');jQuery(this).hasClass("on")?(jQuery(this).removeClass("on").addClass("off"),t.filter("[value=off]").prop("checked",!0)):(jQuery(this).removeClass("off").addClass("on"),t.filter("[value=on]").prop("checked",!0))})};
 
assets/js/message.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // CPAC Notices
2
+ jQuery( function( $ ) {
3
+ $( document ).ready( function() {
4
+
5
+ $( '.updated a.hide-install-addons-notice' ).click( function( e ) {
6
+ e.preventDefault();
7
+
8
+ var el = $( this ).parents( '.ac-message' );
9
+ var el_close = el.find( '.hide-notice' );
10
+
11
+ el_close.hide();
12
+ el_close.after( '<div class="spinner right"></div>' );
13
+ el.find( '.spinner' ).show();
14
+
15
+ $.post( ajaxurl, {
16
+ 'action' : 'cpac_hide_install_addons_notice'
17
+ }, function() {
18
+ el.find( '.spinner' ).remove();
19
+ el.slideUp();
20
+ } );
21
+
22
+ return false;
23
+ } );
24
+ } );
25
+
26
+ } );
assets/js/message.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(function(n){n(document).ready(function(){n(".updated a.hide-install-addons-notice").click(function(i){i.preventDefault();var e=n(this).parents(".ac-message"),t=e.find(".hide-notice");return t.hide(),t.after('<div class="spinner right"></div>'),e.find(".spinner").show(),n.post(ajaxurl,{action:"cpac_hide_install_addons_notice"},function(){e.find(".spinner").remove(),e.slideUp()}),!1})})});
assets/js/table.js ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function( $ ) {
2
+ ac_quickedit_events( $ );
3
+ ac_set_column_classes( $ );
4
+ ac_actions_column( $, $( '.column-actions' ) );
5
+ ac_tooltips( $ );
6
+ ac_show_more( $ );
7
+ ac_edit_button( $ );
8
+ ac_toggle_box( $ );
9
+ ac_toggle_box_ajax_init( $ );
10
+
11
+ $( '.wp-list-table' ).on( 'updated', 'tr', function() {
12
+ ac_set_column_classes( $ );
13
+ ac_actions_column( $, $( this ).find( '.column-actions' ) );
14
+ ac_show_more( $ );
15
+ } );
16
+ } );
17
+
18
+ function ac_edit_button( $ ) {
19
+ if ( AC.edit_link ) {
20
+ $( '.tablenav.top .actions:last' ).append( '<a class="cpac-edit add-new-h2" href="' + AC.edit_link + '">' + AC.i18n.edit_columns + '</a>' );
21
+ }
22
+ }
23
+
24
+ function ac_toggle_box( $ ) {
25
+ $( '.ac-toggle-box-link' ).click( function( e ) {
26
+ e.preventDefault();
27
+ $( this ).next( '.ac-toggle-box-contents' ).toggle();
28
+ } );
29
+ }
30
+
31
+ function ac_toggle_box_ajax_init( $ ) {
32
+
33
+ /**
34
+ * Toggle box
35
+ */
36
+ var do_toggle_value = function( e ) {
37
+ e.preventDefault();
38
+
39
+ $( this ).next( '.ac-toggle-box-contents-ajax' ).toggle();
40
+ };
41
+
42
+ /**
43
+ * Retrieves the contents from the column through ajax
44
+ */
45
+ var do_retrieve_ajax_value = function( e ) {
46
+ e.preventDefault();
47
+
48
+ var $this = $( this );
49
+
50
+ var data = {
51
+ action : 'ac_get_column_value',
52
+ list_screen : AC.list_screen,
53
+ layout : AC.layout,
54
+ column : $this.data( 'column' ),
55
+ pk : $this.attr( 'data-item-id' ),
56
+ _ajax_nonce : AC.ajax_nonce
57
+ };
58
+
59
+ $this.addClass( 'loading' );
60
+
61
+ var xhr = $.post( ajaxurl, data, function( response ) {
62
+ if ( response ) {
63
+ $this.after( '<div class="ac-toggle-box-contents-ajax">' + response + '</div>' );
64
+
65
+ // We only need to run the ajax request once. Unbind the event, and replace with a Toggle Box.
66
+ $this.unbind( 'click', do_retrieve_ajax_value ).bind( 'click', do_toggle_value );
67
+
68
+ // Added hook on Table Cell
69
+ $( $this.parent( 'td' ) ).trigger( 'ajax_column_value_ready' );
70
+
71
+ // Re-init tooltips
72
+ ac_tooltips( $ );
73
+ }
74
+ } );
75
+
76
+ xhr.always( function() {
77
+ $this.removeClass( 'loading' );
78
+ } );
79
+ };
80
+
81
+ // Click event
82
+ $( 'a[data-ajax-populate=1]' ).bind( 'click', do_retrieve_ajax_value );
83
+ }
84
+
85
+ function ac_show_more( $ ) {
86
+ $( '.ac-more-link-show' ).click( function( e ) {
87
+ e.preventDefault();
88
+ var td = $( this ).hide().closest( 'td' );
89
+
90
+ td.find( '.ac-show-more-block' ).show();
91
+
92
+ } );
93
+ $( '.ac-more-link-hide' ).click( function( e ) {
94
+ e.preventDefault();
95
+ var td = $( this ).closest( 'td' );
96
+
97
+ td.find( '.ac-more-link-show' ).show();
98
+ td.find( '.ac-show-more-block' ).hide();
99
+ } );
100
+ }
101
+
102
+ function ac_actions_column( $, $selector ) {
103
+ $( $selector ).each( function() {
104
+ var $column = $( this );
105
+
106
+ if ( $column.find( '.cpac_use_icons' ).length > 0 ) {
107
+ $column.addClass( 'cpac_use_icons' );
108
+ }
109
+ } );
110
+
111
+ $( $selector ).find( '.cpac_use_icons + .hidden + .row-actions > span' ).each( function() {
112
+ var $link = $( this ).find( 'a' );
113
+ $link.attr( 'data-ac-tip', $link.text() ).addClass( 'ac-tip' );
114
+ } );
115
+ }
116
+
117
+ function ac_set_column_classes( $ ) {
118
+ for ( var name in AC.column_types ) {
119
+ if ( AC.column_types.hasOwnProperty( name ) ) {
120
+ var type = AC.column_types[ name ];
121
+
122
+ $( '.wp-list-table td.' + name ).addClass( type );
123
+ }
124
+ }
125
+ }
126
+
127
+ /**
128
+ * @since 2.2.4
129
+ */
130
+ function ac_tooltips( $ ) {
131
+
132
+ if ( typeof $.fn.qtip === 'undefined' ) {
133
+ return;
134
+ }
135
+
136
+ $( '[data-ac-tip]' ).qtip( {
137
+ content : {
138
+ attr : 'data-ac-tip'
139
+ },
140
+ position : {
141
+ my : 'top center',
142
+ at : 'bottom center'
143
+ },
144
+ style : {
145
+ tip : true,
146
+ classes : 'qtip-tipsy'
147
+ }
148
+ } );
149
+ }
150
+
151
+ function ac_quickedit_events( $ ) {
152
+
153
+ $( document ).ajaxComplete( function( event, request ) {
154
+ var $result = $( '<div>' ).append( request.responseText );
155
+
156
+ if ( $result.find( 'tr.iedit' ).length === 1 ) {
157
+ var id = $result.find( 'tr.iedit' ).attr( 'id' );
158
+
159
+ $( 'tr#' + id ).trigger( 'updated' );
160
+ }
161
+ } );
162
+ }
assets/js/table.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function ac_edit_button(t){AC.edit_link&&t(".tablenav.top .actions:last").append('<a class="cpac-edit add-new-h2" href="'+AC.edit_link+'">'+AC.i18n.edit_columns+"</a>")}function ac_toggle_box(t){t(".ac-toggle-box-link").click(function(a){a.preventDefault(),t(this).next(".ac-toggle-box-contents").toggle()})}function ac_toggle_box_ajax_init(t){var a=function(a){a.preventDefault(),t(this).next(".ac-toggle-box-contents-ajax").toggle()},n=function(c){c.preventDefault();var o=t(this),e={action:"ac_get_column_value",list_screen:AC.list_screen,layout:AC.layout,column:o.data("column"),pk:o.attr("data-item-id"),_ajax_nonce:AC.ajax_nonce};o.addClass("loading"),t.post(ajaxurl,e,function(c){c&&(o.after('<div class="ac-toggle-box-contents-ajax">'+c+"</div>"),o.unbind("click",n).bind("click",a),t(o.parent("td")).trigger("ajax_column_value_ready"),ac_tooltips(t))}).always(function(){o.removeClass("loading")})};t("a[data-ajax-populate=1]").bind("click",n)}function ac_show_more(t){t(".ac-more-link-show").click(function(a){a.preventDefault(),t(this).hide().closest("td").find(".ac-show-more-block").show()}),t(".ac-more-link-hide").click(function(a){a.preventDefault();var n=t(this).closest("td");n.find(".ac-more-link-show").show(),n.find(".ac-show-more-block").hide()})}function ac_actions_column(t,a){t(a).each(function(){var a=t(this);a.find(".cpac_use_icons").length>0&&a.addClass("cpac_use_icons")}),t(a).find(".cpac_use_icons + .hidden + .row-actions > span").each(function(){var a=t(this).find("a");a.attr("data-ac-tip",a.text()).addClass("ac-tip")})}function ac_set_column_classes(t){for(var a in AC.column_types)if(AC.column_types.hasOwnProperty(a)){var n=AC.column_types[a];t(".wp-list-table td."+a).addClass(n)}}function ac_tooltips(t){void 0!==t.fn.qtip&&t("[data-ac-tip]").qtip({content:{attr:"data-ac-tip"},position:{my:"top center",at:"bottom center"},style:{tip:!0,classes:"qtip-tipsy"}})}function ac_quickedit_events(t){t(document).ajaxComplete(function(a,n){var c=t("<div>").append(n.responseText);if(1===c.find("tr.iedit").length){var o=c.find("tr.iedit").attr("id");t("tr#"+o).trigger("updated")}})}jQuery(document).ready(function(t){ac_quickedit_events(t),ac_set_column_classes(t),ac_actions_column(t,t(".column-actions")),ac_tooltips(t),ac_show_more(t),ac_edit_button(t),ac_toggle_box(t),ac_toggle_box_ajax_init(t),t(".wp-list-table").on("updated","tr",function(){ac_set_column_classes(t),ac_actions_column(t,t(this).find(".column-actions")),ac_show_more(t)})});
classes/API.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_API {
8
+
9
+ /**
10
+ * @var array [
11
+ * $listscreen_key => [
12
+ * [ 'columns' ][ array $column_settings ]
13
+ * [ 'layout' ][ array $layout_settings ]
14
+ * ]
15
+ * ]
16
+ */
17
+ private $columndata;
18
+
19
+ /**
20
+ * @param AC_ListScreen $list_screen
21
+ */
22
+ public function set_column_settings( AC_ListScreen $list_screen ) {
23
+ if ( $settings = $this->get_column_settings( $list_screen ) ) {
24
+ $list_screen->set_settings( $settings )->set_read_only( true );
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @param AC_ListScreen $list_screen
30
+ *
31
+ * @return array|false
32
+ */
33
+ public function get_column_settings( AC_ListScreen $list_screen ) {
34
+ if ( $columndata = $this->get_columndata( $list_screen->get_key() ) ) {
35
+ foreach ( $columndata as $data ) {
36
+ if ( $list_screen->get_storage_key() === $list_screen->get_key() . $data['layout']['id'] ) {
37
+ return $data['columns'];
38
+ }
39
+ }
40
+ }
41
+
42
+ return false;
43
+ }
44
+
45
+ /**
46
+ * @param AC_ListScreen $list_screen
47
+ *
48
+ * @return array
49
+ */
50
+ public function get_layouts_settings( $list_screen ) {
51
+ $layouts = array();
52
+ if ( $columndata = $this->get_columndata( $list_screen->get_key() ) ) {
53
+ foreach ( $columndata as $data ) {
54
+ $layouts[] = $data['layout'];
55
+ }
56
+ }
57
+
58
+ return $layouts;
59
+ }
60
+
61
+ /**
62
+ * @param string|array $list_screen_key List screen key or keys
63
+ * @param array $column_data
64
+ */
65
+ public function load_columndata( $list_screen_keys, $columndata ) {
66
+ foreach ( (array) $list_screen_keys as $list_screen_key ) {
67
+ $this->add_columndata( $list_screen_key, $columndata );
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @param string $list_screen_key List screen key
73
+ * @param array $column_data
74
+ */
75
+ private function add_columndata( $list_screen_key, $columndata ) {
76
+ $columndata = $this->convert_old_format_to_current( $columndata );
77
+ $columndata = $this->set_as_read_only( $columndata );
78
+
79
+ $this->columndata[ $list_screen_key ] = array_merge( $this->get_columndata( $list_screen_key ), $columndata );
80
+ }
81
+
82
+ /**
83
+ * @param string $list_screen_key
84
+ *
85
+ * @return array
86
+ */
87
+ private function get_columndata( $list_screen_key ) {
88
+ if ( ! isset( $this->columndata[ $list_screen_key ] ) ) {
89
+ return array();
90
+ }
91
+
92
+ return $this->columndata[ $list_screen_key ];
93
+ }
94
+
95
+ /**
96
+ * @param array $columndata
97
+ *
98
+ * @return array
99
+ */
100
+ private function set_as_read_only( $columndata ) {
101
+ foreach ( $columndata as $k => $column ) {
102
+ $columndata[ $k ]['layout']['read_only'] = true;
103
+ }
104
+
105
+ return $columndata;
106
+ }
107
+
108
+ /**
109
+ * Convert the old v3 format to the latest which includes layouts
110
+ *
111
+ * @param array $columndata
112
+ *
113
+ * @return array
114
+ */
115
+ private function convert_old_format_to_current( $columndata ) {
116
+
117
+ // Convert old export formats to new layout format
118
+ $old_format_columns = array();
119
+ foreach ( $columndata as $k => $data ) {
120
+ if ( ! isset( $data['columns'] ) ) {
121
+ $old_format_columns[ $k ] = $data;
122
+ unset( $columndata[ $k ] );
123
+ }
124
+ }
125
+
126
+ if ( $old_format_columns ) {
127
+ array_unshift( $columndata, array( 'columns' => $old_format_columns ) );
128
+ }
129
+
130
+ // Add layout if missing
131
+ foreach ( $columndata as $k => $data ) {
132
+ if ( ! isset( $data['layout'] ) ) {
133
+
134
+ $columndata[ $k ] = array(
135
+ 'columns' => isset( $data['columns'] ) ? $data['columns'] : $data,
136
+ 'layout' => array(
137
+ // unique id based on settings
138
+ 'id' => sanitize_key( substr( md5( serialize( $data ) ), 0, 16 ) ),
139
+ 'name' => __( 'Imported' ) . ( $k ? ' #' . $k : '' ),
140
+ ),
141
+ );
142
+ }
143
+ }
144
+
145
+ return $columndata;
146
+ }
147
+
148
+ /**
149
+ * @param string $json JSON encoded settings
150
+ */
151
+ public function load_from_json( $json ) {
152
+ $array = json_decode( $json, true );
153
+
154
+ $this->load_from_array( $array );
155
+ }
156
+
157
+ /**
158
+ * @param array $array
159
+ */
160
+ public function load_from_array( $array ) {
161
+ foreach ( $array as $list_screen => $columndata ) {
162
+ $this->load_columndata( $list_screen, $columndata );
163
+ }
164
+ }
165
+
166
+ }
classes/Addon.php ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addon {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $title;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $description;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ private $logo;
23
+
24
+ /**
25
+ * Icon is a small version of the logo. Mainly used on the promo banner.
26
+ *
27
+ * @var string
28
+ */
29
+ private $icon;
30
+
31
+ /**
32
+ * Plugin folder name
33
+ *
34
+ * @var AC_PluginInformation
35
+ */
36
+ private $addon;
37
+
38
+ /**
39
+ * Plugin basename. Example: plugin/plugin.php
40
+ *
41
+ * @var AC_PluginInformation[]
42
+ */
43
+ private $plugins;
44
+
45
+ /**
46
+ * External website link
47
+ *
48
+ * @var string
49
+ */
50
+ private $link;
51
+
52
+ /**
53
+ * Plugin URL. Place where the plugin can be downloaded from. Default is install plugin screen.
54
+ *
55
+ * @var string Url
56
+ */
57
+ private $plugin_url;
58
+
59
+ public function __construct( $addon_dirname ) {
60
+ $this->addon = new AC_PluginInformation( $addon_dirname );
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function get_title() {
67
+ return $this->title;
68
+ }
69
+
70
+ /**
71
+ * @param string $title
72
+ */
73
+ protected function set_title( $title ) {
74
+ $this->title = $title;
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Plugin folder name
81
+ *
82
+ * @return AC_PluginInformation[]
83
+ */
84
+ public function get_plugins() {
85
+ return $this->plugins;
86
+ }
87
+
88
+ /**
89
+ * @param string $slug Plugin folder name. Example: 'plugin/init.php' then directory name is 'plugin'.
90
+ */
91
+ protected function add_plugin( $plugin ) {
92
+ $this->plugins[] = new AC_PluginInformation( $plugin );
93
+
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * @return AC_PluginInformation
99
+ */
100
+ public function get_plugin() {
101
+ return $this->plugins[0];
102
+ }
103
+
104
+ /**
105
+ * @return string
106
+ */
107
+ public function get_link() {
108
+ if ( null === $this->link ) {
109
+ $this->set_link( ac_get_site_utm_url( 'pricing-purchase', 'addon' ) );
110
+ }
111
+
112
+ return $this->link;
113
+ }
114
+
115
+ /**
116
+ * @param string $link
117
+ */
118
+ protected function set_link( $url ) {
119
+ if ( ac_helper()->string->is_valid_url( $url ) ) {
120
+ $this->link = $url;
121
+ }
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * @return string
128
+ */
129
+ public function get_description() {
130
+ return $this->description;
131
+ }
132
+
133
+ /**
134
+ * @param string $description
135
+ */
136
+ protected function set_description( $description ) {
137
+ $this->description = $description;
138
+
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * @return string
144
+ */
145
+ public function get_logo() {
146
+ return $this->logo;
147
+ }
148
+
149
+ /**
150
+ * @param string $logo
151
+ */
152
+ protected function set_logo( $logo ) {
153
+ $this->logo = $logo;
154
+
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * @return string
160
+ */
161
+ public function get_icon() {
162
+ return $this->icon;
163
+ }
164
+
165
+ /**
166
+ * @param string $icon
167
+ */
168
+ protected function set_icon( $icon ) {
169
+ $this->icon = $icon;
170
+
171
+ return $this;
172
+ }
173
+
174
+ /**
175
+ * Plugin folder name
176
+ *
177
+ * @return string
178
+ */
179
+ public function get_slug() {
180
+ return $this->addon->get_dirname();
181
+ }
182
+
183
+ /**
184
+ * @return bool
185
+ */
186
+ public function is_installed() {
187
+ return $this->addon->is_installed();
188
+ }
189
+
190
+ /**
191
+ * @return bool
192
+ */
193
+ public function is_active() {
194
+ return $this->addon->is_active();
195
+ }
196
+
197
+ /**
198
+ * @return string|false Returns the plugin version if the plugin is installed, false otherwise
199
+ */
200
+ public function get_version() {
201
+ return $this->addon->get_version();
202
+ }
203
+
204
+ /**
205
+ * @return string Basename
206
+ */
207
+ public function get_basename() {
208
+ return $this->addon->get_basename();
209
+ }
210
+
211
+ /**
212
+ * @return bool
213
+ */
214
+ public function is_plugin_installed() {
215
+ return $this->get_plugin()->is_installed();
216
+ }
217
+
218
+ /**
219
+ * @return bool
220
+ */
221
+ public function is_plugin_active() {
222
+ return $this->get_plugin()->is_active();
223
+ }
224
+
225
+ /**
226
+ * @return string Basename
227
+ */
228
+ public function get_plugin_basename() {
229
+ return $this->get_plugin()->get_basename();
230
+ }
231
+
232
+ /**
233
+ * @return string
234
+ */
235
+ public function get_plugin_activation_url() {
236
+ return $this->get_activation_url( $this->get_plugin_basename() );
237
+ }
238
+
239
+ /**
240
+ * Icon
241
+ */
242
+ public function display_icon() {
243
+ if ( $this->get_icon() ) : ?>
244
+ <img class="icon <?php echo esc_attr( $this->get_slug() ); ?>" src="<?php echo esc_attr( $this->get_icon() ); ?>" alt="<?php echo esc_attr( $this->get_title() ); ?>">
245
+ <?php endif;
246
+ }
247
+
248
+ public function display_promo() {
249
+ if ( $this->get_icon() ) {
250
+ $this->display_icon();
251
+
252
+ return;
253
+ }
254
+
255
+ echo $this->get_title();
256
+ }
257
+
258
+ /**
259
+ * @return AC_Column_Placeholder
260
+ */
261
+ public function get_placeholder_column() {
262
+ $column = new AC_Column_Placeholder();
263
+ $column->set_addon( $this );
264
+
265
+ return $column;
266
+ }
267
+
268
+ /**
269
+ * @param string $title
270
+ *
271
+ * @return string
272
+ */
273
+ protected function get_fields_description( $title ) {
274
+ return sprintf( __( 'Display and edit %s fields in the posts overview in seconds!', 'codepress-admin-columns' ), $title );
275
+ }
276
+
277
+ /**
278
+ * Activate plugin
279
+ *
280
+ * @return string
281
+ */
282
+ public function get_activation_url( $basename ) {
283
+ return $this->get_plugin_action_url( 'activate', $basename );
284
+ }
285
+
286
+ /**
287
+ * Deactivate plugin
288
+ *
289
+ * @return string
290
+ */
291
+ public function get_deactivation_url( $basename ) {
292
+ return $this->get_plugin_action_url( 'deactivate', $basename );
293
+ }
294
+
295
+ /**
296
+ * Activate or Deactivate plugin
297
+ *
298
+ * @param string $action
299
+ *
300
+ * @return string
301
+ */
302
+ private function get_plugin_action_url( $action = 'activate', $basename ) {
303
+ $plugin_url = add_query_arg( array(
304
+ 'action' => $action,
305
+ 'plugin' => $basename,
306
+ 'ac-redirect' => true,
307
+ ), admin_url( 'plugins.php' ) );
308
+
309
+ return wp_nonce_url( $plugin_url, $action . '-plugin_' . $basename );
310
+ }
311
+
312
+ /**
313
+ * @param string $plugin_url
314
+ *
315
+ * @return $this
316
+ */
317
+ public function set_plugin_url( $plugin_url ) {
318
+ $this->plugin_url = $plugin_url;
319
+
320
+ return $this;
321
+ }
322
+
323
+ /**
324
+ * @param string $search_term
325
+ *
326
+ * @return string
327
+ */
328
+ public function get_plugin_url() {
329
+ if ( null === $this->plugin_url ) {
330
+ $this->set_plugin_url( add_query_arg( array(
331
+ 'tab' => 'search',
332
+ 'type' => 'term',
333
+ 's' => $this->get_title(),
334
+ ), admin_url( 'plugin-install.php' ) ) );
335
+ }
336
+
337
+ return $this->plugin_url;
338
+ }
339
+
340
+ /**
341
+ * Show notice on admin page only
342
+ *
343
+ * @return bool
344
+ */
345
+ public function show_missing_notice_on_current_page() {
346
+ return AC()->admin()->is_admin_screen() || AC()->table_screen()->get_current_list_screen();
347
+ }
348
+
349
+ }
classes/Addon/ACF.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addon_ACF extends AC_Addon {
8
+
9
+ public function __construct() {
10
+ parent::__construct( 'cac-addon-acf' );
11
+
12
+ $this
13
+ ->set_title( __( 'Advanced Custom Fields', 'codepress-admin-columns' ) )
14
+ ->set_logo( AC()->get_plugin_url() . 'assets/images/addons/acf.png' )
15
+ ->set_icon( $this->get_logo() )
16
+ ->set_link( ac_get_site_utm_url( 'advanced-custom-fields-columns', 'addon', 'acf' ) )
17
+ ->set_description( $this->get_fields_description( $this->get_title() ) )
18
+ ->add_plugin( 'advanced-custom-fields' )
19
+ ->add_plugin( 'advanced-custom-fields-pro' );
20
+ }
21
+
22
+ public function display_promo() {
23
+ echo $this->get_title() . ' ';
24
+ $this->display_icon();
25
+ }
26
+
27
+ public function get_plugin() {
28
+ foreach ( $this->get_plugins() as $plugin ) {
29
+ if ( $plugin->is_installed() ) {
30
+ return $plugin;
31
+ }
32
+ }
33
+
34
+ return parent::get_plugin();
35
+ }
36
+
37
+ public function is_plugin_active() {
38
+ return class_exists( 'acf', false );
39
+ }
40
+
41
+ public function show_missing_notice_on_current_page() {
42
+ global $pagenow;
43
+
44
+ $is_acf_page = 'edit.php' === $pagenow && 'acf-field-group' === filter_input( INPUT_GET, 'post_type' );
45
+
46
+ return parent::show_missing_notice_on_current_page() || $is_acf_page;
47
+ }
48
+
49
+ }
classes/Addon/Pods.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addon_Pods extends AC_Addon {
8
+
9
+ public function __construct() {
10
+ parent::__construct( 'ac-addon-pods' );
11
+
12
+ $this
13
+ ->set_title( __( 'Pods', 'codepress-admin-columns' ) )
14
+ ->set_logo( AC()->get_plugin_url() . 'assets/images/addons/pods.png' )
15
+ ->set_icon( AC()->get_plugin_url() . 'assets/images/addons/pods-icon.png' )
16
+ ->set_link( ac_get_site_utm_url( 'pods-columns', 'addon', 'pods' ) )
17
+ ->set_description( $this->get_fields_description( $this->get_title() ) )
18
+ ->add_plugin( 'pods' );
19
+ }
20
+
21
+ public function show_missing_notice_on_current_page() {
22
+ global $pagenow;
23
+
24
+ $is_page = 'admin.php' === $pagenow && in_array( filter_input( INPUT_GET, 'page' ), array( 'pods-add-new', 'pods-settings' ) );
25
+
26
+ return parent::show_missing_notice_on_current_page() || $is_page;
27
+ }
28
+
29
+ public function is_plugin_active() {
30
+ return function_exists( 'pods' );
31
+ }
32
+
33
+ }
classes/Addon/Types.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addon_Types extends AC_Addon {
8
+
9
+ public function __construct() {
10
+ parent::__construct( 'ac-addon-types' );
11
+
12
+ $this
13
+ ->set_title( __( 'Toolset Types', 'codepress-admin-columns' ) )
14
+ ->set_logo( AC()->get_plugin_url() . 'assets/images/addons/toolset-types.png' )
15
+ ->set_icon( AC()->get_plugin_url() . 'assets/images/addons/toolset-types-icon.png' )
16
+ ->set_link( ac_get_site_utm_url( 'toolset-types-columns', 'addon', 'types' ) )
17
+ ->set_description( $this->get_fields_description( $this->get_title() ) )
18
+ ->add_plugin( 'types' );
19
+ }
20
+
21
+ public function show_missing_notice_on_current_page() {
22
+ global $pagenow;
23
+
24
+ $is_page = 'admin.php' === $pagenow && in_array( filter_input( INPUT_GET, 'page' ), array( 'toolset-dashboard', 'wpcf-cpt', 'wpcf-cf', 'toolset-settings' ) );
25
+
26
+ return parent::show_missing_notice_on_current_page() || $is_page;
27
+ }
28
+
29
+ public function is_plugin_active() {
30
+ return class_exists( 'Types_Main', false );
31
+ }
32
+
33
+ }
classes/Addon/WooCommerce.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addon_WooCommerce extends AC_Addon {
8
+
9
+ public function __construct() {
10
+ parent::__construct( 'cac-addon-woocommerce' );
11
+
12
+ $this
13
+ ->set_title( __( 'WooCommerce', 'codepress-admin-columns' ) )
14
+ ->set_description( __( 'Enhance the products, orders and coupons overviews with new columns and inline editing.', 'codepress-admin-columns' ) )
15
+ ->set_logo( AC()->get_plugin_url() . 'assets/images/addons/woocommerce.png' )
16
+ ->set_icon( $this->get_logo() )
17
+ ->set_link( ac_get_site_utm_url( 'woocommerce-columns', 'addon', 'woocommerce' ) )
18
+ ->add_plugin( 'woocommerce' );
19
+ }
20
+
21
+ public function get_placeholder_column() {
22
+ $column = new AC_Column_WooCommercePlaceholder();
23
+ $column->set_addon( $this );
24
+
25
+ return $column;
26
+ }
27
+
28
+ public function is_plugin_active() {
29
+ return class_exists( 'WooCommerce', false );
30
+ }
31
+
32
+ }
classes/Addons.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Addons {
8
+
9
+ /**
10
+ * @var AC_Addon[]
11
+ */
12
+ private $addons;
13
+
14
+ /**
15
+ * @return AC_Addon[]
16
+ */
17
+ public function get_addons() {
18
+ if ( null === $this->addons ) {
19
+ $this->set_addons();
20
+ }
21
+
22
+ return $this->addons;
23
+ }
24
+
25
+ /**
26
+ * @return AC_Addon[]
27
+ */
28
+ public function get_active_promo() {
29
+ $addons = $this->get_addons();
30
+
31
+ foreach ( $addons as $k => $addon ) {
32
+ if ( ! $addon->is_plugin_active() || $addon->is_active() ) {
33
+ unset( $addons[ $k ] );
34
+ }
35
+ }
36
+
37
+ return $addons;
38
+ }
39
+
40
+ /**
41
+ * All addons where 3d party is installed but integration is not installed
42
+ *
43
+ * @return AC_Addon[]
44
+ */
45
+ public function get_missing_addons() {
46
+ $missing = array();
47
+
48
+ foreach ( $this->get_addons() as $k => $addon ) {
49
+ if ( $addon->is_plugin_active() && ! $addon->is_active() ) {
50
+ $missing[] = $addon;
51
+ }
52
+ }
53
+
54
+ return $missing;
55
+ }
56
+
57
+ /**
58
+ * @return AC_addon[]
59
+ */
60
+ public function get_active_addons() {
61
+ $addons = array();
62
+
63
+ foreach ( $this->get_addons() as $addon ) {
64
+ if ( $addon->is_active() ) {
65
+ $addons[] = $addon;
66
+ }
67
+ }
68
+
69
+ return $addons;
70
+ }
71
+
72
+ /**
73
+ * Get add-on details from the available add-ons list
74
+ *
75
+ * @since 2.2
76
+ *
77
+ * @param string $slug Addon slug
78
+ *
79
+ * @return AC_Addon|false Returns addon details if the add-on exists, false otherwise
80
+ */
81
+ public function get_addon( $slug ) {
82
+ foreach ( $this->get_addons() as $addon ) {
83
+ if ( $slug === $addon->get_slug() ) {
84
+ return $addon;
85
+ }
86
+ }
87
+
88
+ return false;
89
+ }
90
+
91
+ /**
92
+ * @param AC_Addon $addon
93
+ */
94
+ public function register_addon( AC_Addon $addon ) {
95
+ $this->addons[] = $addon;
96
+ }
97
+
98
+ /**
99
+ * Register addon
100
+ */
101
+ private function set_addons() {
102
+ $classes = AC()->autoloader()->get_class_names_from_dir( AC()->get_plugin_dir() . 'classes/Addon', 'AC_' );
103
+
104
+ foreach ( $classes as $class ) {
105
+ $this->register_addon( new $class );
106
+ }
107
+ }
108
+
109
+ }
classes/Admin.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Admin {
11
+
12
+ const MENU_SLUG = 'codepress-admin-columns';
13
+
14
+ /**
15
+ * Settings Page hook suffix
16
+ *
17
+ * @since 2.0
18
+ */
19
+ private $hook_suffix;
20
+
21
+ /**
22
+ * @var AC_Admin_Pages
23
+ */
24
+ private $pages;
25
+
26
+ /**
27
+ * @since 2.0
28
+ */
29
+ public function __construct() {
30
+ add_action( 'init', array( $this, 'set_pages' ) );
31
+ add_action( 'admin_menu', array( $this, 'settings_menu' ) );
32
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
33
+ }
34
+
35
+ /**
36
+ * Load pages
37
+ */
38
+ public function set_pages() {
39
+ $this->pages = new AC_Admin_Pages();
40
+
41
+ $this->pages
42
+ ->register_page( new AC_Admin_Page_Columns() )
43
+ ->register_page( new AC_Admin_Page_Settings() )
44
+ ->register_page( new AC_Admin_Page_Addons() )
45
+ ->register_page( new AC_Admin_Page_Help() )
46
+ // Hidden
47
+ ->register_page( new AC_Admin_Page_Welcome() )
48
+ ->register_page( new AC_Admin_Page_Upgrade() );
49
+
50
+ do_action( 'ac/admin_pages', $this->pages );
51
+ }
52
+
53
+ /**
54
+ * @return AC_Admin_Pages|false
55
+ */
56
+ public function get_pages() {
57
+ return $this->pages;
58
+ }
59
+
60
+ /**
61
+ * Admin scripts for this tab
62
+ */
63
+ public function admin_scripts() {
64
+ if ( ! $this->is_admin_screen() ) {
65
+ return;
66
+ }
67
+
68
+ wp_enqueue_script( 'ac-admin-general', AC()->get_plugin_url() . "assets/js/admin-general" . AC()->minified() . ".js", array( 'jquery', 'wp-pointer' ), AC()->get_version() );
69
+ wp_enqueue_style( 'wp-pointer' );
70
+ wp_enqueue_style( 'ac-admin', AC()->get_plugin_url() . "assets/css/admin-general" . AC()->minified() . ".css", array(), AC()->get_version() );
71
+
72
+ do_action( 'ac/admin_scripts', $this );
73
+ }
74
+
75
+ /**
76
+ * @param $option
77
+ *
78
+ * @return bool
79
+ */
80
+ public function get_general_option( $option ) {
81
+ /* @var AC_Admin_Page_Settings $settings */
82
+ $settings = $this->get_pages()->get_page( 'settings' );
83
+
84
+ return $settings->get_option( $option );
85
+ }
86
+
87
+ /**
88
+ * @param $tab_slug
89
+ *
90
+ * @return AC_Admin_Page_Columns|AC_Admin_Page_Settings|AC_Admin_Page_Addons|false
91
+ */
92
+ public function get_page( $tab_slug ) {
93
+ return $this->get_pages()->get_page( $tab_slug );
94
+ }
95
+
96
+ /**
97
+ * @param string $tab_slug
98
+ *
99
+ * @return false|string URL
100
+ */
101
+ public function get_link( $tab_slug ) {
102
+ return $this->get_pages()->get_page( $tab_slug )->get_link();
103
+ }
104
+
105
+ /**
106
+ * @since 3.1.1
107
+ */
108
+ public function get_hook_suffix() {
109
+ return $this->hook_suffix;
110
+ }
111
+
112
+ /**
113
+ * @return string
114
+ */
115
+ private function get_parent_slug() {
116
+ return 'options-general.php';
117
+ }
118
+
119
+ /**
120
+ * @return string
121
+ */
122
+ public function get_settings_url() {
123
+ return add_query_arg( array( 'page' => self::MENU_SLUG ), admin_url( $this->get_parent_slug() ) );
124
+ }
125
+
126
+ /**
127
+ * @since 1.0
128
+ */
129
+ public function settings_menu() {
130
+ $this->hook_suffix = add_submenu_page( $this->get_parent_slug(), __( 'Admin Columns Settings', 'codepress-admin-columns' ), __( 'Admin Columns', 'codepress-admin-columns' ), 'manage_admin_columns', self::MENU_SLUG, array( $this, 'display' ) );
131
+
132
+ add_action( 'load-' . $this->hook_suffix, array( $this, 'load_help_tabs' ) );
133
+ }
134
+
135
+ /**
136
+ * Load help tabs
137
+ */
138
+ public function load_help_tabs() {
139
+ new AC_Admin_Help_Introduction();
140
+ new AC_Admin_Help_Basics();
141
+ new AC_Admin_Help_CustomField();
142
+ }
143
+
144
+ /**
145
+ * @return bool
146
+ */
147
+ public function is_admin_screen() {
148
+ global $pagenow;
149
+
150
+ return self::MENU_SLUG === filter_input( INPUT_GET, 'page' ) && $this->get_parent_slug() === $pagenow;
151
+ }
152
+
153
+ /**
154
+ * @param string $slug
155
+ *
156
+ * @return bool
157
+ */
158
+ public function is_current_page( $slug ) {
159
+ $current_tab = $this->get_pages()->get_current_page();
160
+
161
+ return $current_tab && $current_tab->get_slug() === $slug && $this->is_admin_screen();
162
+ }
163
+
164
+ /**
165
+ * @since 1.0
166
+ */
167
+ public function display() {
168
+ $this->get_pages()->display();
169
+ }
170
+
171
+ }
classes/Admin/Help.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Admin_Help {
8
+
9
+ abstract public function get_title();
10
+
11
+ abstract public function get_content();
12
+
13
+ public function __construct() {
14
+ $this->register_tab();
15
+ }
16
+
17
+ /**
18
+ * @return string Based on class name
19
+ */
20
+ public function get_id() {
21
+ $parts = explode( '_', get_class( $this ) );
22
+
23
+ return sanitize_key( strtolower( end( $parts ) ) );
24
+ }
25
+
26
+ /**
27
+ * Register tabs on current screen
28
+ */
29
+ public function register_tab() {
30
+ $wp_screen = get_current_screen();
31
+
32
+ if ( ! $wp_screen ) {
33
+ return;
34
+ }
35
+
36
+ $wp_screen->add_help_tab( array(
37
+ 'id' => 'ac-tab-' . $this->get_id(),
38
+ 'title' => $this->get_title(),
39
+ 'content' => $this->get_content(),
40
+ ) );
41
+ }
42
+
43
+ }
classes/Admin/Help/Basics.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Help_Basics extends AC_Admin_Help {
8
+
9
+ public function get_title() {
10
+ return __( "Basics", 'codepress-admin-columns' );
11
+ }
12
+
13
+ public function get_content() {
14
+ ob_start();
15
+ ?>
16
+
17
+ <h5><?php _e( "Change order", 'codepress-admin-columns' ); ?></h5>
18
+ <p>
19
+ <?php _e( "By dragging the columns you can change the order which they will appear in.", 'codepress-admin-columns' ); ?>
20
+ </p>
21
+
22
+ <h5><?php _e( "Change label", 'codepress-admin-columns' ); ?></h5>
23
+ <p>
24
+ <?php _e( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'codepress-admin-columns' ); ?>
25
+ </p>
26
+
27
+ <h5><?php _e( "Change column width", 'codepress-admin-columns' ); ?></h5>
28
+ <p>
29
+ <?php _e( "By clicking on the triangle you will see the column options. By using the draggable slider you can set the width of the columns in percentages.", 'codepress-admin-columns' ); ?>
30
+ </p>
31
+
32
+ <?php
33
+
34
+ return ob_get_clean();
35
+ }
36
+
37
+ }
classes/Admin/Help/CustomField.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Help_CustomField extends AC_Admin_Help {
8
+
9
+ public function get_title() {
10
+ return __( "Custom Field", 'codepress-admin-columns' );
11
+ }
12
+
13
+ public function get_content() {
14
+ ob_start();
15
+ ?>
16
+
17
+ <p>
18
+ <?php _e( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'codepress-admin-columns' ); ?>
19
+ </p>
20
+ <ul>
21
+ <li>
22
+ <strong><?php _e( "Default", 'codepress-admin-columns' ); ?></strong><br/>
23
+ <?php _e( "Value: Can be either a string or array. Arrays will be flattened and values are seperated by a ',' comma.", 'codepress-admin-columns' ); ?>
24
+ </li>
25
+ <li>
26
+ <strong><?php _e( "Checkmark", 'codepress-admin-columns' ); ?></strong><br/>
27
+ <?php _e( "Value: should be a 1 (one) or 0 (zero).", 'codepress-admin-columns' ); ?>
28
+ </li>
29
+ <li>
30
+ <strong><?php _e( "Color", 'codepress-admin-columns' ); ?></strong><br/>
31
+ <?php _e( "Value: hex value color, such as #808080.", 'codepress-admin-columns' ); ?>
32
+ </li>
33
+ <li>
34
+ <strong><?php _e( "Counter", 'codepress-admin-columns' ); ?></strong><br/>
35
+ <?php _e( "Value: Can be either a string or array. This will display a count of the number of times the meta key is used by the item.", 'codepress-admin-columns' ); ?>
36
+ </li>
37
+ <li>
38
+ <strong><?php _e( "Date", 'codepress-admin-columns' ); ?></strong><br/>
39
+ <?php printf( __( "Value: Can be unix time stamp or a date format as described in the <a href='%s'>Codex</a>. You can change the outputted date format at the <a href='%s'>general settings</a> page.", 'codepress-admin-columns' ), 'http://codex.wordpress.org/Formatting_Date_and_Time', admin_url( 'options-general.php' ) ); ?>
40
+ </li>
41
+ <li>
42
+ <strong><?php _e( "Excerpt", 'codepress-admin-columns' ); ?></strong><br/>
43
+ <?php _e( "Value: This will show the first 20 words of the Post content.", 'codepress-admin-columns' ); ?>
44
+ </li>
45
+ <li>
46
+ <strong><?php _e( "Image", 'codepress-admin-columns' ); ?></strong><br/>
47
+ <?php _e( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'codepress-admin-columns' ); ?>
48
+ </li>
49
+ <li>
50
+ <strong><?php _e( "Media Library", 'codepress-admin-columns' ); ?></strong><br/>
51
+ <?php _e( "Value: should contain Attachment IDs ( seperated by a ',' comma ).", 'codepress-admin-columns' ); ?>
52
+ </li>
53
+ <li>
54
+ <strong><?php _e( "Multiple Values", 'codepress-admin-columns' ); ?></strong><br/>
55
+ <?php _e( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'codepress-admin-columns' ); ?>
56
+ </li>
57
+ <li>
58
+ <strong><?php _e( "Numeric", 'codepress-admin-columns' ); ?></strong><br/>
59
+ <?php _e( "Value: Integers only.<br/>If you have the 'sorting addon' this will be used for sorting, so you can sort your posts on numeric (custom field) values.", 'codepress-admin-columns' ); ?>
60
+ </li>
61
+ <li>
62
+ <strong><?php _e( "Post Titles", 'codepress-admin-columns' ); ?></strong><br/>
63
+ <?php _e( "Value: can be one or more Post ID's (seperated by ',').", 'codepress-admin-columns' ); ?>
64
+ </li>
65
+ <li>
66
+ <strong><?php _e( "Usernames", 'codepress-admin-columns' ); ?></strong><br/>
67
+ <?php _e( "Value: can be one or more User ID's (seperated by ',').", 'codepress-admin-columns' ); ?>
68
+ </li>
69
+ </ul>
70
+
71
+ <?php
72
+
73
+ return ob_get_clean();
74
+ }
75
+
76
+ }
classes/Admin/Help/Introduction.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Help_Introduction extends AC_Admin_Help {
8
+
9
+ public function get_title() {
10
+ return __( "Overview", 'codepress-admin-columns' );
11
+ }
12
+
13
+ public function get_content() {
14
+ ob_start();
15
+ ?>
16
+
17
+ <p>
18
+ <?php _e( "This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.", 'codepress-admin-columns' ); ?>
19
+ </p>
20
+
21
+ <?php
22
+
23
+ return ob_get_clean();
24
+ }
25
+
26
+ }
classes/Admin/Page.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Admin_Page {
8
+
9
+ /**
10
+ * Should this page be displayed when no page is selected
11
+ *
12
+ * @var bool
13
+ */
14
+ private $default;
15
+
16
+ /**
17
+ * @var string
18
+ */
19
+ private $slug;
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ private $label;
25
+
26
+ /**
27
+ * @var bool False when menu page is hidden in menu
28
+ */
29
+ private $show_in_menu = true;
30
+
31
+ /**
32
+ * Display pages
33
+ *
34
+ * @return void
35
+ */
36
+ public abstract function display();
37
+
38
+ /**
39
+ * Is this the default to to display when no active page is present
40
+ *
41
+ * @return bool
42
+ */
43
+ public function is_default() {
44
+ return (bool) $this->default;
45
+ }
46
+
47
+ public function set_default( $default ) {
48
+ $this->default = (bool) $default;
49
+
50
+ return $this;
51
+ }
52
+
53
+ public function get_slug() {
54
+ return $this->slug;
55
+ }
56
+
57
+ public function set_slug( $slug ) {
58
+ $this->slug = sanitize_key( $slug );
59
+
60
+ return $this;
61
+ }
62
+
63
+ public function show_in_menu() {
64
+ return $this->show_in_menu;
65
+ }
66
+
67
+ public function set_show_in_menu( $show ) {
68
+ $this->show_in_menu = (bool) $show;
69
+
70
+ return $this;
71
+ }
72
+
73
+ public function get_label() {
74
+ return $this->label;
75
+ }
76
+
77
+ public function set_label( $label ) {
78
+ $this->label = $label;
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * @return string URL
85
+ */
86
+ public function get_link() {
87
+ return add_query_arg( array( 'tab' => $this->slug ), AC()->admin()->get_settings_url() );
88
+ }
89
+
90
+ public function is_current_screen() {
91
+ return AC()->admin()->is_current_page( $this->get_slug() );
92
+ }
93
+
94
+ /**
95
+ * Cast page to an array
96
+ *
97
+ * @return array
98
+ */
99
+ public function to_array() {
100
+ return array(
101
+ 'slug' => $this->get_slug(),
102
+ 'label' => $this->get_label(),
103
+ 'default' => $this->is_default(),
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Show the label of the page
109
+ *
110
+ * @return string
111
+ */
112
+ public function __toString() {
113
+ return $this->get_label();
114
+ }
115
+
116
+ /**
117
+ * @param string $action
118
+ *
119
+ * @return bool
120
+ */
121
+ public function verify_nonce( $action ) {
122
+ return wp_verify_nonce( filter_input( INPUT_POST, '_ac_nonce' ), $action );
123
+ }
124
+
125
+ /**
126
+ * Nonce Field
127
+ */
128
+ public function nonce_field( $action ) {
129
+ wp_nonce_field( $action, '_ac_nonce', false );
130
+ }
131
+
132
+ }
classes/Admin/Page/Addons.php ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Page_Addons extends AC_Admin_Page {
8
+
9
+ /**
10
+ * User meta key for hiding "Install addons" notice
11
+ *
12
+ * @since 2.4.9
13
+ */
14
+ const OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY = 'cpac-hide-install-addons-notice';
15
+
16
+ public function __construct() {
17
+ $this
18
+ ->set_slug( 'addons' )
19
+ ->set_label( __( 'Add-ons', 'codepress-admin-columns' ) );
20
+
21
+ add_action( 'admin_init', array( $this, 'handle_request' ) );
22
+ add_filter( 'wp_redirect', array( $this, 'redirect_after_status_change' ) );
23
+ add_action( 'admin_init', array( $this, 'handle_install_request' ) );
24
+ add_action( 'admin_init', array( $this, 'show_missing_plugin_notice' ) );
25
+ add_action( 'admin_notices', array( $this, 'missing_addon_notices' ) );
26
+ add_action( 'wp_ajax_cpac_hide_install_addons_notice', array( $this, 'ajax_hide_install_addons_notice' ) );
27
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
28
+ }
29
+
30
+ public function show_missing_plugin_notice() {
31
+ if ( ! $this->is_current_screen() ) {
32
+ return;
33
+ }
34
+
35
+ if ( ! current_user_can( 'manage_admin_columns' ) ) {
36
+ return;
37
+ }
38
+
39
+ if ( ! current_user_can( 'install_plugins' ) ) {
40
+ return;
41
+ }
42
+
43
+ $addons = AC()->addons()->get_active_addons();
44
+
45
+ if ( ! $addons ) {
46
+ return;
47
+ }
48
+
49
+ foreach ( $addons as $addon ) {
50
+
51
+ // is_plugin_installed does not work when plugins are included in a theme, that's why we check is_plugin_active
52
+ if ( ! $addon->is_plugin_installed() && ! $addon->is_plugin_active() ) {
53
+ AC()->notice( sprintf( __( '%s plugin needs to be installed for the add-on to work.', 'codepress-admin-columns' ), ac_helper()->html->link( $addon->get_plugin_url(), $addon->get_title(), array( 'target' => '_blank' ) ) ), 'notice-warning' );
54
+ } else if ( ! $addon->is_plugin_active() ) {
55
+ $message = sprintf( __( '%s plugin is installed, but not active.', 'codepress-admin-columns' ), '<strong>' . $addon->get_plugin()->get_plugin_var( 'Name' ) . '</strong>' );
56
+
57
+ if ( current_user_can( 'activate_plugins' ) ) {
58
+ $message .= ' ' . sprintf( __( 'Click %s to activate the plugin.', 'codepress-admin-columns' ), ac_helper()->html->link( $addon->get_plugin_activation_url(), __( 'here', 'codepress-admin=n-columns' ) ) );
59
+ }
60
+
61
+ AC()->notice( $message, 'notice-warning' );
62
+ }
63
+ }
64
+
65
+ $titles = array();
66
+ foreach ( $addons as $addon ) {
67
+ $titles[] = '<strong>' . esc_html( $addon->get_title() ) . '</strong>';
68
+ }
69
+
70
+ if ( ! ac_is_pro_active() ) {
71
+ AC()->notice( sprintf( _n( '%s add-on requires %s.', '%s add-ons requires %s.', count( $titles ), 'codepress-admin-columns' ), ac_helper()->string->enumeration_list( $titles, 'and' ), ac_helper()->html->link( ac_get_site_url(), __( 'Admin Columns Pro', 'codepress-admin-columns' ), array( 'target' => '_blank' ) ) ), 'notice-warning' );
72
+ }
73
+
74
+ }
75
+
76
+ /**
77
+ * Display an activation/deactivation message on the addons page if applicable
78
+ *
79
+ * @since 2.2
80
+ */
81
+ public function handle_request() {
82
+ if ( ! $this->is_current_screen() ) {
83
+ return;
84
+ }
85
+
86
+ $basename = filter_input( INPUT_GET, 'plugin' );
87
+
88
+ if ( ! $basename ) {
89
+ return;
90
+ }
91
+
92
+ $status = filter_input( INPUT_GET, 'status' );
93
+
94
+ if ( ! $status ) {
95
+ return;
96
+ }
97
+
98
+ if ( ! wp_verify_nonce( filter_input( INPUT_GET, '_ac_nonce' ), 'ac-plugin-status-change' ) ) {
99
+ return;
100
+ }
101
+
102
+ $plugin = new AC_PluginInformation( dirname( $basename ) );
103
+
104
+ $activate_string = __( '%s plugin successfully activated.', 'codepress-admin-columns' );
105
+ $deactivate_string = __( '%s plugin successfully deactivated.', 'codepress-admin-columns' );
106
+
107
+ // Is plugin an addon?
108
+ foreach ( AC()->addons()->get_addons() as $addon ) {
109
+ if ( $addon->get_basename() === $plugin->get_basename() ) {
110
+ $activate_string = __( '%s successfully activated.', 'codepress-admin-columns' );
111
+ $deactivate_string = __( '%s successfully deactivated.', 'codepress-admin-columns' );
112
+ }
113
+ }
114
+
115
+ switch ( $status ) {
116
+ case 'activate' :
117
+ if ( $plugin->is_active() ) {
118
+ AC()->notice( sprintf( $activate_string, '<strong>' . $plugin->get_name() . '</strong>' ) );
119
+ } else {
120
+ AC()->notice( sprintf( __( '%s could not be activated.', 'codepress-admin-columns' ), '<strong>' . $plugin->get_name() . '</strong>' ) . ' ' . sprintf( 'Please visit the %s page.', ac_helper()->html->link( admin_url( 'plugins.php' ), strtolower( __( 'Plugins' ) ) ) ), 'error' );
121
+ }
122
+ break;
123
+ case 'deactivate' :
124
+ AC()->notice( sprintf( $deactivate_string, '<strong>' . $plugin->get_name() . '</strong>' ) );
125
+ break;
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Admin scripts
131
+ */
132
+ public function admin_scripts() {
133
+ if ( $this->is_current_screen() ) {
134
+ wp_enqueue_style( 'ac-admin-page-addons', AC()->get_plugin_url() . 'assets/css/admin-page-addons' . AC()->minified() . '.css', array(), AC()->get_version() );
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Possibly adds an admin notice when a third party plugin supported by an addon is installed, but the addon isn't
140
+ *
141
+ * @since 2.4.9
142
+ */
143
+ public function missing_addon_notices() {
144
+ if ( ! current_user_can( 'manage_admin_columns' ) ) {
145
+ return;
146
+ }
147
+
148
+ if ( ! current_user_can( 'install_plugins' ) ) {
149
+ return;
150
+ }
151
+
152
+ if ( $this->is_current_screen() ) {
153
+ return;
154
+ }
155
+
156
+ if ( AC()->suppress_site_wide_notices() ) {
157
+ return;
158
+ }
159
+
160
+ if ( ac_helper()->user->get_meta_site( self::OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY, true ) ) {
161
+ return;
162
+ }
163
+
164
+ $plugins = array();
165
+
166
+ foreach ( AC()->addons()->get_addons() as $addon ) {
167
+ if ( $addon->show_missing_notice_on_current_page() && $addon->is_plugin_active() && ! $addon->is_active() ) {
168
+ $plugins[] = $addon->get_title();
169
+ }
170
+ }
171
+
172
+ if ( $plugins ) {
173
+ foreach ( $plugins as $index => $plugin ) {
174
+ $plugins[ $index ] = '<strong>' . $plugin . '</strong>';
175
+ }
176
+
177
+ $plugins_list = ac_helper()->string->enumeration_list( $plugins, 'and' );
178
+
179
+ ?>
180
+ <div class="ac-message updated">
181
+ <a href="#" class="hide-notice hide-install-addons-notice"></a>
182
+
183
+ <p><?php printf( __( "Did you know Admin Columns Pro has an integration addon for %s? With the proper Admin Columns Pro license, you can download them from %s!", 'codepress-admin-columns' ), $plugins_list, ac_helper()->html->link( $this->get_link(), __( 'the addons page', 'codepress-admin-columns' ) ) ); ?>
184
+ </div>
185
+ <?php
186
+
187
+ wp_enqueue_script( 'ac-sitewide-notices' );
188
+ wp_enqueue_style( 'ac-sitewide-notices' );
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Ajax callback for hiding the "Missing addons" notice used for notifying users of available integration addons for plugins they have installed
194
+ *
195
+ * @since 2.4.9
196
+ */
197
+ public function ajax_hide_install_addons_notice() {
198
+ ac_helper()->user->update_meta_site( self::OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY, '1', true );
199
+ }
200
+
201
+ /**
202
+ * Handles the installation of the add-on
203
+ *
204
+ * @since 2.2
205
+ */
206
+ public function handle_install_request() {
207
+ if ( ! wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), 'install-ac-addon' ) ) {
208
+ return;
209
+ }
210
+
211
+ $addon = AC()->addons()->get_addon( filter_input( INPUT_GET, 'plugin' ) );
212
+
213
+ if ( ! $addon ) {
214
+ AC()->notice( __( 'Addon does not exist.', 'codepress-admin-columns' ), 'error' );
215
+
216
+ return;
217
+ }
218
+
219
+ if ( ! ac_is_pro_active() ) {
220
+ AC()->notice( __( 'You need Admin Columns Pro.', 'codepress-admin-columns' ), 'error' );
221
+
222
+ return;
223
+ }
224
+
225
+ // Hook: trigger possible warning message before running WP installer ( api errors etc. )
226
+ if ( $error = apply_filters( 'ac/addons/install_request/maybe_error', false, $_GET['plugin'] ) ) {
227
+ AC()->notice( $error, 'error' );
228
+
229
+ return;
230
+ }
231
+
232
+ $install_url = add_query_arg( array(
233
+ 'action' => 'install-plugin',
234
+ 'plugin' => $addon->get_slug(),
235
+ 'ac-redirect' => true,
236
+ ), wp_nonce_url( network_admin_url( 'update.php' ), 'install-plugin_' . $addon->get_slug() ) );
237
+
238
+ wp_redirect( $install_url );
239
+ exit;
240
+ }
241
+
242
+ /**
243
+ * Redirect the user to the Admin Columns add-ons page after activation/deactivation of an add-on from the add-ons page
244
+ *
245
+ * @since 2.2
246
+ */
247
+ public function redirect_after_status_change( $location ) {
248
+ global $pagenow;
249
+
250
+ if ( 'plugins.php' !== $pagenow || ! is_admin() || ! filter_input( INPUT_GET, 'ac-redirect' ) || filter_input( INPUT_GET, 'error' ) ) {
251
+ return $location;
252
+ }
253
+
254
+ $status = filter_input( INPUT_GET, 'action' );
255
+
256
+ if ( ! $status ) {
257
+ return $location;
258
+ }
259
+
260
+ $addon = false;
261
+
262
+ // Check if either the addon is installed or it's plugin
263
+ foreach ( AC()->addons()->get_addons() as $_addon ) {
264
+ if ( in_array( filter_input( INPUT_GET, 'plugin' ), array( $_addon->get_basename(), $_addon->get_plugin_basename() ) ) ) {
265
+ $addon = $_addon;
266
+ }
267
+ }
268
+
269
+ if ( ! $addon ) {
270
+ return $location;
271
+ }
272
+
273
+ $location = add_query_arg( array(
274
+ 'status' => $status,
275
+ 'plugin' => filter_input( INPUT_GET, 'plugin' ),
276
+ '_ac_nonce' => wp_create_nonce( 'ac-plugin-status-change' ),
277
+ ), $this->get_link() );
278
+
279
+ return $location;
280
+ }
281
+
282
+ /**
283
+ * Addons are grouped into addon groups by providing the group an addon belongs to.
284
+ *
285
+ * @since 2.2
286
+ *
287
+ * @return array Available addon groups ([group_name] => [label])
288
+ */
289
+ public function get_addon_groups() {
290
+ $addon_groups = array(
291
+ 'installed' => __( 'Installed', 'codepress-admin-columns' ),
292
+ 'recommended' => __( 'Recommended', 'codepress-admin-columns' ),
293
+ 'default' => __( 'Available', 'codepress-admin-columns' ),
294
+ );
295
+
296
+ /**
297
+ * Filter the addon groups
298
+ *
299
+ * @since 2.2
300
+ *
301
+ * @param array $addon_groups Available addon groups ([group_name] => [label])
302
+ */
303
+ return apply_filters( 'ac/addons/groups', $addon_groups );
304
+ }
305
+
306
+ /**
307
+ * @param string $name
308
+ *
309
+ * @return string|false
310
+ */
311
+ public function get_group( $name ) {
312
+ $groups = $this->get_addon_groups();
313
+
314
+ if ( ! isset( $groups ) ) {
315
+ return false;
316
+ }
317
+
318
+ return $groups[ $name ];
319
+ }
320
+
321
+ /**
322
+ * Group a list of add-ons
323
+ *
324
+ * @since 3.0
325
+ *
326
+ * @return array A list of addons per group: [group_name] => (array) [group_addons], where [group_addons] is an array ([addon_name] => (array) [addon_details])
327
+ */
328
+ private function get_grouped_addons() {
329
+ $active = array();
330
+ $inactive = array();
331
+
332
+ foreach ( AC()->addons()->get_addons() as $addon ) {
333
+ if ( $addon->is_active() ) {
334
+ $active[] = $addon;
335
+ } else {
336
+ $inactive[] = $addon;
337
+ }
338
+ }
339
+
340
+ /* @var AC_Addon[] $sorted */
341
+ $sorted = array_merge( $active, $inactive );
342
+
343
+ $grouped = array();
344
+ foreach ( $this->get_addon_groups() as $group => $label ) {
345
+ foreach ( $sorted as $addon ) {
346
+ $addon_group = 'default';
347
+
348
+ if ( $addon->is_plugin_active() ) {
349
+ $addon_group = 'recommended';
350
+ }
351
+
352
+ if ( $addon->is_installed() ) {
353
+ $addon_group = 'installed';
354
+ }
355
+
356
+ if ( ! isset( $grouped[ $group ] ) ) {
357
+ $grouped[ $group ]['title'] = $label;
358
+ }
359
+
360
+ if ( $addon_group === $group ) {
361
+ $grouped[ $group ]['addons'][] = $addon;
362
+ }
363
+ }
364
+
365
+ if ( empty( $grouped[ $group ]['addons'] ) ) {
366
+ unset( $grouped[ $group ] );
367
+ }
368
+ }
369
+
370
+ return $grouped;
371
+ }
372
+
373
+ public function display() {
374
+
375
+ foreach ( $this->get_grouped_addons() as $group_slug => $group ) : ?>
376
+ <div class="ac-addon group-<?php echo esc_attr( $group_slug ); ?>">
377
+ <h2><?php echo esc_html( $group['title'] ); ?></h2>
378
+
379
+ <ul>
380
+ <?php
381
+ foreach ( $group['addons'] as $addon ) :
382
+ /* @var AC_Addon $addon */ ?>
383
+ <li class="<?php echo esc_attr( $addon->get_slug() ); ?>">
384
+ <div class="addon-header">
385
+ <div class="inner">
386
+ <?php if ( $addon->get_logo() ) : ?>
387
+ <img src="<?php echo esc_attr( $addon->get_logo() ); ?>"/>
388
+ <?php else : ?>
389
+ <h2><?php echo esc_html( $addon->get_title() ); ?></h2>
390
+ <?php endif; ?>
391
+ </div>
392
+ </div>
393
+ <div class="addon-content">
394
+ <h3><?php echo esc_html( $addon->get_title() ); ?></h3>
395
+ <p><?php echo esc_html( $addon->get_description() ); ?></p>
396
+ </div>
397
+ <div class="addon-actions">
398
+ <?php
399
+
400
+ // Installed..
401
+ if ( $addon->is_installed() ) :
402
+
403
+ // Active
404
+ if ( $addon->is_active() ) : ?>
405
+ <span class="active"><?php _e( 'Active', 'codepress-admin-columns' ); ?></span>
406
+
407
+ <?php if ( current_user_can( 'activate_plugins' ) ) : ?>
408
+ <a href="<?php echo esc_url( $addon->get_deactivation_url( $addon->get_basename() ) ); ?>" class="button right"><?php _e( 'Deactivate', 'codepress-admin-columns' ); ?></a>
409
+ <?php endif;
410
+ // Installed
411
+ elseif ( current_user_can( 'activate_plugins' ) ) : ?>
412
+ <a href="<?php echo esc_url( $addon->get_activation_url( $addon->get_basename() ) ); ?>" class="button button-primary right"><?php _e( 'Activate', 'codepress-admin-columns' ); ?></a>
413
+ <?php endif;
414
+
415
+ // Not installed...
416
+ else :
417
+ if ( ac_is_pro_active() && current_user_can( 'install_plugins' ) ) : ?>
418
+ <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'install', 'plugin' => $addon->get_slug() ), $this->get_link() ), 'install-ac-addon' ) ); ?>" class="button"><?php esc_html_e( 'Download & Install', 'codepress-admin-columns' ); ?></a>
419
+ <?php else : ?>
420
+ <a target="_blank" href="<?php echo esc_url( $addon->get_link() ); ?>" class="button"><?php esc_html_e( 'Get this add-on', 'codepress-admin-columns' ); ?></a>
421
+ <?php endif;
422
+ endif;
423
+ ?>
424
+ </div>
425
+ </li>
426
+ <?php endforeach; // addons ?>
427
+ </ul>
428
+ </div>
429
+ <?php endforeach; // grouped_addons
430
+ }
431
+
432
+ }
classes/Admin/Page/Columns.php ADDED
@@ -0,0 +1,897 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Page_Columns extends AC_Admin_Page {
8
+
9
+ const OPTION_CURRENT = 'cpac_current_model';
10
+
11
+ /**
12
+ * @var array
13
+ */
14
+ private $notices;
15
+
16
+ /**
17
+ * @var AC_ListScreen
18
+ */
19
+ private $current_list_screen;
20
+
21
+ public function __construct() {
22
+
23
+ $this->set_slug( 'columns' )
24
+ ->set_label( __( 'Admin Columns', 'codepress-admin-columns' ) )
25
+ ->set_default( true );
26
+
27
+ add_action( 'current_screen', array( $this, 'set_current_list_screen' ) );
28
+ add_action( 'admin_init', array( $this, 'handle_request' ) );
29
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
30
+
31
+ // Ajax calls
32
+ add_action( 'wp_ajax_ac_column_select', array( $this, 'ajax_column_select' ) );
33
+ add_action( 'wp_ajax_ac_column_refresh', array( $this, 'ajax_column_refresh' ) );
34
+ add_action( 'wp_ajax_ac_columns_save', array( $this, 'ajax_columns_save' ) );
35
+ }
36
+
37
+ /**
38
+ * Admin scripts
39
+ */
40
+ public function admin_scripts() {
41
+ if ( ! $this->is_current_screen() ) {
42
+ return;
43
+ }
44
+
45
+ $list_screen = $this->get_current_list_screen();
46
+
47
+ if ( ! $list_screen ) {
48
+ return;
49
+ }
50
+
51
+ $minified = AC()->minified();
52
+
53
+ // Width slider
54
+ wp_enqueue_style( 'jquery-ui-lightness', AC()->get_plugin_url() . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), AC()->get_version() );
55
+ wp_enqueue_script( 'jquery-ui-slider' );
56
+
57
+ wp_enqueue_script( 'ac-admin-page-columns', AC()->get_plugin_url() . "assets/js/admin-page-columns{$minified}.js", array(
58
+ 'jquery',
59
+ 'dashboard',
60
+ 'jquery-ui-slider',
61
+ 'jquery-ui-sortable',
62
+ 'wp-pointer',
63
+ ), AC()->get_version() );
64
+
65
+ wp_enqueue_style( 'ac-admin-page-columns-css', AC()->get_plugin_url() . 'assets/css/admin-page-columns' . AC()->minified() . '.css', array(), AC()->get_version() );
66
+
67
+ wp_localize_script( 'ac-admin-page-columns', 'AC', array(
68
+ '_ajax_nonce' => wp_create_nonce( 'ac-settings' ),
69
+ 'list_screen' => $list_screen->get_key(),
70
+ 'layout' => $list_screen->get_layout_id(),
71
+ 'original_columns' => $list_screen->get_original_columns(),
72
+ 'i18n' => array(
73
+ 'clone' => __( '%s column is already present and can not be duplicated.', 'codepress-admin-columns' ),
74
+ 'error' => __( 'Invalid response.', 'codepress-admin-columns' ),
75
+ ),
76
+ ) );
77
+
78
+ do_action( 'ac/settings/scripts' );
79
+ }
80
+
81
+ public function set_layout_preference( $layout ) {
82
+ ac_helper()->user->update_meta_site( self::OPTION_CURRENT . '_layout', $layout );
83
+ }
84
+
85
+ public function get_layout_preference() {
86
+ return ac_helper()->user->get_meta_site( self::OPTION_CURRENT . '_layout', true );
87
+ }
88
+
89
+ private function get_first_list_screen() {
90
+ $list_screens = AC()->get_list_screens();
91
+
92
+ return reset( $list_screens );
93
+ }
94
+
95
+ public function set_current_list_screen() {
96
+ if ( ! AC()->user_can_manage_admin_columns() || ! $this->is_current_screen() ) {
97
+ return;
98
+ }
99
+
100
+ // User selected
101
+ $key = filter_input( INPUT_GET, 'list_screen' );
102
+
103
+ // Preference
104
+ if ( ! $key ) {
105
+ $key = $this->get_list_screen_preference();
106
+ }
107
+
108
+ // First one
109
+ if ( ! $key ) {
110
+ $list_screens = AC()->get_list_screens();
111
+
112
+ reset( $list_screens );
113
+
114
+ $key = key( $list_screens );
115
+ }
116
+
117
+ $list_screen = AC()->get_list_screen( $key );
118
+
119
+ if ( ! $list_screen ) {
120
+ $list_screen = $this->get_first_list_screen();
121
+ }
122
+
123
+ // Load table headers
124
+ if ( ! $list_screen->get_original_columns() ) {
125
+ $this->set_original_table_headers( $list_screen );
126
+ }
127
+
128
+ $this->set_list_screen_preference( $list_screen->get_key() );
129
+
130
+ $this->current_list_screen = $list_screen;
131
+
132
+ do_action( 'ac/settings/list_screen', $list_screen );
133
+ }
134
+
135
+ /**
136
+ * @return AC_ListScreen
137
+ */
138
+ public function get_current_list_screen() {
139
+ return $this->current_list_screen;
140
+ }
141
+
142
+ /**
143
+ * Populate the list screen with columns headers from WP_List_Table
144
+ *
145
+ * @see WP_List_Table::get_columns()
146
+ *
147
+ * @param AC_ListScreen $list_screen
148
+ */
149
+ private function set_original_table_headers( AC_ListScreen $list_screen ) {
150
+ $list_screen->get_list_table();
151
+
152
+ $table_headers = (array) get_column_headers( $list_screen->get_screen_id() );
153
+
154
+ $list_screen->set_original_columns( $table_headers );
155
+ }
156
+
157
+ /**
158
+ * Handle request
159
+ */
160
+ public function handle_request() {
161
+ if ( ! AC()->user_can_manage_admin_columns() || ! $this->is_current_screen() ) {
162
+ return;
163
+ }
164
+
165
+ // Handle requests
166
+ switch ( filter_input( INPUT_POST, 'cpac_action' ) ) {
167
+
168
+ case 'restore_by_type' :
169
+ if ( $this->verify_nonce( 'restore-type' ) ) {
170
+ $list_screen = AC()->get_list_screen( filter_input( INPUT_POST, 'list_screen' ) );
171
+ $list_screen->set_layout_id( filter_input( INPUT_POST, 'layout' ) );
172
+ $list_screen->delete();
173
+
174
+ $this->notice( sprintf( __( 'Settings for %s restored successfully.', 'codepress-admin-columns' ), "<strong>" . esc_html( $this->get_list_screen_message_label( $list_screen ) ) . "</strong>" ), 'updated' );
175
+ }
176
+ break;
177
+ }
178
+
179
+ do_action( 'ac/settings/handle_request', $this );
180
+ }
181
+
182
+ /**
183
+ * @since 3.0
184
+ *
185
+ * @param AC_ListScreen $list_screen
186
+ *
187
+ * @return string $label
188
+ */
189
+ private function get_list_screen_message_label( $list_screen ) {
190
+ return apply_filters( 'ac/settings/list_screen_message_label', $list_screen->get_label(), $list_screen );
191
+ }
192
+
193
+ /**
194
+ * @param string $message Message body
195
+ * @param string $type Updated or error
196
+ */
197
+ public function notice( $message, $type = 'updated' ) {
198
+ $this->notices[] = '<div class="ac-message inline ' . esc_attr( $type ) . '"><p>' . $message . '</p></div>';
199
+ }
200
+
201
+ /**
202
+ * @param AC_Column $column
203
+ *
204
+ * @return string
205
+ */
206
+ private function get_column_display( AC_Column $column ) {
207
+ ob_start();
208
+ $this->display_column( $column );
209
+
210
+ return ob_get_clean();
211
+ }
212
+
213
+ /**
214
+ * Check is the ajax request is valid and user is allowed to make it
215
+ *
216
+ * @since 3.0
217
+ * @return AC_ListScreen
218
+ */
219
+ private function ajax_validate_request() {
220
+ check_ajax_referer( 'ac-settings' );
221
+
222
+ if ( ! AC()->user_can_manage_admin_columns() ) {
223
+ wp_die();
224
+ }
225
+
226
+ $list_screen = AC()->get_list_screen( filter_input( INPUT_POST, 'list_screen' ) );
227
+
228
+ if ( ! $list_screen ) {
229
+ wp_die();
230
+ }
231
+
232
+ $list_screen->set_layout_id( filter_input( INPUT_POST, 'layout' ) );
233
+
234
+ // Load default headings
235
+ if ( ! $list_screen->get_stored_default_headings() ) {
236
+ $list_screen->set_original_columns( (array) filter_input( INPUT_POST, 'original_columns', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ) );
237
+ }
238
+
239
+ return $list_screen;
240
+ }
241
+
242
+ /**
243
+ * @param AC_ListScreen $list_screen
244
+ *
245
+ * @return string
246
+ */
247
+ private function get_error_message_visit_list_screen( $list_screen ) {
248
+ return sprintf( __( 'Please visit the %s screen once to load all available columns', 'codepress-admin-columns' ), ac_helper()->html->link( $list_screen->get_screen_link(), $list_screen->get_label() ) );
249
+ }
250
+
251
+ /**
252
+ * Display HTML markup for column type
253
+ *
254
+ * @since 3.0
255
+ */
256
+ public function ajax_column_select() {
257
+ $list_screen = $this->ajax_validate_request();
258
+
259
+ $column = $list_screen->get_column_by_type( filter_input( INPUT_POST, 'type' ) );
260
+
261
+ if ( ! $column ) {
262
+ wp_send_json_error( array(
263
+ 'type' => 'message',
264
+ 'error' => $this->get_error_message_visit_list_screen( $list_screen ),
265
+ ) );
266
+ }
267
+
268
+ $current_original_columns = (array) filter_input( INPUT_POST, 'current_original_columns', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
269
+
270
+ // Not cloneable message
271
+ if ( in_array( $column->get_type(), $current_original_columns ) ) {
272
+ wp_send_json_error( array(
273
+ 'type' => 'message',
274
+ 'error' => sprintf(
275
+ __( '%s column is already present and can not be duplicated.', 'codepress-admin-columns' ),
276
+ '<strong>' . $column->get_label() . '</strong>' ),
277
+ ) );
278
+ }
279
+
280
+ // Placeholder message
281
+ if ( $column instanceof AC_Column_Placeholder ) {
282
+ wp_send_json_error( array(
283
+ 'type' => 'message',
284
+ 'error' => $column->get_message(),
285
+ ) );
286
+ }
287
+
288
+ wp_send_json_success( $this->get_column_display( $column ) );
289
+ }
290
+
291
+ /**
292
+ * @since 2.2
293
+ */
294
+ public function ajax_column_refresh() {
295
+ $list_screen = $this->ajax_validate_request();
296
+
297
+ $options = filter_input( INPUT_POST, 'columns', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
298
+ $name = filter_input( INPUT_POST, 'column_name' );
299
+
300
+ if ( empty( $options[ $name ] ) ) {
301
+ wp_die();
302
+ }
303
+
304
+ $settings = $options[ $name ];
305
+
306
+ $settings['name'] = $name;
307
+
308
+ $column = $list_screen->create_column( $settings );
309
+
310
+ if ( ! $column ) {
311
+ wp_die();
312
+ }
313
+
314
+ wp_send_json_success( $this->get_column_display( $column ) );
315
+ }
316
+
317
+ /**
318
+ * @since 2.5
319
+ */
320
+ public function ajax_columns_save() {
321
+ $list_screen = $this->ajax_validate_request();
322
+
323
+ parse_str( $_POST['data'], $formdata );
324
+
325
+ if ( ! isset( $formdata['columns'] ) ) {
326
+ wp_send_json_error( array(
327
+ 'type' => 'error',
328
+ 'message' => __( 'You need at least one column', 'codepress-admin-columns' ),
329
+ )
330
+ );
331
+ }
332
+
333
+ $result = $list_screen->store( $formdata['columns'] );
334
+
335
+ if ( is_wp_error( $result ) ) {
336
+
337
+ if ( 'same-settings' === $result->get_error_code() ) {
338
+ wp_send_json_error( array(
339
+ 'type' => 'notice notice-warning',
340
+ 'message' => sprintf( __( 'You are trying to store the same settings for %s.', 'codepress-admin-columns' ), "<strong>" . esc_html( $this->get_list_screen_message_label( $list_screen ) ) . "</strong>" ),
341
+ )
342
+ );
343
+ }
344
+
345
+ wp_send_json_error( array(
346
+ 'type' => 'error',
347
+ 'message' => $result->get_error_message(),
348
+ )
349
+ );
350
+ }
351
+
352
+ wp_send_json_success(
353
+ sprintf( __( 'Settings for %s updated successfully.', 'codepress-admin-columns' ), "<strong>" . esc_html( $this->get_list_screen_message_label( $list_screen ) ) . "</strong>" )
354
+ . ' <a href="' . esc_attr( $list_screen->get_screen_link() ) . '">' . esc_html( sprintf( __( 'View %s screen', 'codepress-admin-columns' ), $list_screen->get_label() ) ) . '</a>'
355
+ );
356
+ }
357
+
358
+ private function display_notices() {
359
+ if ( $this->notices ) {
360
+ echo implode( $this->notices );
361
+ }
362
+ }
363
+
364
+ public function sort_by_label( $a, $b ) {
365
+ return strcmp( $a->label, $b->label );
366
+ }
367
+
368
+ /**
369
+ * @return array
370
+ */
371
+ private function get_grouped_list_screens() {
372
+ $list_screens = array();
373
+
374
+ foreach ( AC()->get_list_screens() as $list_screen ) {
375
+ $list_screens[ $list_screen->get_group() ][ $list_screen->get_key() ] = $list_screen->get_label();
376
+ }
377
+
378
+ $grouped = array();
379
+
380
+ foreach ( AC()->list_screen_groups()->get_groups_sorted() as $group ) {
381
+ $slug = $group['slug'];
382
+
383
+ if ( empty( $list_screens[ $slug ] ) ) {
384
+ continue;
385
+ }
386
+
387
+ if ( ! isset( $grouped[ $slug ] ) ) {
388
+ $grouped[ $slug ]['title'] = $group['label'];
389
+ }
390
+
391
+ natcasesort( $list_screens[ $slug ] );
392
+
393
+ $grouped[ $slug ]['options'] = $list_screens[ $slug ];
394
+
395
+ unset( $list_screens[ $slug ] );
396
+ }
397
+
398
+ return $grouped;
399
+ }
400
+
401
+ private function set_list_screen_preference( $list_screen_key ) {
402
+ ac_helper()->user->update_meta_site( self::OPTION_CURRENT, $list_screen_key );
403
+ }
404
+
405
+ private function get_list_screen_preference() {
406
+ return ac_helper()->user->get_meta_site( self::OPTION_CURRENT, true );
407
+ }
408
+
409
+ /**
410
+ * @param string $main_label
411
+ *
412
+ * @return string
413
+ */
414
+ private function get_truncated_side_label( $label, $mainlabel = '' ) {
415
+ if ( 34 < ( strlen( $label ) + ( strlen( $mainlabel ) * 1.1 ) ) ) {
416
+ $label = substr( $label, 0, 34 - ( strlen( $mainlabel ) * 1.1 ) ) . '...';
417
+ }
418
+
419
+ return $label;
420
+ }
421
+
422
+ /**
423
+ * @return AC_Admin_Promo|false
424
+ */
425
+ public function get_active_promotion() {
426
+ $classes = AC()->autoloader()->get_class_names_from_dir( AC()->get_plugin_dir() . 'classes/Admin/Promo', 'AC_' );
427
+
428
+ foreach ( $classes as $class ) {
429
+
430
+ /* @var AC_Admin_Promo $promo */
431
+ $promo = new $class;
432
+
433
+ if ( $promo->is_active() ) {
434
+ return $promo;
435
+ }
436
+ }
437
+
438
+ return false;
439
+ }
440
+
441
+ /**
442
+ * @param AC_ListScreen $list_screen
443
+ *
444
+ * @return string
445
+ */
446
+ private function get_read_only_message( AC_ListScreen $list_screen ) {
447
+ $message = sprintf( __( 'The columns for %s are set up via PHP and can therefore not be edited.', 'codepress-admin-columns' ), '<strong>' . esc_html( $list_screen->get_label() ) . '</strong>' );
448
+
449
+ return apply_filters( 'ac/read_only_message', $message, $list_screen );
450
+ }
451
+
452
+ /**
453
+ * Display
454
+ */
455
+ public function display() {
456
+ $list_screen = $this->get_current_list_screen();
457
+
458
+ ?>
459
+
460
+ <div class="ac-admin<?php echo $list_screen->get_settings() ? ' stored' : ''; ?>" data-type="<?php echo esc_attr( $list_screen->get_key() ); ?>">
461
+ <div class="main">
462
+ <div class="menu">
463
+ <form>
464
+ <?php $this->nonce_field( 'select-list-screen' ); ?>
465
+ <input type="hidden" name="page" value="<?php echo esc_attr( AC_Admin::MENU_SLUG ); ?>">
466
+
467
+ <select name="list_screen" title="Select type" id="ac_list_screen">
468
+ <?php foreach ( $this->get_grouped_list_screens() as $group ) : ?>
469
+ <optgroup label="<?php echo esc_attr( $group['title'] ); ?>">
470
+ <?php foreach ( $group['options'] as $key => $label ) : ?>
471
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $list_screen->get_key() ); ?>><?php echo esc_html( $label ); ?></option>
472
+ <?php endforeach; ?>
473
+ </optgroup>
474
+ <?php endforeach; ?>
475
+ </select>
476
+ <span class="spinner"></span>
477
+
478
+ <?php if ( $link = $list_screen->get_screen_link() ) : ?>
479
+ <a href="<?php echo esc_url( $link ); ?>" class="page-title-action view-link"><?php echo esc_html__( 'View', 'codepress-admin-columns' ); ?></a>
480
+ <?php endif; ?>
481
+ </form>
482
+ </div>
483
+
484
+ <?php do_action( 'ac/settings/after_title', $list_screen ); ?>
485
+
486
+ </div>
487
+
488
+ <div class="ac-right">
489
+ <div class="ac-right-inner">
490
+
491
+ <?php if ( ! $list_screen->is_read_only() ) : ?>
492
+ <div class="sidebox form-actions">
493
+ <?php $mainlabel = __( 'Store settings', 'codepress-admin-columns' ); ?>
494
+ <h3>
495
+ <span class="left"><?php echo esc_html( $mainlabel ); ?></span>
496
+ <?php if ( 18 > strlen( $mainlabel ) && ( $truncated_label = $this->get_truncated_side_label( $list_screen->get_label(), $mainlabel ) ) ) : ?>
497
+ <span class="right contenttype"><?php echo esc_html( $truncated_label ); ?></span>
498
+ <?php else : ?>
499
+ <span class="clear contenttype"><?php echo esc_html( $list_screen->get_label() ); ?></span>
500
+ <?php endif; ?>
501
+ </h3>
502
+
503
+ <div class="form-update">
504
+ <a class="button-primary submit update"><?php _e( 'Update' ); ?></a>
505
+ <a class="button-primary submit save"><?php _e( 'Save' ); ?></a>
506
+ </div>
507
+
508
+ <form class="form-reset" method="post">
509
+ <input type="hidden" name="list_screen" value="<?php echo esc_attr( $list_screen->get_key() ); ?>"/>
510
+ <input type="hidden" name="layout" value="<?php echo esc_attr( $list_screen->get_layout_id() ); ?>"/>
511
+ <input type="hidden" name="cpac_action" value="restore_by_type"/>
512
+
513
+ <?php $this->nonce_field( 'restore-type' ); ?>
514
+
515
+ <?php $onclick = AC()->use_delete_confirmation() ? ' onclick="return confirm(\'' . esc_js( sprintf( __( "Warning! The %s columns data will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop", 'codepress-admin-columns' ), "'" . $this->get_list_screen_message_label( $list_screen ) . "'" ) ) . '\');"' : ''; ?>
516
+ <input class="reset-column-type" type="submit"<?php echo $onclick; ?> value="<?php _e( 'Restore columns', 'codepress-admin-columns' ); ?>">
517
+ <span class="spinner"></span>
518
+ </form>
519
+
520
+ <?php do_action( 'ac/settings/form_actions', $this ); ?>
521
+
522
+ </div><!--form-actions-->
523
+ <?php endif; ?>
524
+
525
+ <?php do_action( 'ac/settings/sidebox', $list_screen ); ?>
526
+
527
+ <?php if ( apply_filters( 'ac/show_banner', true ) ) : ?>
528
+
529
+ <?php $active_promotion = $this->get_active_promotion(); ?>
530
+
531
+ <div class="sidebox" id="ac-pro-version">
532
+ <div class="padding-box">
533
+ <h3>
534
+ <a href="<?php echo esc_url( ac_get_site_utm_url( 'upgrade-to-admin-columns-pro', 'banner', 'title' ) ); ?>">
535
+ <?php _e( 'Upgrade to', 'codepress-admin-columns' ); ?>&nbsp;<span><?php _e( 'Pro', 'codepress-admin-columns' ); ?></span>
536
+ </a>
537
+ </h3>
538
+
539
+ <div class="inside">
540
+ <p><?php _e( 'Take Admin Columns to the next level:', 'codepress-admin-columns' ); ?></p>
541
+ <ul class="features">
542
+ <?php
543
+
544
+ $items = array(
545
+ 'sorting' => __( 'Add sortable columns', 'codepress-admin-columns' ),
546
+ 'filtering' => __( 'Add filterable columns', 'codepress-admin-columns' ),
547
+ 'editing' => __( 'Edit your column content directly', 'codepress-admin-columns' ),
548
+ 'column-sets' => __( 'Create multiple columns sets', 'codepress-admin-columns' ),
549
+ 'import-export' => __( 'Import &amp; Export settings', 'codepress-admin-columns' ),
550
+ );
551
+
552
+ foreach ( $items as $utm_content => $label ) : ?>
553
+ <li>
554
+ <a href="<?php echo esc_url( ac_get_site_utm_url( 'upgrade-to-admin-columns-pro', 'banner', 'usp-' . $utm_content ) ); ?>"><?php echo esc_html( $label ); ?></a>
555
+ </li>
556
+ <?php endforeach; ?>
557
+
558
+ </ul>
559
+
560
+ <?php if ( $promos = AC()->addons()->get_missing_addons() ) : ?>
561
+ <strong><?php _e( 'Extra Columns for:', 'codepress-admin-columns' ); ?></strong>
562
+ <ul>
563
+ <?php foreach ( $promos as $addon ) : ?>
564
+ <li class="acp-integration">
565
+ <a href="<?php echo esc_url( $addon->get_link() ); ?>" target="_blank"><?php $addon->display_promo(); ?></a>
566
+ </li>
567
+ <?php endforeach; ?>
568
+ </ul>
569
+ <?php endif; ?>
570
+
571
+ <p class="center nopadding">
572
+ <?php if ( ! $active_promotion ) : ?>
573
+ <a target="_blank" href="<?php echo esc_url( ac_get_site_utm_url( 'upgrade-to-admin-columns-pro', 'banner' ) ); ?>" class="more">
574
+ <?php _e( 'Learn more about Pro', 'codepress-admin-columns' ); ?>
575
+ </a>
576
+ <?php endif; ?>
577
+ </p>
578
+ </div>
579
+ </div>
580
+
581
+ <?php if ( $active_promotion ) : ?>
582
+
583
+ <div class="padding-box ac-pro-deal">
584
+ <?php $active_promotion->display(); ?>
585
+ </div>
586
+
587
+ <?php else : ?>
588
+
589
+ <div class="padding-box ac-pro-newsletter">
590
+ <h3>
591
+ <?php echo esc_html( sprintf( __( 'Get %s Off!', 'codepress-admin-columns' ), '20%' ) ); ?>
592
+ </h3>
593
+ <div class="inside">
594
+ <p>
595
+ <?php echo esc_html( sprintf( __( "Submit your email and we'll send you a coupon for %s off.", 'codepress-admin-columns' ), '20%' ) ); ?>
596
+ </p>
597
+ <?php
598
+ $user_data = get_userdata( get_current_user_id() );
599
+ ?>
600
+ <form method="post" action="<?php echo esc_url( ac_get_site_utm_url( 'upgrade-to-admin-columns-pro', 'send-coupon' ) ); ?>" target="_blank">
601
+ <input name="action" type="hidden" value="mc_upgrade_pro">
602
+ <input name="EMAIL" placeholder="<?php esc_attr_e( "Your Email", 'codepress-admin-columns' ); ?>" value="<?php echo esc_attr( $user_data->user_email ); ?>">
603
+ <input name="FNAME" placeholder="<?php esc_attr_e( "Your First Name", 'codepress-admin-columns' ); ?>">
604
+ <input type="submit" value="<?php esc_attr_e( "Send me the coupon", 'codepress-admin-columns' ); ?>" class="acp-button">
605
+ </form>
606
+ </div>
607
+ </div>
608
+
609
+ <?php endif; ?>
610
+
611
+ </div>
612
+
613
+ <div class="sidebox" id="direct-feedback">
614
+ <div id="feedback-choice">
615
+ <h3><?php _e( 'Are you happy with Admin Columns?', 'codepress-admin-columns' ); ?></h3>
616
+
617
+ <div class="inside">
618
+ <a href="#" class="yes"><?php _e( 'Yes' ); ?></a>
619
+ <a href="#" class="no"><?php _e( 'No' ); ?></a>
620
+ </div>
621
+ </div>
622
+ <div id="feedback-support">
623
+ <div class="inside">
624
+ <p>
625
+ <?php _e( "What's wrong? Need help? Let us know!", 'codepress-admin-columns' ); ?>
626
+ </p>
627
+ <p>
628
+ <?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'codepress-admin-columns' ); ?>
629
+ </p>
630
+ <ul class="share">
631
+ <li>
632
+ <a href="<?php echo esc_url( ac_get_site_utm_url( 'documentation', 'feedback-docs-button' ) ); ?>" target="_blank">
633
+ <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'codepress-admin-columns' ); ?>
634
+ </a>
635
+ </li>
636
+ <li>
637
+ <a href="https://wordpress.org/support/plugin/codepress-admin-columns" target="_blank">
638
+ <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'codepress-admin-columns' ); ?>
639
+ </a>
640
+ </li>
641
+ </ul>
642
+ <div class="clear"></div>
643
+ </div>
644
+ </div>
645
+ <div id="feedback-rate">
646
+ <div class="inside">
647
+ <p>
648
+ <?php _e( "Woohoo! We're glad to hear that!", 'codepress-admin-columns' ); ?>
649
+ </p>
650
+ <p>
651
+ <?php _e( 'We would really love it if you could show your appreciation by giving us a rating on WordPress.org or tweet about Admin Columns!', 'codepress-admin-columns' ); ?>
652
+ </p>
653
+ <ul class="share">
654
+ <li>
655
+ <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
656
+ <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'codepress-admin-columns' ); ?>
657
+ </a>
658
+ </li>
659
+
660
+ <li>
661
+ <a href="<?php echo esc_url( add_query_arg( array( 'hashtags' => 'admincolumns', 'text' => urlencode( __( "I'm using Admin Columns for WordPress!", 'codepress-admin-columns' ) ), 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ), 'via' => ac_get_twitter_handle() ), 'https://twitter.com/intent/tweet' ) ); ?>" target="_blank">
662
+ <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'codepress-admin-columns' ); ?>
663
+ </a>
664
+ </li>
665
+
666
+ <li>
667
+ <a href="<?php echo esc_url( ac_get_site_utm_url( 'upgrade-to-admin-columns-pro', 'feedback-purchase-button' ) ); ?>" target="_blank">
668
+ <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'codepress-admin-columns' ); ?>
669
+ </a>
670
+ </li>
671
+ </ul>
672
+ <div class="clear"></div>
673
+ </div>
674
+ </div>
675
+ </div>
676
+
677
+ <?php endif; ?>
678
+
679
+ <div class="sidebox" id="plugin-support">
680
+ <h3><?php _e( 'Support', 'codepress-admin-columns' ); ?></h3>
681
+
682
+ <div class="inside">
683
+ <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
684
+ <p>
685
+ <?php _e( "Check the <strong>Help</strong> section in the top-right screen.", 'codepress-admin-columns' ); ?>
686
+ </p>
687
+ <?php endif; ?>
688
+ <p>
689
+ <?php printf( __( "For full documentation, bug reports, feature suggestions and other tips <a href='%s'>visit the Admin Columns website</a>", 'codepress-admin-columns' ), ac_get_site_utm_url( 'documentation', 'support' ) ); ?>
690
+ </p>
691
+ </div>
692
+ </div><!--plugin-support-->
693
+
694
+ </div><!--.ac-right-inner-->
695
+ </div><!--.ac-right-->
696
+
697
+ <div class="ac-left">
698
+ <?php if ( ! $list_screen->get_stored_default_headings() && ! $list_screen->is_read_only() ) : ?>
699
+ <div class="notice notice-warning">
700
+ <p>
701
+ <?php echo $this->get_error_message_visit_list_screen( $list_screen ); ?>
702
+ </p>
703
+ </div>
704
+ <?php endif ?>
705
+
706
+ <?php $this->display_notices(); ?>
707
+
708
+ <?php if ( $list_screen->is_read_only() ) : ?>
709
+ <div class="ac-notice notice-warning below-h2">
710
+ <p><?php echo $this->get_read_only_message( $list_screen ); ?></p>
711
+ </div>
712
+ <?php endif; ?>
713
+
714
+ <div class="ac-boxes<?php echo esc_attr( $list_screen->is_read_only() ? ' disabled' : '' ); ?>">
715
+
716
+ <div class="ac-columns">
717
+ <form method="post" action="<?php echo esc_attr( $this->get_link() ); ?>">
718
+
719
+ <input type="hidden" name="list_screen" value="<?php echo esc_attr( $list_screen->get_key() ); ?>"/>
720
+ <input type="hidden" name="cpac_action" value="update_by_type"/>
721
+
722
+ <?php $this->nonce_field( 'update-type' ); ?>
723
+
724
+ <?php
725
+
726
+ /**
727
+ * Columns
728
+ */
729
+ foreach ( $list_screen->get_columns() as $column ) {
730
+ $this->display_column( $column );
731
+ }
732
+ ?>
733
+ </form>
734
+
735
+ </div>
736
+
737
+ <div class="column-footer">
738
+ <?php if ( ! $list_screen->is_read_only() ) : ?>
739
+ <div class="order-message">
740
+ <?php _e( 'Drag and drop to reorder', 'codepress-admin-columns' ); ?>
741
+ </div>
742
+ <div class="button-container">
743
+ <?php
744
+
745
+ /**
746
+ * Display a clear button below the column settings. The clear button removes all column settings from the current page.
747
+ *
748
+ * @since 3.0
749
+ *
750
+ * @param bool
751
+ */
752
+ if ( apply_filters( 'ac/enable_clear_columns_button', false ) ) :
753
+ ?>
754
+ <a class="clear-columns" data-clear-columns><?php _e( 'Clear all columns ', 'codepress-admin-columns' ) ?></a>
755
+ <?php endif; ?>
756
+
757
+ <span class="spinner"></span>
758
+ <a class="button-primary submit update"><?php _e( 'Update' ); ?></a>
759
+ <a class="button-primary submit save"><?php _e( 'Save' ); ?></a>
760
+ <a class="add_column button">+ <?php _e( 'Add Column', 'codepress-admin-columns' ); ?></a>
761
+ </div>
762
+ <?php endif; ?>
763
+ </div>
764
+
765
+ </div><!--.ac-boxes-->
766
+
767
+ <?php do_action( 'ac/settings/after_columns', $list_screen ); ?>
768
+
769
+ </div><!--.ac-left-->
770
+ <div class="clear"></div>
771
+
772
+ <div id="add-new-column-template">
773
+ <?php $this->display_column_template( $list_screen ); ?>
774
+ </div>
775
+
776
+ </div><!--.ac-admin-->
777
+
778
+ <div class="clear"></div>
779
+
780
+ <?php
781
+ }
782
+
783
+ /**
784
+ * Get first custom group column
785
+ */
786
+ private function display_column_template( AC_ListScreen $list_screen ) {
787
+ $columns = array();
788
+
789
+ foreach ( $list_screen->get_column_types() as $column_type ) {
790
+ if ( 'custom' === $column_type->get_group() ) {
791
+ $columns[ $column_type->get_label() ] = $column_type;
792
+ }
793
+ }
794
+
795
+ array_multisort( array_keys( $columns ), SORT_NATURAL, $columns );
796
+
797
+ /** @var AC_Column $column */
798
+ $column = array_shift( $columns );
799
+
800
+ $this->display_column( $column );
801
+ }
802
+
803
+ /**
804
+ * @since 2.0
805
+ */
806
+ public function display_column( AC_Column $column ) { ?>
807
+
808
+ <div class="ac-column ac-<?php echo esc_attr( $column->get_type() ); ?>"
809
+ data-type="<?php echo esc_attr( $column->get_type() ); ?>"
810
+ data-original="<?php echo esc_attr( $column->is_original() ); ?>"
811
+ data-column-name="<?php echo esc_attr( $column->get_name() ); ?>">
812
+
813
+ <div class="ac-column-header">
814
+ <table class="widefat">
815
+ <tbody>
816
+ <tr>
817
+ <td class="column_sort">
818
+ <span class="cpacicon-move"></span>
819
+ </td>
820
+ <td class="column_label">
821
+ <div class="inner">
822
+ <div class="meta">
823
+ <?php
824
+
825
+ foreach ( $column->get_settings() as $setting ) {
826
+ if ( $setting instanceof AC_Settings_HeaderInterface ) {
827
+ echo $setting->render_header();
828
+ }
829
+ }
830
+
831
+ /**
832
+ * Fires in the meta-element for column options, which is displayed right after the column label
833
+ *
834
+ * @since 2.0
835
+ *
836
+ * @param AC_Column $column_instance Column class instance
837
+ */
838
+ do_action( 'ac/column/header', $column );
839
+
840
+ ?>
841
+ </div>
842
+ <a class="toggle" data-toggle="column">
843
+ <?php echo $column->get_setting( 'label' )->get_value(); // do not escape ?>
844
+ </a>
845
+ <a class="edit-button" data-toggle="column"><?php _e( 'Edit', 'codepress-admin-columns' ); ?></a>
846
+ <a class="close-button" data-toggle="column"><?php _e( 'Close', 'codepress-admin-columns' ); ?></a>
847
+ <?php if ( ! $column->is_original() ) : ?>
848
+ <a class="clone-button" href="#"><?php _e( 'Clone', 'codepress-admin-columns' ); ?></a>
849
+ <?php endif; ?>
850
+ <a class="remove-button"><?php _e( 'Remove', 'codepress-admin-columns' ); ?></a>
851
+ </div>
852
+ </td>
853
+ <td class="column_type">
854
+ <div class="inner" data-toggle="column">
855
+ <?php echo ac_helper()->html->strip_attributes( $column->get_label(), array( 'style', 'class' ) ); ?>
856
+ </div>
857
+ </td>
858
+ <td class="column_edit" data-toggle="column">
859
+ </td>
860
+ </tr>
861
+ </tbody>
862
+ </table>
863
+ </div>
864
+
865
+ <div class="ac-column-body">
866
+ <div class="ac-column-settings">
867
+
868
+ <?php
869
+
870
+ foreach ( $column->get_settings() as $setting ) {
871
+ echo $setting->render() . "\n";
872
+ }
873
+
874
+ ?>
875
+
876
+ <table class="ac-column-setting ac-column-setting-actions">
877
+ <tr>
878
+ <td class="col-label"></td>
879
+ <td class="col-settings">
880
+ <p>
881
+ <a href="#" class="close-button" data-toggle="column"><?php _e( 'Close', 'codepress-admin-columns' ); ?></a>
882
+ <?php if ( ! $column->is_original() ) : ?>
883
+ <a class="clone-button" href="#"><?php _e( 'Clone', 'codepress-admin-columns' ); ?></a>
884
+ <?php endif; ?>
885
+ <a href="#" class="remove-button"><?php _e( 'Remove' ); ?></a>
886
+ </p>
887
+ </td>
888
+ </tr>
889
+
890
+ </table>
891
+ </div>
892
+ </div>
893
+ </div>
894
+ <?php
895
+ }
896
+
897
+ }
classes/Admin/Page/Help.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Page_Help extends AC_Admin_Page {
8
+
9
+ const TRANSIENT_COUNT_KEY = 'ac-deprecated-message-count';
10
+
11
+ private $messages = array();
12
+
13
+ public function __construct() {
14
+
15
+ $this
16
+ ->set_slug( 'help' )
17
+ ->set_label_with_count();
18
+
19
+ // Hide page when there are no messages
20
+ if ( ! $this->get_message_count() ) {
21
+ $this->set_show_in_menu( false );
22
+ }
23
+
24
+ // Init and request
25
+ add_action( 'admin_init', array( $this, 'init' ), 9 );
26
+ add_action( 'admin_init', array( $this, 'run_hooks_on_help_tab' ) );
27
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
28
+ }
29
+
30
+ /**
31
+ * @return $this
32
+ */
33
+ private function set_label_with_count() {
34
+ $label = __( 'Help', 'codepress-admin-columns' );
35
+
36
+ if ( $count = $this->get_message_count() ) {
37
+ $label .= '<span class="ac-badge">' . $count . '</span>';
38
+ }
39
+
40
+ $this->set_label( $label );
41
+
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Run all hooks once
47
+ */
48
+ public function init() {
49
+ if ( ! AC()->user_can_manage_admin_columns() ) {
50
+ return;
51
+ }
52
+
53
+ // Run once
54
+ if ( false === $this->get_message_count() ) {
55
+ $this->run_hooks();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Run all hooks when opening the help tab.
61
+ */
62
+ public function run_hooks_on_help_tab() {
63
+ if ( ! AC()->user_can_manage_admin_columns() || ! $this->is_current_screen() ) {
64
+ return;
65
+ }
66
+
67
+ $this->run_hooks();
68
+ }
69
+
70
+ /**
71
+ * Admin scripts
72
+ */
73
+ public function admin_scripts() {
74
+ if ( $this->is_current_screen() ) {
75
+ wp_enqueue_style( 'ac-admin-page-help-css', AC()->get_plugin_url() . 'assets/css/admin-page-help' . AC()->minified() . '.css', array(), AC()->get_version() );
76
+ }
77
+ }
78
+
79
+ private function update_message_count() {
80
+ $count = count( $this->get_messages( 'filter' ) ) + count( $this->get_messages( 'action' ) );
81
+
82
+ set_transient( self::TRANSIENT_COUNT_KEY, $count, WEEK_IN_SECONDS );
83
+ }
84
+
85
+ private function get_message_count() {
86
+ return get_transient( self::TRANSIENT_COUNT_KEY );
87
+ }
88
+
89
+ public function delete_message_count() {
90
+ delete_transient( self::TRANSIENT_COUNT_KEY );
91
+ }
92
+
93
+ /**
94
+ * This will run all deprecated hooks and adds a message when a hook has been used on the site.
95
+ */
96
+ public function run_hooks() {
97
+
98
+ $types = array( 'post', 'user', 'comment', 'link', 'media' );
99
+ $post_types = get_post_types();
100
+
101
+ $columns = array();
102
+ foreach ( AC()->get_list_screens() as $ls ) {
103
+ foreach ( $ls->get_column_types() as $column ) {
104
+ $columns[ $column->get_type() ] = $column->get_type();
105
+ }
106
+ }
107
+
108
+ // Filters
109
+
110
+ $this->deprecated_filter( 'cac/headings/label', '3.0', 'cac-columns-custom' );
111
+ $this->deprecated_filter( 'cac/column/meta/value', '3.0', 'cac-column-meta-value' );
112
+ $this->deprecated_filter( 'cac/column/meta/types', '3.0', 'cac-column-meta-types' );
113
+ $this->deprecated_filter( 'cac/settings/tabs', '3.0', 'cac-settings-tabs' );
114
+ $this->deprecated_filter( 'cac/editable/is_column_editable', '3.0', 'cac-editable-is_column_editable' );
115
+ $this->deprecated_filter( 'cac/editable/editables_data', '3.0', 'cac-editable-editables_data' );
116
+ $this->deprecated_filter( 'cac/editable/options', '3.0', 'cac-editable-editables_data' );
117
+ $this->deprecated_filter( 'cac/inline-edit/ajax-column-save/value', '3.0', 'cac-inline-edit-ajax-column-save-value' );
118
+ $this->deprecated_filter( 'cac/addon/filtering/options', '3.0', 'cac-addon-filtering-options' );
119
+ $this->deprecated_filter( 'cac/addon/filtering/dropdown_top_label', '3.0', 'cac-addon-filtering-dropdown_top_label' );
120
+ $this->deprecated_filter( 'cac/addon/filtering/taxonomy/terms_args', '3.0', 'cac-addon-filtering-taxonomy-terms_args' );
121
+ $this->deprecated_filter( 'cac/addon/filtering/dropdown_empty_option', '3.0', 'cac-addon-filtering-taxonomy-terms_args' );
122
+ $this->deprecated_filter( 'cac/column/actions/action_links', '3.0', 'cac-column_actions-action_links' );
123
+ $this->deprecated_filter( 'cac/acf/format_acf_value', '3.0', 'cac-acf-format_acf_value' );
124
+ $this->deprecated_filter( 'cac/addon/filtering/taxonomy/terms_args', '3.0' );
125
+ $this->deprecated_filter( 'cac/column/meta/use_text_input', '3.0' );
126
+ $this->deprecated_filter( 'cac/hide_renewal_notice', '3.0' );
127
+
128
+ $this->deprecated_filter( 'cac/columns/custom', '3.0', 'cac-columns-custom' );
129
+ foreach ( $types as $type ) {
130
+ $this->deprecated_filter( 'cac/columns/custom/type=' . $type, '3.0', 'cac-columns-custom' );
131
+ }
132
+
133
+ foreach ( $post_types as $post_type ) {
134
+ $this->deprecated_filter( 'cac/columns/custom/post_type=' . $post_type, '3.0', 'cac-columns-custom' );
135
+ }
136
+
137
+ $this->deprecated_filter( 'cac/column/value', '3.0', 'cac-column-value' );
138
+ foreach ( $types as $type ) {
139
+ $this->deprecated_filter( 'cac/column/value/' . $type, '3.0', 'cac-column-value' );
140
+ }
141
+
142
+ $this->deprecated_filter( 'cac/editable/column_value', '3.0', 'cac-editable-column_value' );
143
+ foreach ( $columns as $column_type ) {
144
+ $this->deprecated_filter( 'cac/editable/column_value/column=' . $column_type, '3.0', 'cac-editable-column_value' );
145
+ }
146
+
147
+ $this->deprecated_filter( 'cac/editable/column_save', '3.0', 'cac-editable-column_save' );
148
+ foreach ( $columns as $column_type ) {
149
+ $this->deprecated_filter( 'cac/editable/column_save/column=' . $column_type, '3.0', 'cac-editable-column_save' );
150
+ }
151
+
152
+ // Actions
153
+ $this->deprecated_action( 'cac/admin_head', '3.0', 'cac-admin_head' );
154
+ $this->deprecated_action( 'cac/loaded', '3.0', 'cac-cacloaded' );
155
+ $this->deprecated_action( 'cac/inline-edit/after_ajax_column_save', '3.0', 'cacinline-editafter_ajax_column_save' );
156
+ $this->deprecated_action( 'cac/settings/after_title', '3.0' );
157
+ $this->deprecated_action( 'cac/settings/form_actions', '3.0' );
158
+ $this->deprecated_action( 'cac/settings/sidebox', '3.0' );
159
+ $this->deprecated_action( 'cac/settings/form_columns', '3.0' );
160
+ $this->deprecated_action( 'cac/settings/after_columns', '3.0' );
161
+ $this->deprecated_action( 'cac/column/settings_meta', '3.0' );
162
+ $this->deprecated_action( 'cac/settings/general', '3.0' );
163
+ $this->deprecated_action( 'cpac_messages', '3.0' );
164
+ $this->deprecated_action( 'cac/settings/after_menu', '3.0' );
165
+
166
+ $this->update_message_count();
167
+ }
168
+
169
+ private function get_groups() {
170
+ $groups = array(
171
+ 'filter' => __( 'Deprecated Filters', 'codepress-admin-columns' ),
172
+ 'action' => __( 'Deprecated Actions', 'codepress-admin-columns' ),
173
+ );
174
+
175
+ return $groups;
176
+ }
177
+
178
+ /**
179
+ * @param string $hook
180
+ * @param string $version
181
+ * @param string|null $page_slug
182
+ */
183
+ private function deprecated_filter( $hook, $version, $page_slug = null ) {
184
+ if ( has_filter( $hook ) ) {
185
+ $message = sprintf( __( 'The filter %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
186
+
187
+ $this->add_deprecated_message( 'filter', $message, $hook, 'filter-reference/' . $page_slug );
188
+ }
189
+ }
190
+
191
+ /**
192
+ * @param string $hook
193
+ * @param string $version
194
+ * @param string|null $page_slug
195
+ */
196
+ private function deprecated_action( $hook, $version, $page_slug = null ) {
197
+ if ( has_action( $hook ) ) {
198
+ $message = sprintf( __( 'The action %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
199
+
200
+ $this->add_deprecated_message( 'action', $message, $hook, 'action-reference/' . $page_slug );
201
+ }
202
+ }
203
+
204
+ /**
205
+ * @param string $type
206
+ * @param string $message
207
+ * @param string $hook
208
+ * @param null $page
209
+ */
210
+ private function add_deprecated_message( $type, $message, $hook, $page = null ) {
211
+ if ( $callback_message = $this->get_callback_message( $hook ) ) {
212
+ $message .= ' ' . $callback_message;
213
+ }
214
+ if ( $page ) {
215
+ $message .= ' ' . $this->get_documention_link( $page );
216
+ }
217
+
218
+ $this->add_message( $message, $type );
219
+ }
220
+
221
+ /**
222
+ * @param string $message
223
+ * @param string $type
224
+ */
225
+ private function add_message( $message, $type = 'filter' ) {
226
+ $this->messages[ $type ][] = $message;
227
+ }
228
+
229
+ /**
230
+ * @param string $type
231
+ *
232
+ * @return array|false
233
+ */
234
+ private function get_messages( $type = 'filter' ) {
235
+ if ( ! isset( $this->messages[ $type ] ) ) {
236
+ return array();
237
+ }
238
+
239
+ return $this->messages[ $type ];
240
+ }
241
+
242
+ /**
243
+ * @param string $page Website page slug
244
+ *
245
+ * @return false|string
246
+ */
247
+ private function get_documention_link( $page ) {
248
+ return ac_helper()->html->link( ac_get_site_url( 'documentation/' . $page ), __( 'View documentation', 'codepress-admin-columns' ) . ' &raquo;', array( 'target' => '_blank' ) );
249
+ }
250
+
251
+ /**
252
+ * @param string $hook Action or Filter
253
+ *
254
+ * @return array|false
255
+ */
256
+ private function get_callbacks( $hook ) {
257
+ global $wp_filter;
258
+
259
+ if ( ! isset( $wp_filter[ $hook ] ) ) {
260
+ return false;
261
+ }
262
+
263
+ if ( empty( $wp_filter[ $hook ]->callbacks ) ) {
264
+ return false;
265
+ }
266
+
267
+ $callbacks = array();
268
+
269
+ foreach ( $wp_filter[ $hook ]->callbacks as $callback ) {
270
+ foreach ( $callback as $cb ) {
271
+
272
+ // Function
273
+ if ( is_scalar( $cb['function'] ) ) {
274
+ $callbacks[] = $cb['function'];
275
+ }
276
+
277
+ // Method
278
+ if ( is_array( $cb['function'] ) ) {
279
+ $callbacks[] = get_class( $cb['function'][0] ) . '::' . $cb['function'][1];
280
+ }
281
+ }
282
+ }
283
+
284
+ if ( ! $callbacks ) {
285
+ return false;
286
+ }
287
+
288
+ return $callbacks;
289
+ }
290
+
291
+ /**
292
+ * @param string $hook Action or Filter
293
+ *
294
+ * @return string|false
295
+ */
296
+ private function get_callback_message( $hook ) {
297
+ $callbacks = $this->get_callbacks( $hook );
298
+
299
+ if ( ! $callbacks ) {
300
+ return false;
301
+ }
302
+
303
+ return sprintf( _n( 'The callback used is %s.', 'The callbacks used are %s', count( $callbacks ), 'codepress-admin-columns' ), '<code>' . implode( '</code>, <code>', $callbacks ) . '</code>' );
304
+ }
305
+
306
+ /**
307
+ * Render help page
308
+ */
309
+ public function display() {
310
+ ?>
311
+ <h2><?php _e( 'Help', 'codepress-admin-columns' ); ?></h2>
312
+ <p>
313
+ <?php _e( 'The Admin Columns plugin has undergone some major changes in version 4.', 'codepress-admin-columns' ); ?> <br/>
314
+
315
+ <?php printf( __( 'This site is using some actions or filters that have changed. Please read %s to resolve them.', 'codepress-admin-columns' ), ac_helper()->html->link( ac_get_site_utm_url( 'documentation/faq/upgrading-from-v3-to-v4', 'help' ), __( 'our documentation', 'codepress-admin-columns' ) ) ); ?>
316
+ </p>
317
+
318
+ <?php foreach ( $this->get_groups() as $type => $label ) {
319
+ if ( $messages = $this->get_messages( $type ) ) : ?>
320
+ <h3><?php echo esc_html( $label ); ?></h3>
321
+ <?php foreach ( $messages as $message ) : ?>
322
+ <div class="ac-deprecated-message">
323
+ <p><?php echo $message; ?></p>
324
+ </div>
325
+ <?php endforeach; ?>
326
+ <?php endif;
327
+ }
328
+ }
329
+
330
+ }
classes/Admin/Page/Settings.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Page_Settings extends AC_Admin_Page {
8
+
9
+ const SETTINGS_NAME = 'cpac_general_options';
10
+
11
+ const SETTINGS_GROUP = 'cpac-general-settings';
12
+
13
+ private $options;
14
+
15
+ public function __construct() {
16
+ $this
17
+ ->set_slug( 'settings' )
18
+ ->set_label( __( 'Settings', 'codepress-admin-columns' ) );
19
+
20
+ $this->options = get_option( self::SETTINGS_NAME );
21
+
22
+ register_setting( self::SETTINGS_GROUP, self::SETTINGS_NAME );
23
+
24
+ add_filter( 'option_page_capability_' . self::SETTINGS_GROUP, array( $this, 'set_capability' ) );
25
+ add_action( 'admin_init', array( $this, 'handle_column_request' ) );
26
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
27
+ }
28
+
29
+ public function admin_scripts() {
30
+ if ( $this->is_current_screen() ) {
31
+ wp_enqueue_style( 'ac-admin-page-settings', AC()->get_plugin_url() . 'assets/css/admin-page-settings' . AC()->minified() . '.css', array(), AC()->get_version() );
32
+ }
33
+ }
34
+
35
+ public function set_capability() {
36
+ return 'manage_admin_columns';
37
+ }
38
+
39
+ /**
40
+ * @param string $key
41
+ */
42
+ public function attr_name( $key ) {
43
+ echo esc_attr( self::SETTINGS_NAME . '[' . sanitize_key( $key ) . ']' );
44
+ }
45
+
46
+ /**
47
+ * @param $key
48
+ *
49
+ * @return false|string When '0' there are no options stored.
50
+ */
51
+ public function get_option( $key ) {
52
+ return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
53
+ }
54
+
55
+ private function is_empty_options() {
56
+ return false === $this->options;
57
+ }
58
+
59
+ public function delete_options() {
60
+ delete_option( self::SETTINGS_NAME );
61
+ }
62
+
63
+ /**
64
+ * @return bool
65
+ */
66
+ public function show_edit_button() {
67
+ return $this->is_empty_options() || $this->get_option( 'show_edit_button' );
68
+ }
69
+
70
+ /**
71
+ * Deletes all stored column settings. Does not delete general settings.
72
+ */
73
+ private function delete_all_column_settings() {
74
+ global $wpdb;
75
+
76
+ $sql = "
77
+ DELETE
78
+ FROM $wpdb->options
79
+ WHERE option_name LIKE %s";
80
+
81
+ $wpdb->query( $wpdb->prepare( $sql, AC_ListScreen::OPTIONS_KEY . '%' ) );
82
+
83
+ // @since 3.0
84
+ do_action( 'ac/restore_all_columns' );
85
+ }
86
+
87
+ /**
88
+ * @since 1.0
89
+ */
90
+ public function handle_column_request() {
91
+ if ( ! AC()->user_can_manage_admin_columns() || ! $this->is_current_screen() ) {
92
+ return;
93
+ }
94
+
95
+ switch ( filter_input( INPUT_POST, 'ac_action' ) ) :
96
+
97
+ case 'restore_all' :
98
+ if ( $this->verify_nonce( 'restore-all' ) ) {
99
+ $this->delete_all_column_settings();
100
+
101
+ AC()->notice( __( 'Default settings succesfully restored.', 'codepress-admin-columns' ), 'updated' );
102
+ }
103
+ break;
104
+
105
+ endswitch;
106
+ }
107
+
108
+ public function single_checkbox( $args = array() ) {
109
+ $defaults = array(
110
+ 'name' => '',
111
+ 'label' => '',
112
+ 'instructions' => '',
113
+ 'default_value' => false,
114
+ );
115
+
116
+ $args = (object) wp_parse_args( $args, $defaults );
117
+
118
+ $current_value = $this->is_empty_options() ? $args->default_value : $this->get_option( $args->name );
119
+ ?>
120
+ <p>
121
+ <label for="<?php echo $args->name; ?>">
122
+ <input name="<?php $this->attr_name( $args->name ); ?>" id="<?php echo $args->name; ?>" type="checkbox" value="1" <?php checked( $current_value, '1' ); ?>>
123
+ <?php echo $args->label; ?>
124
+ </label>
125
+ <?php if ( $args->instructions ) : ?>
126
+ <a class="ac-pointer instructions" rel="pointer-<?php echo $args->name; ?>" data-pos="right">
127
+ <?php _e( 'Instructions', 'codepress-admin-columns' ); ?>
128
+ </a>
129
+ <?php endif; ?>
130
+ </p>
131
+ <?php if ( $args->instructions ) : ?>
132
+ <div id="pointer-<?php echo $args->name; ?>" style="display:none;">
133
+ <h3><?php _e( 'Notice', 'codepress-admin-columns' ); ?></h3>
134
+ <?php echo $args->instructions; ?>
135
+ </div>
136
+ <?php
137
+ endif;
138
+ }
139
+
140
+ /**
141
+ * @param bool $type
142
+ *
143
+ * @return string
144
+ */
145
+ public function get_default_text( $type = 'on' ) {
146
+ $string = __( 'off', 'codepress-admin-columns' );
147
+
148
+ if ( 'on' === $type ) {
149
+ $string = __( 'on', 'codepress-admin-columns' );
150
+ }
151
+
152
+ return sprintf( __( "Default is %s.", 'codepress-admin-columns' ), '<code>' . $string . '</code>' );
153
+ }
154
+
155
+ public function display() { ?>
156
+ <table class="form-table ac-form-table settings">
157
+ <tbody>
158
+ <tr class="general">
159
+ <th scope="row">
160
+ <h2><?php _e( 'General Settings', 'codepress-admin-columns' ); ?></h2>
161
+ <p><?php _e( 'Customize your Admin Columns settings.', 'codepress-admin-columns' ); ?></p>
162
+ </th>
163
+ <td>
164
+ <form method="post" action="options.php">
165
+
166
+ <?php settings_fields( self::SETTINGS_GROUP ); ?>
167
+
168
+ <?php
169
+ $this->single_checkbox( array(
170
+ 'name' => 'show_edit_button',
171
+ 'label' => sprintf( __( "Show %s button on table screen.", 'codepress-admin-columns' ), '"' . __( 'Edit columns', 'codepress-admin-columns' ) . '"' ) . ' ' . $this->get_default_text( 'on' ),
172
+ 'default_value' => '1',
173
+ ) );
174
+ ?>
175
+
176
+ <?php do_action( 'ac/settings/general', $this ); ?>
177
+
178
+ <p>
179
+ <input type="submit" class="button" value="<?php _e( 'Save' ); ?>"/>
180
+ </p>
181
+ </form>
182
+ </td>
183
+ </tr>
184
+
185
+ <?php
186
+
187
+ /** Allow plugins to add their own custom settings to the settings page. */
188
+ if ( $groups = apply_filters( 'ac/settings/groups', array() ) ) {
189
+
190
+ foreach ( $groups as $id => $group ) {
191
+
192
+ $title = isset( $group['title'] ) ? $group['title'] : '';
193
+ $description = isset( $group['description'] ) ? $group['description'] : '';
194
+
195
+ ?>
196
+
197
+ <tr>
198
+ <th scope="row">
199
+ <h2><?php echo esc_html( $title ); ?></h2>
200
+
201
+ <p><?php echo $description; ?></p>
202
+ </th>
203
+ <td>
204
+ <?php
205
+
206
+ /** Use this Hook to add additional fields to the group */
207
+ do_action( "ac/settings/group/" . $id );
208
+
209
+ ?>
210
+ </td>
211
+ </tr>
212
+
213
+ <?php
214
+ }
215
+ }
216
+ ?>
217
+
218
+ <tr class="restore">
219
+ <th scope="row">
220
+ <h2><?php _e( 'Restore Settings', 'codepress-admin-columns' ); ?></h2>
221
+ <p><?php _e( 'This will delete all column settings and restore the default settings.', 'codepress-admin-columns' ); ?></p>
222
+ </th>
223
+ <td>
224
+ <form method="post">
225
+
226
+ <?php $this->nonce_field( 'restore-all' ); ?>
227
+
228
+ <input type="hidden" name="ac_action" value="restore_all">
229
+ <input type="submit" class="button" name="ac-restore-defaults" value="<?php echo esc_attr( __( 'Restore default settings', 'codepress-admin-columns' ) ); ?>" onclick="return confirm('<?php echo esc_js( __( "Warning! ALL saved admin columns data will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop", 'codepress-admin-columns' ) ); ?>');">
230
+ </form>
231
+ </td>
232
+ </tr>
233
+
234
+ </tbody>
235
+ </table>
236
+
237
+ <?php
238
+ }
239
+
240
+ }
classes/{upgrade.php → Admin/Page/Upgrade.php} RENAMED
@@ -1,411 +1,372 @@
1
- <?php
2
- /**
3
- * Upgrade
4
- *
5
- * Class largely based on code from ACF ( thanks to Elliot Condon )
6
- *
7
- * @since 2.0
8
- */
9
- class CPAC_Upgrade {
10
-
11
- /**
12
- * CPAC class
13
- */
14
- private $cpac;
15
-
16
- public $update_prevented = false;
17
-
18
- /**
19
- * @since 2.0
20
- */
21
- function __construct( $cpac ) {
22
-
23
- $this->cpac = $cpac;
24
-
25
- // Hooks
26
- add_action( 'admin_init', array( $this, 'init' ) );
27
- add_action( 'admin_menu', array( $this, 'admin_menu' ), 11 );
28
- add_action( 'admin_head', array( $this, 'admin_head' ) );
29
- add_action( 'wp_ajax_cpac_upgrade', array( $this, 'ajax_upgrade' ) );
30
-
31
- if ( ! $this->allow_upgrade() ) {
32
- add_action( 'cpac_messages', array( $this, 'proaddon_notice' ) );
33
- }
34
- }
35
-
36
- /**
37
- * Admin CSS to hide upgrade menu and place icon
38
- *
39
- * @since 2.2.7
40
- */
41
- public function admin_head() {
42
- ?>
43
- <style type="text/css">
44
- #menu-settings a[href="options-general.php?page=cpac-upgrade"] { display: none; }
45
- </style>
46
- <?php
47
- }
48
-
49
- /**
50
- * Display a notice about the deprecated pro add-on
51
- *
52
- * @since 2.2
53
- */
54
- public function proaddon_notice() {
55
-
56
- if ( apply_filters( 'cpac/suppress_proaddon_notice', false ) ) {
57
- return;
58
- }
59
- ?>
60
- <div class="message error">
61
- <p>
62
- <?php _e( 'The pro add-on is no longer supported. Please login to your account and download Admin Columns Pro', 'codepress-admin-columns' ); ?>
63
- <a href="<?php ac_site_url( 'pro-addon-information' ); ?>" target="_blank"><?php _e( 'Learn more', 'codepress-admin-columns' ); ?></a>
64
- </p>
65
- </div>
66
- <?php
67
- }
68
-
69
- /**
70
- * Whether upgrading is allowed
71
- *
72
- * @since 2.1.5
73
- *
74
- * @return bool Whether plugin upgrading is allowed
75
- */
76
- public function allow_upgrade() {
77
-
78
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
79
-
80
- return ! is_plugin_active( 'cac-addon-pro/cac-addon-pro.php' );
81
- }
82
-
83
- /**
84
- * Add submenu page & scripts
85
- *
86
- * @since 2.0
87
- */
88
- public function admin_menu() {
89
-
90
- // Don't run on plugin activate
91
- if ( isset( $_GET['action'] ) && 'activate-plugin' === $_GET['action'] ) {
92
- return;
93
- }
94
-
95
- $upgrade_page = add_submenu_page( 'options-general.php', __( 'Upgrade', 'codepress-admin-columns' ), __( 'Upgrade', 'codepress-admin-columns' ), 'manage_options', 'cpac-upgrade', array( $this, 'start_upgrade' ) );
96
- add_action( "admin_print_scripts-{$upgrade_page}", array( $this, 'admin_scripts' ) );
97
- }
98
-
99
- /**
100
- * @since 2.0
101
- */
102
- public function init() {
103
-
104
- // @dev_only delete_option( 'cpac_version' ); set_transient( 'cpac_show_welcome', 'display' );
105
- $version = get_option( 'cpac_version', false );
106
-
107
- // Maybe version pre 2.0.0 was used
108
- if ( ! $version && get_option( 'cpac_options' ) ) {
109
- $version = '1.0.0';
110
- }
111
-
112
- // @dev_only if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) echo "--------- CPAC DEBUG: START ---------<br/>\n" . $version . "<br/>\n" . CPAC_VERSION . "<br/>\n" . CPAC_UPGRADE_VERSION . "<br/>\n" . get_transient( 'cpac_show_welcome' ) . "<br/>\n" . "--------- CPAC DEBUG: END ---------<br/>\n";
113
-
114
- // Maybe upgrade?
115
- if ( $version ) {
116
-
117
- // run every upgrade
118
- if ( $version < CPAC_VERSION ) {
119
- // nothing yet
120
- }
121
-
122
- // run only when updating from v1 to v2
123
- if ( $version < '2.0.0' ) {
124
-
125
- // show welcome screen
126
- set_transient( 'cpac_show_welcome', 'display' );
127
- }
128
-
129
- // run only when database upgrade is needed
130
- if ( $version < CPAC_UPGRADE_VERSION ) {
131
-
132
- // display upgrade message on every page except upgrade page itself
133
- if ( ! ( isset( $_REQUEST['page'] ) && 'cpac-upgrade' === $_REQUEST['page'] ) ) {
134
-
135
- $message = __( 'Admin Columns', 'codepress-admin-columns' ) . ' v' . CPAC_VERSION . ' ' .
136
- __( 'requires a database upgrade','codepress-admin-columns' ) .
137
- ' (<a class="thickbox" href="' . admin_url() .
138
- 'plugin-install.php?tab=plugin-information&plugin=codepress-admin-columns&section=changelog&TB_iframe=true&width=640&height=559">' .
139
- __( 'why?', 'codepress-admin-columns' ) .'</a>). ' .
140
- __( "Please", 'codepress-admin-columns' ) .' <a href="http://codex.wordpress.org/Backing_Up_Your_Database">' .
141
- __( "backup your database", 'codepress-admin-columns' ) .'</a>, '.
142
- __( "then click", 'codepress-admin-columns' ) . ' <a href="' . admin_url() . 'options-general.php?page=cpac-upgrade" class="button">' .
143
- __( "Upgrade Database", 'codepress-admin-columns' ) . '</a>';
144
-
145
- cpac_admin_message( $message, 'updated' );
146
- }
147
- }
148
-
149
- // run when NO upgrade is needed
150
- elseif ( $version < CPAC_VERSION ) {
151
-
152
- update_option( 'cpac_version', CPAC_VERSION );
153
- }
154
- }
155
-
156
- // Fresh install
157
- else {
158
-
159
- update_option( 'cpac_version', CPAC_VERSION );
160
- }
161
- }
162
-
163
- /**
164
- * Init Upgrade Process
165
- *
166
- * @since 2.0
167
- */
168
- public function ajax_upgrade() {
169
-
170
- // vars
171
- $return = array(
172
- 'status' => false,
173
- 'message' => "",
174
- 'next' => false,
175
- );
176
-
177
- $version = $_POST['version'];
178
-
179
- // versions
180
- switch ( $version ) {
181
-
182
- case '2.0.0' :
183
-
184
- $old_settings = get_option( 'cpac_options' );
185
-
186
- // old settings
187
- if ( ! empty( $old_settings['columns'] ) ) {
188
-
189
- foreach ( $old_settings['columns'] as $storage_key => $old_columns ){
190
-
191
- $columns = array();
192
-
193
- if ( $old_columns ) {
194
-
195
- // used to determine clone ID
196
- $tax_count = null;
197
- $post_count = null;
198
- $meta_count = null;
199
-
200
- foreach ( $old_columns as $old_column_name => $old_column_settings ) {
201
-
202
- // only active columns
203
- if ( isset( $old_column_settings['state'] ) && 'on' !== $old_column_settings['state'] )
204
- continue;
205
-
206
- // convert old settings to new
207
- $settings = array_merge( $old_column_settings, array(
208
- 'type' => $old_column_name,
209
- 'clone' => ''
210
- ) );
211
-
212
- // set name
213
- $name = $old_column_name;
214
-
215
- // convert: Users
216
- if ( 'wp-users' == $storage_key ) {
217
-
218
- // is user postcount?
219
- if ( strpos( $old_column_name, 'column-user_postcount-' ) !== false ) {
220
- $settings['type'] = 'column-user_postcount';
221
- $settings['clone'] = $post_count;
222
- $settings['post_type'] = str_replace( 'column-user_postcount-', '', $old_column_name );
223
-
224
- $name = $post_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
225
- $post_count++;
226
- }
227
- }
228
-
229
- // convert: Media
230
- elseif ( 'wp-media' == $storage_key ) {
231
-
232
- if ( 'column-filesize' == $old_column_name ) {
233
- $name = 'column-file_size';
234
- $settings['type'] = $name;
235
- }
236
- // is EXIF data?
237
- elseif ( strpos( $old_column_name, 'column-image-' ) !== false ) {
238
- $name = 'column-exif_data';
239
- $settings['type'] = $name;
240
- $settings['exif_datatype'] = str_replace( 'column-image-', '', $old_column_name );
241
- }
242
- elseif ( 'column-file_paths' == $old_column_name ) {
243
- $name = 'column-available_sizes';
244
- $settings['type'] = $name;
245
- }
246
- }
247
-
248
- // convert: Comments
249
- elseif ( 'wp-comments' == $storage_key ) {
250
-
251
- if ( 'column-author_author' == $old_column_name ) {
252
- $name = 'column-author';
253
- $settings['type'] = $name;
254
- }
255
- }
256
-
257
- // convert: Posts
258
- else {
259
-
260
- if ( 'column-attachment-count' == $old_column_name ) {
261
- $name = 'column-attachment_count';
262
- $settings['type'] = $name;
263
- }
264
- elseif ( 'column-author-name' == $old_column_name ) {
265
- $name = 'column-author_name';
266
- $settings['type'] = $name;
267
- $settings['display_author_as'] = $old_column_settings['display_as'];
268
- }
269
- elseif ( 'column-before-moretag' == $old_column_name ) {
270
- $name = 'column-before_moretag';
271
- $settings['type'] = $name;
272
- }
273
- elseif ( 'column-comment-count' == $old_column_name ) {
274
- $name = 'column-comment_count';
275
- $settings['type'] = $name;
276
- $settings['comment_status'] = 'total_comments';
277
- }
278
- elseif ( 'column-comment-status' == $old_column_name ) {
279
- $name = 'column-comment_status';
280
- $settings['type'] = $name;
281
- }
282
- elseif ( 'column-ping-status' == $old_column_name ) {
283
- $name = 'column-ping_status';
284
- $settings['type'] = $name;
285
- }
286
- elseif ( 'column-page-slug' == $old_column_name ) {
287
- $name = 'column-slug';
288
- $settings['type'] = $name;
289
- }
290
- elseif ( 'column-page-template' == $old_column_name ) {
291
- $name = 'column-page_template';
292
- $settings['type'] = $name;
293
- }
294
- }
295
-
296
- // convert: Applies to all storage types
297
-
298
- // is taxonomy?
299
- if ( strpos( $old_column_name, 'column-taxonomy-' ) !== false ) {
300
- $settings['type'] = 'column-taxonomy';
301
- $settings['clone'] = $tax_count;
302
- $settings['taxonomy'] = str_replace( 'column-taxonomy-', '', $old_column_name );
303
-
304
- $name = $tax_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
305
- $tax_count++;
306
- }
307
- // is custom field?
308
- elseif ( strpos( $old_column_name, 'column-meta-' ) !== false ) {
309
-
310
- $settings['type'] = 'column-meta';
311
- //$settings['clone'] = str_replace( 'column-meta-', '', $old_column_name );
312
- $settings['clone'] = $meta_count;
313
-
314
- $name = $meta_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
315
- $meta_count++;
316
- }
317
- elseif ( 'column-word-count' == $old_column_name ) {
318
- $name = 'column-word_count';
319
- $settings['type'] = $name;
320
- }
321
-
322
- // add to column set
323
- $columns[ $name ] = $settings;
324
-
325
- // reorder so that active column are at the top of the pile.
326
- $active = $inactive = array();
327
- foreach ( $columns as $name => $_settings ) {
328
- if ( 'on' === $_settings['state'] ) {
329
- $active[ $name ] = $_settings;
330
- }
331
- else {
332
- $inactive[ $name ] = $_settings;
333
- }
334
- }
335
- $columns = array_merge( $active, $inactive );
336
- }
337
-
338
- // store column settings
339
- if ( ! get_option( "cpac_options_{$storage_key}" ) ) {
340
- update_option( "cpac_options_{$storage_key}", $columns );
341
- }
342
- }
343
- }
344
- }
345
-
346
- // update version
347
- update_option( 'cpac_version', $version );
348
-
349
- $return = array(
350
- 'status' => true,
351
- 'message' => __( "Migrating Column Settings", 'codepress-admin-columns' ) . '...',
352
- 'next' => false,
353
- );
354
-
355
- break;
356
- }
357
-
358
- // return json
359
- echo json_encode( $return );
360
- die;
361
- }
362
-
363
- /*
364
- * Starting points of the upgrade process
365
- *
366
- * @since 2.0
367
- */
368
- public function start_upgrade() {
369
-
370
- $version = get_option( 'cpac_version', '1.0.0' );
371
- $next = false;
372
-
373
- // list of starting points
374
- if( $version < '2.0.0' ) {
375
- $next = '2.0.0';
376
- }
377
-
378
- // Run upgrade?
379
- if( $next ) : ?>
380
- <script type="text/javascript">
381
- run_upgrade("<?php echo $next; ?>");
382
- </script>
383
- <?php
384
-
385
- // No update required
386
- else : ?>
387
- <p><?php _e( 'No Upgrade Required', 'codepress-admin-columns' ); ?></p>
388
- <a href="<?php echo admin_url('options-general.php'); ?>?page=codepress-admin-columns&amp;info"><?php _e( 'Return to welcome screen.', 'codepress-admin-columns' ); ?></a>
389
- <?php
390
- endif;
391
- }
392
-
393
- /**
394
- * Scripts
395
- *
396
- * @since 2.0
397
- */
398
- public function admin_scripts() {
399
- wp_enqueue_script( 'cpac-upgrade', CPAC_URL . 'assets/js/upgrade.js', array( 'jquery' ), CPAC_VERSION );
400
-
401
- // CSS
402
- wp_enqueue_style( 'cpac-admin', CPAC_URL . 'assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
403
-
404
- // javascript translations
405
- wp_localize_script( 'cpac-upgrade', 'cpac_upgrade_i18n', array(
406
- 'complete' => __( 'Upgrade Complete!', 'codepress-admin-columns' ) . '</p><p><a href="' . admin_url('options-general.php') . '?page=codepress-admin-columns&info">' . __( 'Return to settings.', 'codepress-admin-columns' ) . "</a>" ,
407
- 'error' => __( 'Error', 'codepress-admin-columns' ),
408
- 'major_error' => __( 'Sorry. Something went wrong during the upgrade process. Please report this on the support forum.', 'codepress-admin-columns' )
409
- ));
410
- }
411
- }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Upgrade
9
+ *
10
+ * Class largely based on code from ACF ( props to Elliot )
11
+ *
12
+ * @since 2.0
13
+ */
14
+ class AC_Admin_Page_Upgrade extends AC_Admin_Page {
15
+
16
+ const VERSION_KEY = 'cpac_version';
17
+
18
+ public $update_prevented = false;
19
+
20
+ /**
21
+ * @since 2.0
22
+ */
23
+ function __construct() {
24
+ $this
25
+ ->set_slug( 'upgrade' )
26
+ ->set_label( __( 'Upgrade', 'codepress-admin-columns' ) )
27
+ ->set_show_in_menu( false );
28
+
29
+ add_action( 'wp_ajax_cpac_upgrade', array( $this, 'ajax_upgrade' ) );
30
+
31
+ if ( ! $this->allow_upgrade() ) {
32
+ add_action( 'ac/settings/after_menu', array( $this, 'proaddon_notice' ) );
33
+ }
34
+
35
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
36
+ }
37
+
38
+ /**
39
+ * Display a notice about the deprecated pro add-on
40
+ *
41
+ * @since 2.2
42
+ */
43
+ public function proaddon_notice() { ?>
44
+ <div class="message error">
45
+ <p>
46
+ <?php _e( 'The pro add-on is no longer supported. Please login to your account and download Admin Columns Pro', 'codepress-admin-columns' ); ?>
47
+ <a href="<?php echo ac_get_site_utm_url( 'pro-addon-information', 'pro-notice' ); ?>" target="_blank"><?php _e( 'Learn more', 'codepress-admin-columns' ); ?></a>
48
+ </p>
49
+ </div>
50
+ <?php
51
+ }
52
+
53
+ /**
54
+ * Whether upgrading is allowed
55
+ *
56
+ * @since 2.1.5
57
+ *
58
+ * @return bool Whether plugin upgrading is allowed
59
+ */
60
+ public function allow_upgrade() {
61
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
62
+
63
+ return ! is_plugin_active( 'cac-addon-pro/cac-addon-pro.php' );
64
+ }
65
+
66
+ /**
67
+ * Init Upgrade Process
68
+ *
69
+ * @since 2.0
70
+ */
71
+ public function ajax_upgrade() {
72
+
73
+ // vars
74
+ $return = array(
75
+ 'status' => false,
76
+ 'message' => "",
77
+ 'next' => false,
78
+ );
79
+
80
+ $version = $_POST['version'];
81
+
82
+ // versions
83
+ switch ( $version ) {
84
+
85
+ case '2.0.0' :
86
+
87
+ $old_settings = get_option( 'cpac_options' );
88
+
89
+ // old settings
90
+ if ( ! empty( $old_settings['columns'] ) ) {
91
+
92
+ foreach ( $old_settings['columns'] as $storage_key => $old_columns ) {
93
+
94
+ $columns = array();
95
+
96
+ if ( $old_columns ) {
97
+
98
+ // used to determine clone ID
99
+ $tax_count = null;
100
+ $post_count = null;
101
+ $meta_count = null;
102
+
103
+ foreach ( $old_columns as $old_column_name => $old_column_settings ) {
104
+
105
+ // only active columns
106
+ if ( isset( $old_column_settings['state'] ) && 'on' !== $old_column_settings['state'] ) {
107
+ continue;
108
+ }
109
+
110
+ // convert old settings to new
111
+ $settings = array_merge( $old_column_settings, array(
112
+ 'type' => $old_column_name,
113
+ 'clone' => '',
114
+ ) );
115
+
116
+ // set name
117
+ $name = $old_column_name;
118
+
119
+ // convert: Users
120
+ if ( 'wp-users' == $storage_key ) {
121
+
122
+ // is user post count?
123
+ if ( strpos( $old_column_name, 'column-user_postcount-' ) !== false ) {
124
+ $settings['type'] = 'column-user_postcount';
125
+ $settings['clone'] = $post_count;
126
+ $settings['post_type'] = str_replace( 'column-user_postcount-', '', $old_column_name );
127
+
128
+ $name = $post_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
129
+ $post_count++;
130
+ }
131
+ }
132
+
133
+ // convert: Media
134
+ elseif ( 'wp-media' == $storage_key ) {
135
+
136
+ if ( 'column-filesize' == $old_column_name ) {
137
+ $name = 'column-file_size';
138
+ $settings['type'] = $name;
139
+ }
140
+ // is EXIF data?
141
+ elseif ( strpos( $old_column_name, 'column-image-' ) !== false ) {
142
+ $name = 'column-exif_data';
143
+ $settings['type'] = $name;
144
+ $settings['exif_datatype'] = str_replace( 'column-image-', '', $old_column_name );
145
+ }
146
+ elseif ( 'column-file_paths' == $old_column_name ) {
147
+ $name = 'column-available_sizes';
148
+ $settings['type'] = $name;
149
+ }
150
+ }
151
+
152
+ // convert: Comments
153
+ elseif ( 'wp-comments' == $storage_key ) {
154
+
155
+ if ( 'column-author_author' == $old_column_name ) {
156
+ $name = 'column-author';
157
+ $settings['type'] = $name;
158
+ }
159
+ }
160
+
161
+ // convert: Posts
162
+ else {
163
+
164
+ if ( 'column-attachment-count' == $old_column_name ) {
165
+ $name = 'column-attachment_count';
166
+ $settings['type'] = $name;
167
+ }
168
+ elseif ( 'column-author-name' == $old_column_name ) {
169
+ $name = 'column-author_name';
170
+ $settings['type'] = $name;
171
+ $settings['display_author_as'] = $old_column_settings['display_as'];
172
+ }
173
+ elseif ( 'column-before-moretag' == $old_column_name ) {
174
+ $name = 'column-before_moretag';
175
+ $settings['type'] = $name;
176
+ }
177
+ elseif ( 'column-comment-count' == $old_column_name ) {
178
+ $name = 'column-comment_count';
179
+ $settings['type'] = $name;
180
+ $settings['comment_status'] = 'total_comments';
181
+ }
182
+ elseif ( 'column-comment-status' == $old_column_name ) {
183
+ $name = 'column-comment_status';
184
+ $settings['type'] = $name;
185
+ }
186
+ elseif ( 'column-ping-status' == $old_column_name ) {
187
+ $name = 'column-ping_status';
188
+ $settings['type'] = $name;
189
+ }
190
+ elseif ( 'column-page-slug' == $old_column_name ) {
191
+ $name = 'column-slug';
192
+ $settings['type'] = $name;
193
+ }
194
+ elseif ( 'column-page-template' == $old_column_name ) {
195
+ $name = 'column-page_template';
196
+ $settings['type'] = $name;
197
+ }
198
+ }
199
+
200
+ // convert: Applies to all storage types
201
+
202
+ // is taxonomy?
203
+ if ( strpos( $old_column_name, 'column-taxonomy-' ) !== false ) {
204
+ $settings['type'] = 'column-taxonomy';
205
+ $settings['clone'] = $tax_count;
206
+ $settings['taxonomy'] = str_replace( 'column-taxonomy-', '', $old_column_name );
207
+
208
+ $name = $tax_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
209
+ $tax_count++;
210
+ }
211
+ // is custom field?
212
+ elseif ( strpos( $old_column_name, 'column-meta-' ) !== false ) {
213
+
214
+ $settings['type'] = 'column-meta';
215
+ //$settings['clone'] = str_replace( 'column-meta-', '', $old_column_name );
216
+ $settings['clone'] = $meta_count;
217
+
218
+ $name = $meta_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
219
+ $meta_count++;
220
+ }
221
+ elseif ( 'column-word-count' == $old_column_name ) {
222
+ $name = 'column-word_count';
223
+ $settings['type'] = $name;
224
+ }
225
+
226
+ // add to column set
227
+ $columns[ $name ] = $settings;
228
+
229
+ // reorder so that active column are at the top of the pile.
230
+ $active = $inactive = array();
231
+ foreach ( $columns as $name => $_settings ) {
232
+ if ( 'on' === $_settings['state'] ) {
233
+ $active[ $name ] = $_settings;
234
+ }
235
+ else {
236
+ $inactive[ $name ] = $_settings;
237
+ }
238
+ }
239
+ $columns = array_merge( $active, $inactive );
240
+ }
241
+
242
+ // store column settings
243
+ if ( ! get_option( "cpac_options_{$storage_key}" ) ) {
244
+ update_option( "cpac_options_{$storage_key}", $columns );
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ // update version
251
+ update_option( self::VERSION_KEY, $version );
252
+
253
+ $return = array(
254
+ 'status' => true,
255
+ 'message' => __( "Migrating Column Settings", 'codepress-admin-columns' ) . '...',
256
+ 'next' => false,
257
+ );
258
+
259
+ break;
260
+ }
261
+
262
+ // return json
263
+ echo json_encode( $return );
264
+ die;
265
+ }
266
+
267
+ /*
268
+ * Starting points of the upgrade process
269
+ *
270
+ * @since 2.0
271
+ */
272
+ public function start_upgrade() {
273
+
274
+ $version = get_option( self::VERSION_KEY, '1.0.0' );
275
+ $next = false;
276
+
277
+ // list of starting points
278
+ if ( $version < '2.0.0' ) {
279
+ $next = '2.0.0';
280
+ }
281
+
282
+ // Run upgrade?
283
+ if ( $next ) : ?>
284
+ <script type="text/javascript">
285
+ run_upgrade( "<?php echo $next; ?>" );
286
+ </script>
287
+ <?php
288
+
289
+ // No update required
290
+ else : ?>
291
+ <p><?php _e( 'No Upgrade Required', 'codepress-admin-columns' ); ?></p>
292
+ <?php echo ac_helper()->html->link( AC()->admin()->get_link( 'welcome' ), __( 'Return to welcome screen.', 'codepress-admin-columns' ) );
293
+ endif;
294
+ }
295
+
296
+ /**
297
+ * Scripts
298
+ *
299
+ * @since 2.0
300
+ */
301
+ public function admin_scripts() {
302
+ if ( ! $this->is_current_screen() ) {
303
+ return;
304
+ }
305
+
306
+ wp_enqueue_script( 'ac-upgrade', AC()->get_plugin_url() . 'assets/js/upgrade.js', array( 'jquery' ), AC()->get_version() );
307
+ wp_localize_script( 'ac-upgrade', 'cpac_upgrade_i18n', array(
308
+ 'complete' => __( 'Upgrade Complete!', 'codepress-admin-columns' ) . '</p><p><a href="' . esc_url( AC()->admin()->get_link( 'welcome' ) ) . '">' . __( 'Return to settings.', 'codepress-admin-columns' ) . "</a>",
309
+ 'error' => __( 'Error', 'codepress-admin-columns' ),
310
+ 'major_error' => __( 'Sorry. Something went wrong during the upgrade process. Please report this on the support forum.', 'codepress-admin-columns' ),
311
+ ) );
312
+ }
313
+
314
+ /**
315
+ * @since 2.0
316
+ */
317
+ public function display() {
318
+ ?>
319
+ <h1><?php _e( 'Upgrade', 'codepress-admin-columns' ); ?></h1>
320
+ <?php
321
+
322
+ $version = get_option( self::VERSION_KEY, false );
323
+
324
+ // Maybe version pre 2.0.0 was used
325
+ if ( ! $version && get_option( 'cpac_options' ) ) {
326
+ $version = '1.0.0';
327
+ }
328
+
329
+ // Maybe upgrade?
330
+ if ( $version ) {
331
+
332
+ // run every upgrade
333
+ if ( $version < AC()->get_version() ) {
334
+ // nothing yet
335
+ }
336
+
337
+ // run only when updating from v1 to v2
338
+ if ( $version < '2.0.0' ) {
339
+
340
+ // show welcome screen
341
+ wp_safe_redirect( AC()->admin()->get_link( 'welcome' ) );
342
+ exit;
343
+ }
344
+
345
+ // run only when database upgrade is needed
346
+ if ( $version < AC()->get_upgrade_version() ) {
347
+
348
+ // display upgrade message on every page except upgrade page itself
349
+ if ( ! ( isset( $_REQUEST['page'] ) && 'upgrade' === $_REQUEST['page'] ) ) {
350
+
351
+ $message = sprintf( "Admin Columns %s requires a database upgrade.", AC()->get_version() );
352
+ $message .= sprintf( "Please %s, then click %s.", ac_helper()->html->link( 'http://codex.wordpress.org/Backing_Up_Your_Database', 'backup your database' ), ac_helper()->html->link( $this->get_link(), 'Upgrade Database' ) );
353
+
354
+ AC()->notice( $message, 'updated' );
355
+ }
356
+ }
357
+
358
+ // run when NO upgrade is needed
359
+ elseif ( $version < AC()->get_version() ) {
360
+
361
+ update_option( self::VERSION_KEY, AC()->get_version() );
362
+ }
363
+ }
364
+
365
+ // Fresh install
366
+ else {
367
+
368
+ update_option( self::VERSION_KEY, AC()->get_version() );
369
+ }
370
+ }
371
+
372
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/Admin/Page/Welcome.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Page_Welcome extends AC_Admin_Page {
8
+
9
+ public function __construct() {
10
+ $this
11
+ ->set_slug( 'welcome' )
12
+ ->set_label( __( 'Welcome', 'codepress-admin-columns' ) )
13
+ ->set_show_in_menu( false );
14
+ }
15
+
16
+ private function get_sub_tabs() {
17
+ return array(
18
+ '' => 'Welcome',
19
+ 'changelog' => 'Changelog',
20
+ );
21
+ }
22
+
23
+ private function get_current_tab() {
24
+ return filter_input( INPUT_GET, 'sub_tab' );
25
+ }
26
+
27
+ private function display_changelog() {
28
+ ?>
29
+ <h3><?php echo __( "Changelog for", 'codepress-admin-columns' ) . ' ' . AC()->get_version(); ?></h3>
30
+ <?php
31
+
32
+ $items = file_get_contents( AC()->get_plugin_dir() . 'readme.txt' );
33
+ $items = explode( '= ' . AC()->get_version() . ' =', $items );
34
+ $items = end( $items );
35
+ $items = explode( "\n\n", $items );
36
+
37
+ $changelog = false;
38
+ foreach ( $items as $item ) {
39
+ if ( 0 === strpos( $item, '*' ) ) {
40
+ $changelog = $item;
41
+ break;
42
+ }
43
+ }
44
+
45
+ $items = array_filter( array_map( 'trim', explode( "*", $changelog ) ) );
46
+ ?>
47
+ <ul class="cpac-changelog">
48
+ <?php echo implode( '<br/>', $items ); ?>
49
+ </ul>
50
+ <?php
51
+ }
52
+
53
+ public function display() {
54
+ ?>
55
+
56
+ <div id="cpac-welcome" class="wrap about-wrap">
57
+
58
+ <h1><?php echo __( "Welcome to Admin Columns", 'codepress-admin-columns' ) . ' ' . AC()->get_version(); ?></h1>
59
+
60
+ <div class="about-text">
61
+ <?php _e( "Thank you for updating to the latest version!", 'codepress-admin-columns' ); ?>
62
+ <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'codepress-admin-columns' ); ?>
63
+ </div>
64
+
65
+ <div class="cpac-content-body">
66
+ <h2 class="nav-tab-wrapper">
67
+ <?php foreach ( $this->get_sub_tabs() as $slug => $label ) {
68
+ echo ac_helper()->html->link( add_query_arg( array( 'sub_tab' => $slug ), $this->get_link() ), $label, array( 'class' => 'cpac-tab-toggle nav-tab' . ( $this->get_current_tab() == $slug ? ' nav-tab-active' : '' ) ) );
69
+ } ?>
70
+
71
+ </h2>
72
+
73
+ <?php switch ( $this->get_current_tab() ) {
74
+
75
+ case 'changelog' :
76
+ $this->display_changelog();
77
+ break;
78
+
79
+ default :
80
+ ?>
81
+ <h3>Changes</h3>
82
+ <p>*</p>
83
+ <?php
84
+ }
85
+ ?>
86
+
87
+ </div>
88
+
89
+ <div class="cpac-content-footer">
90
+ <a class="button-primary button-large" href="<?php echo esc_url( AC()->admin_columns_screen()->get_link() ); ?>"><?php _e( "Start using Admin Columns", 'codepress-admin-columns' ); ?></a>
91
+ </div>
92
+
93
+ </div>
94
+ <?php
95
+ }
96
+
97
+ }
classes/Admin/Pages.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ final class AC_Admin_Pages {
8
+
9
+ /**
10
+ * @var AC_Admin_Page[]
11
+ */
12
+ private $pages;
13
+
14
+ /**
15
+ * Reference that points to default tab
16
+ *
17
+ * @var string
18
+ */
19
+ private $default_slug;
20
+
21
+ public function __construct() {
22
+ $this->pages = array();
23
+ }
24
+
25
+ /**
26
+ * @param AC_Admin_Page $page
27
+ *
28
+ * @return AC_Admin_Pages
29
+ */
30
+ public function register_page( AC_Admin_Page $page ) {
31
+ $this->pages[ $page->get_slug() ] = $page;
32
+
33
+ if ( $page->is_default() ) {
34
+ $this->default_slug = $page->get_slug();
35
+ }
36
+
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * @param $slug
42
+ *
43
+ * @return AC_Admin_Page|false
44
+ */
45
+ public function get_page( $slug ) {
46
+ $page = false;
47
+
48
+ if ( isset( $this->pages[ $slug ] ) ) {
49
+ $page = $this->pages[ $slug ];
50
+ }
51
+
52
+ return $page;
53
+ }
54
+
55
+ /**
56
+ * @return AC_Admin_Page|false
57
+ */
58
+ public function get_current_page() {
59
+ $page = $this->get_page( filter_input( INPUT_GET, 'tab' ) );
60
+
61
+ if ( ! $page ) {
62
+ $page = $this->get_page( $this->default_slug );
63
+ }
64
+
65
+ return $page;
66
+ }
67
+
68
+ public function display() { ?>
69
+ <div id="cpac" class="wrap">
70
+ <h1 class="nav-tab-wrapper cpac-nav-tab-wrapper">
71
+ <?php
72
+
73
+ $active_page = $this->get_current_page();
74
+
75
+ foreach ( $this->pages as $slug => $page ) {
76
+ if ( $page->show_in_menu() ) {
77
+ $active = $slug === $active_page->get_slug() ? ' nav-tab-active' : '';
78
+
79
+ echo ac_helper()->html->link( AC()->admin()->get_link( $slug ), $page->get_label(), array( 'class' => 'nav-tab ' . $active ) );
80
+ }
81
+ }
82
+
83
+ ?>
84
+ </h1>
85
+
86
+ <?php
87
+
88
+ do_action( 'ac/settings/after_menu' );
89
+
90
+ $active_page->display();
91
+
92
+ ?>
93
+ </div>
94
+
95
+ <?php
96
+ }
97
+
98
+ }
classes/Admin/Promo.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Admin_Promo {
8
+
9
+ /**
10
+ * @var array
11
+ */
12
+ private $date_ranges;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $title;
18
+
19
+ /**
20
+ * @var int
21
+ */
22
+ private $discount;
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ private $url;
28
+
29
+ /**
30
+ * @return string
31
+ */
32
+ public function get_title() {
33
+ return $this->title;
34
+ }
35
+
36
+ /**
37
+ * @param string $title
38
+ */
39
+ public function set_title( $title ) {
40
+ $this->title = $title;
41
+ }
42
+
43
+ /**
44
+ * @return int
45
+ */
46
+ public function get_discount() {
47
+ return $this->discount;
48
+ }
49
+
50
+ /**
51
+ * @param int $discount
52
+ */
53
+ public function set_discount( $discount ) {
54
+ $this->discount = $discount;
55
+ }
56
+
57
+ /**
58
+ * @return int
59
+ */
60
+ public function get_url() {
61
+ if ( null === $this->url ) {
62
+
63
+ $campaign = str_replace( get_parent_class( $this ) . '_', '', get_class( $this ) );
64
+
65
+ $this->set_url( ac_get_site_utm_url( 'pricing-purchase', 'promo', null, $campaign ) );
66
+ }
67
+
68
+ return $this->url;
69
+ }
70
+
71
+ /**
72
+ * @param int $url
73
+ */
74
+ public function set_url( $url ) {
75
+ $this->url = $url;
76
+ }
77
+
78
+ /**
79
+ * @param string $start_date
80
+ * @param string $end_date
81
+ */
82
+ public function add_date_range( $start_date, $end_date ) {
83
+ if ( ! $start_date || ! $end_date ) {
84
+ return;
85
+ }
86
+
87
+ $this->date_ranges[] = array(
88
+ 'start' => $start_date,
89
+ 'end' => $end_date,
90
+ );
91
+ }
92
+
93
+ /**
94
+ * @return bool True when promo is active
95
+ */
96
+ public function is_active() {
97
+ return $this->get_active_date_range() ? true : false;
98
+ }
99
+
100
+ /**
101
+ * Active date range
102
+ *
103
+ * @return array|false
104
+ */
105
+ private function get_active_date_range() {
106
+ $today = date( 'Y-m-d' );
107
+
108
+ foreach ( $this->date_ranges as $date_range ) {
109
+ if ( $today >= $date_range['start'] && $today <= $date_range['end'] ) {
110
+ return $date_range;
111
+ }
112
+ }
113
+
114
+ return false;
115
+ }
116
+
117
+ /**
118
+ * @return bool|string
119
+ */
120
+ public function end_date() {
121
+ $date_range = $this->get_active_date_range();
122
+
123
+ return $date_range ? date_i18n( get_option( 'date_format' ), strtotime( $date_range['end'] ) ) : false;
124
+ }
125
+
126
+ /**
127
+ * Render HTML
128
+ */
129
+ public function display() { ?>
130
+ <h3>
131
+ <?php echo esc_html( $this->get_title() ); ?>
132
+ </h3>
133
+ <a target="_blank" href="<?php echo esc_url( $this->get_url() ); ?>" class="acp-button">
134
+ <?php echo esc_html( sprintf( __( 'Get %s Off', 'codepress-admin-columns' ), $this->get_discount() . '%' ) ); ?>
135
+ </a>
136
+ <p class="nomargin">
137
+ <?php echo esc_html( sprintf( __( "Discount is valid until %s", 'codepress-admin-columns' ), $this->end_date() ) ); ?>
138
+ </p>
139
+ <?php
140
+ }
141
+
142
+ }
classes/Admin/Promo/BlackFriday.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Promo_BlackFriday extends AC_Admin_Promo {
8
+
9
+ public function __construct() {
10
+
11
+ $this->set_title( '30% Off from Black Friday until Cyber Monday' );
12
+ $this->set_discount( 30 );
13
+
14
+ // 2016
15
+ $this->add_date_range( '2016-11-25','2016-11-29' );
16
+
17
+ // 2017
18
+ $this->add_date_range( '2017-11-24','2017-11-28' );
19
+ }
20
+
21
+ }
classes/Autoloader.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Autoloader {
8
+
9
+ /**
10
+ * @var AC_Autoloader;
11
+ */
12
+ protected static $instance;
13
+
14
+ /**
15
+ * Register prefixes and their path
16
+ *
17
+ * @var array
18
+ */
19
+ protected $prefixes = array();
20
+
21
+ private function __construct() {
22
+ spl_autoload_register( array( $this, 'autoload' ) );
23
+ }
24
+
25
+ public static function instance() {
26
+ if ( null === self::$instance ) {
27
+ self::$instance = new self();
28
+ }
29
+
30
+ return self::$instance;
31
+ }
32
+
33
+ public static function string_to_classname( $string ) {
34
+ return implode( array_map( 'ucfirst', explode( '_', str_replace( '-', '_', $string ) ) ) );
35
+ }
36
+
37
+ /**
38
+ * Register a prefix that should autoload
39
+ *
40
+ * @param $prefix string Unique prefix to this set of classes
41
+ * @param $path string Path to directory where classes are stored
42
+ */
43
+ public function register_prefix( $prefix, $path ) {
44
+ $prefix = rtrim( $prefix, '_' ) . '_';
45
+ $path = trailingslashit( $path );
46
+
47
+ $this->prefixes[ $prefix ] = $path;
48
+
49
+ // make sure that more specific prefixes are checked first
50
+ krsort( $this->prefixes );
51
+ }
52
+
53
+ /**
54
+ * @param $class
55
+ */
56
+ public function autoload( $class ) {
57
+ foreach ( $this->prefixes as $prefix => $path ) {
58
+ if ( 0 !== strpos( $class, $prefix ) ) {
59
+ continue;
60
+ }
61
+
62
+ $file = $path . str_replace( array( $prefix, '_' ), array( '', '/' ), $class ) . '.php';
63
+
64
+ if ( is_readable( $file ) ) {
65
+ require_once $file;
66
+
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ /**
73
+ * @param string $prefix
74
+ *
75
+ * @return false|string
76
+ */
77
+ private function get_path_by_prefix( $prefix ) {
78
+ return isset( $this->prefixes[ $prefix ] ) ? $this->prefixes[ $prefix ] : false;
79
+ }
80
+
81
+ /**
82
+ * Get list of all class names from a directory
83
+ *
84
+ * @param string $dir
85
+ * @param string $prefix
86
+ *
87
+ * @return array Class names
88
+ */
89
+ public function get_class_names_from_dir( $dir, $prefix ) {
90
+ $path = trailingslashit( $dir );
91
+ $classes_dir = $this->get_path_by_prefix( $prefix );
92
+
93
+ // skip if directory is not auto loaded
94
+ if ( false === strpos( $path, $classes_dir ) ) {
95
+ return array();
96
+ }
97
+
98
+ $class_names = array();
99
+
100
+ $prefix = $prefix . str_replace( array( $classes_dir, '/' ), array( '', '_' ), untrailingslashit( $path ) ) . '_';
101
+
102
+ if ( is_dir( $dir ) ) {
103
+ $iterator = new DirectoryIterator( $dir );
104
+
105
+ foreach ( $iterator as $leaf ) {
106
+ // skip non php files
107
+ if ( $leaf->isDot() || $leaf->isDir() || 'php' !== pathinfo( $leaf->getFilename(), PATHINFO_EXTENSION ) ) {
108
+ continue;
109
+ }
110
+
111
+ $class_name = $prefix . str_replace( '.php', '', $leaf->getFilename() );
112
+
113
+ $r = new ReflectionClass( $class_name );
114
+
115
+ if ( $r->isInstantiable() ) {
116
+ $class_names[] = $class_name;
117
+ }
118
+ }
119
+ }
120
+
121
+ return $class_names;
122
+ }
123
+
124
+ }
classes/Collection.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Class AC_Collection
9
+ *
10
+ * Used to hold values from the same type
11
+ */
12
+ class AC_Collection
13
+ implements Iterator {
14
+
15
+ /**
16
+ * @var array
17
+ */
18
+ protected $items;
19
+
20
+ public function __construct( array $items = array() ) {
21
+ $this->items = $items;
22
+ }
23
+
24
+ public function all() {
25
+ return $this->items;
26
+ }
27
+
28
+ public function has( $key ) {
29
+ return isset( $this->items[ $key ] );
30
+ }
31
+
32
+ public function put( $key, $value ) {
33
+ $this->items[ $key ] = $value;
34
+
35
+ return $this;
36
+ }
37
+
38
+ public function push( $value ) {
39
+ $this->items[] = $value;
40
+ }
41
+
42
+ public function get( $key, $default = null ) {
43
+ if ( $this->has( $key ) ) {
44
+ return $this->items[ $key ];
45
+ }
46
+
47
+ return $default;
48
+ }
49
+
50
+ public function __get( $key ) {
51
+ return $this->get( $key );
52
+ }
53
+
54
+ public function rewind() {
55
+ reset( $this->items );
56
+ }
57
+
58
+ public function current() {
59
+ return current( $this->items );
60
+ }
61
+
62
+ public function key() {
63
+ return key( $this->items );
64
+ }
65
+
66
+ public function next() {
67
+ return next( $this->items );
68
+ }
69
+
70
+ public function valid() {
71
+ $key = $this->key();
72
+
73
+ return ( $key !== null && $key !== false );
74
+ }
75
+
76
+ /**
77
+ * Filter collection items
78
+ *
79
+ * @return AC_Collection
80
+ */
81
+ public function filter() {
82
+ return new AC_Collection( ac_helper()->array->filter( $this->items ) );
83
+ }
84
+
85
+ /**
86
+ * @param string $glue
87
+ *
88
+ * @return string
89
+ */
90
+ public function implode( $glue = '' ) {
91
+ return implode( $glue, $this->items );
92
+ }
93
+
94
+ }
classes/Column.php ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column {
11
+
12
+ /**
13
+ * @var string Unique Name
14
+ */
15
+ private $name;
16
+
17
+ /**
18
+ * @var string Unique type
19
+ */
20
+ private $type;
21
+
22
+ /**
23
+ * @var string Label which describes this column
24
+ */
25
+ private $label;
26
+
27
+ /**
28
+ * @var string Group name
29
+ */
30
+ private $group;
31
+
32
+ /**
33
+ * @var bool An original column will use the already defined column value and label.
34
+ */
35
+ private $original = false;
36
+
37
+ /**
38
+ * @var AC_Settings_Column[]
39
+ */
40
+ private $settings;
41
+
42
+ /**
43
+ * @var AC_Settings_FormatValueInterface[]|AC_Settings_FormatCollectionInterface[]
44
+ */
45
+ private $formatters;
46
+
47
+ /**
48
+ * @var AC_ListScreen
49
+ */
50
+ protected $list_screen;
51
+
52
+ /**
53
+ * The options managed by the settings
54
+ *
55
+ * @var array
56
+ */
57
+ protected $options = array();
58
+
59
+ /**
60
+ * @var string|bool
61
+ */
62
+ private $empty_char;
63
+
64
+ /**
65
+ * Get the unique name of the column
66
+ *
67
+ * @since 2.3.4
68
+ * @return string Column name
69
+ */
70
+ public function get_name() {
71
+ return $this->name;
72
+ }
73
+
74
+ /**
75
+ * @param string $name
76
+ *
77
+ * @return $this
78
+ */
79
+ public function set_name( $name ) {
80
+ $this->name = $name;
81
+
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Get the type of the column.
87
+ *
88
+ * @since 2.3.4
89
+ * @return string Type
90
+ */
91
+ public function get_type() {
92
+ return $this->type;
93
+ }
94
+
95
+ /**
96
+ * @param string $type
97
+ *
98
+ * @return $this
99
+ */
100
+ public function set_type( $type ) {
101
+ $this->type = $type;
102
+
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * @return AC_ListScreen
108
+ */
109
+ public function get_list_screen() {
110
+ return $this->list_screen;
111
+ }
112
+
113
+ /**
114
+ * @param AC_ListScreen $list_screen
115
+ *
116
+ * @return $this
117
+ */
118
+ public function set_list_screen( AC_ListScreen $list_screen ) {
119
+ $this->list_screen = $list_screen;
120
+
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Get the type of the column.
126
+ *
127
+ * @since 2.4.9
128
+ * @return string Label of column's type
129
+ */
130
+ public function get_label() {
131
+ if ( null === $this->label ) {
132
+ $this->set_label( $this->get_list_screen()->get_original_label( $this->get_type() ) );
133
+ }
134
+
135
+ return $this->label;
136
+ }
137
+
138
+ /**
139
+ * @param string $label
140
+ *
141
+ * @return $this
142
+ */
143
+ public function set_label( $label ) {
144
+ $this->label = $label;
145
+
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * @since 3.0
151
+ * @return string Group
152
+ */
153
+ public function get_group() {
154
+ if ( null === $this->group ) {
155
+ $this->set_group( 'custom' );
156
+
157
+ if ( $this->is_original() ) {
158
+ $this->set_group( 'default' );
159
+ }
160
+ }
161
+
162
+ return $this->group;
163
+ }
164
+
165
+ /**
166
+ * @param string $group Group label
167
+ *
168
+ * @return $this
169
+ */
170
+ public function set_group( $group ) {
171
+ $this->group = $group;
172
+
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * @return string Post type
178
+ */
179
+ public function get_post_type() {
180
+ return method_exists( $this->list_screen, 'get_post_type' ) ? $this->list_screen->get_post_type() : false;
181
+ }
182
+
183
+ /**
184
+ * @return string Taxonomy
185
+ */
186
+ public function get_taxonomy() {
187
+ return method_exists( $this->list_screen, 'get_taxonomy' ) ? $this->list_screen->get_taxonomy() : false;
188
+ }
189
+
190
+ /**
191
+ * Return true when a default column has been replaced by a custom column.
192
+ * An original column will then use the original label and value.
193
+ *
194
+ * @since 3.0
195
+ */
196
+ public function is_original() {
197
+ return $this->original;
198
+ }
199
+
200
+ /**
201
+ * @param bool $boolean
202
+ *
203
+ * @return $this
204
+ */
205
+ public function set_original( $boolean ) {
206
+ $this->original = (bool) $boolean;
207
+
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * Overwrite this function in child class.
213
+ * Determine whether this column type should be available
214
+ *
215
+ * @since 2.2
216
+ *
217
+ * @return bool Whether the column type should be available
218
+ */
219
+ public function is_valid() {
220
+ return true;
221
+ }
222
+
223
+ /**
224
+ * @param AC_Settings_Column $setting
225
+ *
226
+ * @return $this
227
+ */
228
+ public function add_setting( AC_Settings_Column $setting ) {
229
+ $setting->set_values( $this->options );
230
+
231
+ $this->settings[ $setting->get_name() ] = $setting;
232
+
233
+ foreach ( (array) $setting->get_dependent_settings() as $dependent_setting ) {
234
+ $this->add_setting( $dependent_setting );
235
+ }
236
+
237
+ return $this;
238
+ }
239
+
240
+ /**
241
+ * @param string $id Settings ID
242
+ */
243
+ public function remove_setting( $id ) {
244
+ if ( isset( $this->settings[ $id ] ) ) {
245
+ unset( $this->settings[ $id ] );
246
+ }
247
+ }
248
+
249
+ /**
250
+ * @param string $id
251
+ *
252
+ * @return AC_Settings_Column|AC_Settings_Column_User|AC_Settings_Column_Separator|AC_Settings_Column_Label
253
+ */
254
+ public function get_setting( $id ) {
255
+ return $this->get_settings()->get( $id );
256
+ }
257
+
258
+ public function get_formatters() {
259
+ if ( null === $this->formatters ) {
260
+ foreach ( $this->get_settings() as $setting ) {
261
+ if ( $setting instanceof AC_Settings_FormatValueInterface || $setting instanceof AC_Settings_FormatCollectionInterface ) {
262
+ $this->formatters[] = $setting;
263
+ }
264
+ }
265
+ }
266
+
267
+ return $this->formatters;
268
+ }
269
+
270
+ /**
271
+ * @return AC_Collection
272
+ */
273
+ public function get_settings() {
274
+ if ( null === $this->settings ) {
275
+ $settings = array(
276
+ new AC_Settings_Column_Type( $this ),
277
+ new AC_Settings_Column_Label( $this ),
278
+ new AC_Settings_Column_Width( $this ),
279
+ );
280
+
281
+ foreach ( $settings as $setting ) {
282
+ $this->add_setting( $setting );
283
+ }
284
+
285
+ $this->register_settings();
286
+
287
+ do_action( 'ac/column/settings', $this );
288
+ }
289
+
290
+ return new AC_Collection( $this->settings );
291
+ }
292
+
293
+ /**
294
+ * Register settings
295
+ */
296
+ protected function register_settings() {
297
+ // Overwrite in child class
298
+ }
299
+
300
+ /**
301
+ * @param string $key
302
+ *
303
+ * @return null|string|bool
304
+ */
305
+ public function get_option( $key ) {
306
+ $options = $this->get_options();
307
+
308
+ return isset( $options[ $key ] ) ? $options[ $key ] : null;
309
+ }
310
+
311
+ /**
312
+ * @param array $options
313
+ *
314
+ * @return $this
315
+ */
316
+ public function set_options( array $options ) {
317
+ $this->options = $options;
318
+
319
+ return $this;
320
+ }
321
+
322
+ /**
323
+ * Get the current options
324
+ *
325
+ * @return array
326
+ */
327
+ public function get_options() {
328
+ return $this->options;
329
+ }
330
+
331
+ /**
332
+ * Enqueue CSS + JavaScript on the admin listings screen!
333
+ *
334
+ * This action is called in the admin_head action on the listings screen where your column values are displayed.
335
+ * Use this action to add CSS + JavaScript
336
+ *
337
+ * @since 3.3.4
338
+ */
339
+ public function scripts() {
340
+ // Overwrite in child class
341
+ }
342
+
343
+ /**
344
+ * Apply available formatters (recursive) on the value
345
+ *
346
+ * @param mixed $value
347
+ * @param mixed $original_value
348
+ * @param int $current Current index of self::$formatters
349
+ *
350
+ * @return mixed
351
+ */
352
+ public function get_formatted_value( $value, $original_value = null, $current = 0 ) {
353
+ $formatters = $this->get_formatters();
354
+ $available = count( $formatters );
355
+
356
+ if ( null === $original_value ) {
357
+ $original_value = $value;
358
+ }
359
+
360
+ if ( $available > $current ) {
361
+ $is_collection = $value instanceof AC_Collection;
362
+ $is_value_formatter = $formatters[ $current ] instanceof AC_Settings_FormatValueInterface;
363
+
364
+ if ( $is_collection && $is_value_formatter ) {
365
+ foreach ( $value as $k => $v ) {
366
+ $value->put( $k, $this->get_formatted_value( $v, null, $current ) );
367
+ }
368
+
369
+ while ( $available > $current ) {
370
+ if ( $formatters[ $current ] instanceof AC_Settings_FormatCollectionInterface ) {
371
+ return $this->get_formatted_value( $value, $original_value, $current );
372
+ }
373
+
374
+ ++$current;
375
+ }
376
+ } elseif ( ( $is_collection && ! $is_value_formatter ) || $is_value_formatter ) {
377
+ $value = $formatters[ $current ]->format( $value, $original_value );
378
+
379
+ return $this->get_formatted_value( $value, $original_value, ++$current );
380
+ }
381
+ }
382
+
383
+ return $value;
384
+ }
385
+
386
+ /**
387
+ * Get the raw, underlying value for the column
388
+ * Not suitable for direct display, use get_value() for that
389
+ *
390
+ * @since 2.0.3
391
+ *
392
+ * @param int $id
393
+ *
394
+ * @return string|array
395
+ */
396
+ public function get_raw_value( $id ) {
397
+ return null;
398
+ }
399
+
400
+ /**
401
+ * Display value
402
+ *
403
+ * @param int $id
404
+ *
405
+ * @return int|string
406
+ */
407
+ public function get_value( $id ) {
408
+ $value = $this->get_formatted_value( $this->get_raw_value( $id ), $id );
409
+
410
+ if ( $value instanceof AC_Collection ) {
411
+ $value = $value->filter()->implode( $this->get_separator() );
412
+ }
413
+
414
+ if ( ! $value && ! $this->is_original() ) {
415
+ $value = $this->get_empty_char();
416
+ }
417
+
418
+ return (string) $value;
419
+ }
420
+
421
+ /**
422
+ * @return string
423
+ */
424
+ public function get_separator() {
425
+ return ', ';
426
+ }
427
+
428
+ /**
429
+ * @param string
430
+ */
431
+ public function set_empty_char( $char ) {
432
+ $this->empty_char = (string) $char;
433
+ }
434
+
435
+ /**
436
+ * @return bool|string
437
+ */
438
+ public function get_empty_char() {
439
+ if ( null === $this->empty_char ) {
440
+ $this->set_empty_char( '&ndash;' );
441
+ }
442
+
443
+ return apply_filters( 'ac/empty_char', $this->empty_char, $this );
444
+ }
445
+
446
+ }
classes/Column/ActionColumnHelper.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Holds all the row actions buttons for each content type (e.g. post, comment, user and media).
9
+ * WP_List_Table does not have a method for retrieving row actions. This class uses their filters to fetch the actions.
10
+ * For example usage see the AC_Column_Actions class.
11
+ *
12
+ * Class AC_Column_ActionColumnHelper
13
+ */
14
+ class AC_Column_ActionColumnHelper {
15
+
16
+ private $actions;
17
+
18
+ /**
19
+ * @since 2.5
20
+ */
21
+ private static $_instance = null;
22
+
23
+ /**
24
+ * @since 2.5
25
+ */
26
+ public static function instance() {
27
+ if ( null === self::$_instance ) {
28
+ self::$_instance = new self();
29
+ }
30
+
31
+ return self::$_instance;
32
+ }
33
+
34
+ private function __construct() {
35
+ add_filter( 'comment_row_actions', array( $this, 'set_comment' ), 10, 2 );
36
+ add_filter( 'page_row_actions', array( $this, 'set_post' ), 10, 2 );
37
+ add_filter( 'post_row_actions', array( $this, 'set_post' ), 10, 2 );
38
+ add_filter( 'media_row_actions', array( $this, 'set_media' ), 10, 2 );
39
+ add_filter( 'user_row_actions', array( $this, 'set_user' ), 10, 2 );
40
+ }
41
+
42
+ public function set_comment( $actions, $comment ) {
43
+ $this->actions[ 'comment' ][ $comment->ID ] = $actions;
44
+
45
+ return $actions;
46
+ }
47
+
48
+ public function set_post( $actions, $post ) {
49
+ $this->actions[ 'post' ][ $post->ID ] = $actions;
50
+
51
+ return $actions;
52
+ }
53
+
54
+ public function set_media( $actions, $post ) {
55
+ $this->actions[ 'media' ][ $post->ID ] = $actions;
56
+
57
+ return $actions;
58
+ }
59
+
60
+ public function set_user( $actions, $user ) {
61
+ $this->actions[ 'user' ][ $user->ID ] = $actions;
62
+
63
+ return $actions;
64
+ }
65
+
66
+ /**
67
+ * Retrieve row actions like 'edit, trash, spam' etc.
68
+ *
69
+ * @param string $type
70
+ * @param int $id Object ID
71
+ *
72
+ * @return array|false Array with actions
73
+ */
74
+ public function get( $type, $id ) {
75
+ return isset( $this->actions[ $type ][ $id ] ) ? $this->actions[ $type ][ $id ] : array();
76
+ }
77
+
78
+ }
classes/Column/Actions.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Base class for columns containing action links for items.
9
+ *
10
+ * @since 2.2.6
11
+ */
12
+ abstract class AC_Column_Actions extends AC_Column {
13
+
14
+ /**
15
+ * Get a list of action links for an item (e.g. post) ID.
16
+ *
17
+ * @since 2.2.6
18
+ *
19
+ * @param int $id Item ID to get the list of actions for.
20
+ *
21
+ * @return array List of actions ([action name] => [action link]).
22
+ */
23
+ abstract protected function get_object_type();
24
+
25
+ /**
26
+ * @since 2.2.6
27
+ */
28
+ public function __construct() {
29
+ $this->set_type( 'column-actions' );
30
+ $this->set_label( __( 'Actions', 'codepress-admin-columns' ) );
31
+ }
32
+
33
+ /**
34
+ * @since 2.2.6
35
+ */
36
+ public function get_value( $id ) {
37
+ if ( $this->get_option( 'use_icons' ) ) {
38
+ return '<span class="cpac_use_icons"></span>';
39
+ }
40
+
41
+ return '';
42
+ }
43
+
44
+ public function register_settings() {
45
+ $this->add_setting( new AC_Settings_Column_ActionIcons( $this ) );
46
+ }
47
+
48
+ }
classes/Column/AjaxValue.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ interface AC_Column_AjaxValue {
8
+
9
+ /**
10
+ * @param int $id
11
+ *
12
+ * @return void
13
+ */
14
+ public function get_ajax_value( $id );
15
+
16
+ }
classes/Column/Comment/Actions.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Actions extends AC_Column_Actions {
11
+
12
+ protected function get_object_type() {
13
+ return 'comment';
14
+ }
15
+
16
+ }
classes/Column/Comment/Agent.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Agent extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-agent' );
14
+ $this->set_label( __( 'Agent', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $this->get_raw_value( $id );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ $comment = get_comment( $id );
23
+
24
+ return $comment->comment_agent;
25
+ }
26
+
27
+ }
classes/Column/Comment/Approved.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Approved extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-approved' );
14
+ $this->set_label( __( 'Approved', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return ac_helper()->icon->yes_or_no( $this->get_raw_value( $id ) );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ $comment = get_comment( $id );
23
+
24
+ return $comment->comment_approved;
25
+ }
26
+
27
+ }
classes/Column/Comment/Author.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Author extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'author' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 20 );
19
+ }
20
+
21
+ }
classes/Column/Comment/AuthorAvatar.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_AuthorAvatar extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-author_avatar' );
14
+ $this->set_label( __( 'Avatar', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $comment = get_comment( $id );
19
+
20
+ return get_avatar( $comment, 80 );
21
+ }
22
+
23
+ }
classes/Column/Comment/AuthorEmail.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_AuthorEmail extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-author_email' );
14
+ $this->set_label( __( 'Author Email', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $email = $this->get_raw_value( $id );
19
+
20
+ return ac_helper()->html->link( $email, $email );
21
+ }
22
+
23
+ public function get_raw_value( $id ) {
24
+ $comment = get_comment( $id );
25
+
26
+ return $comment->comment_author_email;
27
+ }
28
+
29
+ }
classes/Column/Comment/AuthorIP.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Column_Comment_AuthorIP extends AC_Column {
8
+
9
+ public function __construct() {
10
+ $this->set_type( 'column-author_ip' );
11
+ $this->set_label( __( 'Author IP', 'codepress-admin-columns' ) );
12
+ }
13
+
14
+ public function get_value( $id ) {
15
+ return $this->get_raw_value( $id );
16
+ }
17
+
18
+ public function get_raw_value( $id ) {
19
+ $comment = get_comment( $id );
20
+
21
+ return $comment->comment_author_IP;
22
+ }
23
+
24
+ }
classes/Column/Comment/AuthorName.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4.2
9
+ */
10
+ class AC_Column_Comment_AuthorName extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-author_name' );
14
+ $this->set_label( __( 'Author Name', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $this->get_raw_value( $id );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ $comment = get_comment( $id );
23
+
24
+ return $comment->comment_author;
25
+ }
26
+
27
+ }
classes/Column/Comment/AuthorUrl.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_AuthorUrl extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-author_url' );
14
+ $this->set_label( __( 'Author Url', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return ac_helper()->string->shorten_url( $this->get_raw_value( $id ) );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ $comment = get_comment( $id );
23
+
24
+ return $comment->comment_author_url;
25
+ }
26
+
27
+ }
classes/Column/Comment/Comment.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Comment extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'comment' );
15
+ }
16
+
17
+ }
classes/Column/Comment/Date.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Date extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'date' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 14 );
19
+ }
20
+
21
+ }
classes/Column/Comment/DateGmt.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_DateGmt extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-date_gmt' );
14
+ $this->set_label( __( 'Date GMT', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $date_gmt = $this->get_raw_value( $id );
19
+
20
+ $value = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
21
+ esc_url( get_comment_link( $id ) ),
22
+ ac_helper()->date->date( $date_gmt ),
23
+ ac_helper()->date->time( $date_gmt )
24
+ );
25
+
26
+ return "<div class='submitted-on'>{$value}</div>";
27
+ }
28
+
29
+ public function get_raw_value( $id ) {
30
+ $comment = get_comment( $id );
31
+
32
+ return $comment->comment_date_gmt;
33
+ }
34
+
35
+ }
classes/Column/Comment/Excerpt.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Excerpt extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-excerpt' );
14
+ $this->set_label( __( 'Content', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ $comment = get_comment( $id );
19
+
20
+ return $comment->comment_content;
21
+ }
22
+
23
+ public function register_settings() {
24
+ $word_limit = new AC_Settings_Column_WordLimit( $this );
25
+ $word_limit->set_default( 15 );
26
+
27
+ $this->add_setting( $word_limit );
28
+ }
29
+
30
+ }
classes/Column/Comment/ID.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_ID extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-comment_id' );
14
+ $this->set_label( __( 'ID', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $id;
19
+ }
20
+
21
+ }
classes/Column/Comment/Post.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4.7
9
+ */
10
+ class AC_Column_Comment_Post extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-post' );
14
+ $this->set_label( __( 'Post', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ $comment = get_comment( $id );
19
+
20
+ if ( ! $comment ) {
21
+ return false;
22
+ }
23
+
24
+ return $comment->comment_post_ID;
25
+ }
26
+
27
+ public function register_settings() {
28
+ $this->add_setting( new AC_Settings_Column_Post( $this ) );
29
+ }
30
+
31
+ }
classes/Column/Comment/ReplyTo.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_ReplyTo extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-reply_to' );
14
+ $this->set_label( __( 'In Reply To', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $value = '';
19
+ $parent = $this->get_raw_value( $id );
20
+ if ( $parent ) {
21
+ $parent = get_comment( $parent );
22
+
23
+ $value = ac_helper()->html->link( esc_url( get_comment_link( $parent ) ), get_comment_author( $parent->comment_ID ) );
24
+ }
25
+
26
+ return $value;
27
+ }
28
+
29
+ public function get_raw_value( $id ) {
30
+ $comment = get_comment( $id );
31
+
32
+ return $comment->comment_parent;
33
+ }
34
+
35
+ }
classes/Column/Comment/Response.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Comment_Response extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'response' );
14
+ $this->set_original( true );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 15 );
19
+ }
20
+
21
+ /**
22
+ * Response Column should not be displayed when viewing "Comments On".
23
+ * The list table does this by checking if $post_id is set globally. We mimic this functionality here.
24
+ *
25
+ * @see WP_Comments_List_Table::get_columns() for the WP implementation
26
+ */
27
+ public function is_valid() {
28
+ global $current_screen, $post_id;
29
+
30
+ if ( $current_screen && $this->get_list_screen()->is_current_screen( $current_screen ) && $post_id ) {
31
+ return false;
32
+ }
33
+
34
+ return true;
35
+
36
+ }
37
+
38
+ }
classes/{column/comment/status.php → Column/Comment/Status.php} RENAMED
@@ -1,50 +1,38 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Comment_Approved
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Comment_Status extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-status';
20
- $this->properties['label'] = __( 'Status', 'codepress-admin-columns' );
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.0
26
- */
27
- public function get_value( $id ) {
28
- return $this->get_raw_value( $id );
29
- }
30
-
31
- public function get_statuses() {
32
- return array(
33
- 'trash' => __( 'Trash' ),
34
- 'post-trashed' => __( 'Trash' ),
35
- 'spam' => __( 'Spam' ),
36
- '1' => __( 'Approved' ),
37
- '0' => __( 'Pending' ),
38
- );
39
- }
40
-
41
- /**
42
- * @since 2.4.2
43
- */
44
- public function get_raw_value( $id ) {
45
- $comment = get_comment( $id );
46
- $statuses = $this->get_statuses();
47
-
48
- return isset( $statuses[ $comment->comment_approved ] ) ? $statuses[ $comment->comment_approved ] : '';
49
- }
50
- }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_Status extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-status' );
14
+ $this->set_label( __( 'Status', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $this->get_raw_value( $id );
19
+ }
20
+
21
+ public function get_statuses() {
22
+ return array(
23
+ 'trash' => __( 'Trash' ),
24
+ 'post-trashed' => __( 'Trash' ),
25
+ 'spam' => __( 'Spam' ),
26
+ '1' => __( 'Approved' ),
27
+ '0' => __( 'Pending' ),
28
+ );
29
+ }
30
+
31
+ public function get_raw_value( $id ) {
32
+ $comment = get_comment( $id );
33
+ $statuses = $this->get_statuses();
34
+
35
+ return isset( $statuses[ $comment->comment_approved ] ) ? $statuses[ $comment->comment_approved ] : '';
36
+ }
37
+
38
+ }
 
 
 
 
 
 
 
 
 
 
 
 
classes/Column/Comment/Type.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4.2
9
+ */
10
+ class AC_Column_Comment_Type extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-type' );
14
+ $this->set_label( __( 'Type', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $this->get_raw_value( $id );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ $comment = get_comment( $id );
23
+
24
+ return $comment->comment_type;
25
+ }
26
+
27
+ }
classes/Column/Comment/User.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4.2
9
+ */
10
+ class AC_Column_Comment_User extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user' );
14
+ $this->set_label( __( 'User', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ /**
18
+ * @param int $comment_id Comment ID
19
+ *
20
+ * @return int User ID
21
+ */
22
+ public function get_raw_value( $comment_id ) {
23
+ $comment = get_comment( $comment_id );
24
+
25
+ return $comment->user_id;
26
+ }
27
+
28
+ public function register_settings() {
29
+ $this->add_setting( new AC_Settings_Column_User( $this ) );
30
+ }
31
+
32
+ }
classes/Column/Comment/WordCount.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Comment_WordCount extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-word_count' );
14
+ $this->set_label( __( 'Word Count', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ $comment = get_comment( $id );
19
+
20
+ return ac_helper()->string->word_count( $comment->comment_content );
21
+ }
22
+
23
+ }
classes/Column/CustomField.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Custom field column, displaying the contents of meta fields.
9
+ * Suited for all list screens supporting WordPress' default way of handling meta data.
10
+ *
11
+ * Supports different types of meta fields, including dates, serialized data, linked content,
12
+ * and boolean values.
13
+ *
14
+ * @since 1.0
15
+ */
16
+ class AC_Column_CustomField extends AC_Column_Meta {
17
+
18
+ public function __construct() {
19
+ $this->set_type( 'column-meta' );
20
+ $this->set_label( __( 'Custom Field', 'codepress-admin-columns' ) );
21
+ $this->set_group( 'custom_field' );
22
+ }
23
+
24
+ public function get_meta_key() {
25
+ return $this->get_setting( 'custom_field' )->get_value();
26
+ }
27
+
28
+ public function register_settings() {
29
+ $this->add_setting( new AC_Settings_Column_CustomField( $this ) );
30
+ $this->add_setting( new AC_Settings_Column_BeforeAfter( $this ) );
31
+ }
32
+
33
+ /**
34
+ * @since 3.2.1
35
+ */
36
+ public function get_field_type() {
37
+ return $this->get_setting( 'field_type' )->get_value();
38
+ }
39
+
40
+ /**
41
+ * @since 3.2.1
42
+ */
43
+ public function get_field() {
44
+ return $this->get_meta_key();
45
+ }
46
+
47
+ /**
48
+ * Only valid for a Listscreen with a meta type
49
+ *
50
+ * @return mixed
51
+ */
52
+ public function is_valid() {
53
+ return in_array( $this->get_list_screen()->get_meta_type(), array( 'post', 'user', 'comment', 'term' ) );
54
+ }
55
+
56
+ }
classes/{column/link/actions.php → Column/Link/Actions.php} RENAMED
@@ -1,53 +1,45 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Actions
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Actions extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-actions';
19
- $this->properties['label'] = __( 'Actions', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- return $this->get_column_value_actions( $bookmark );
31
- }
32
-
33
- /**
34
- * Get column value of link actions
35
- *
36
- * This part is copied from the Link List Table class
37
- *
38
- * @since 1.4.2
39
- *
40
- * @param object $link
41
- * @return string Actions
42
- */
43
- private function get_column_value_actions( $link ) {
44
- $actions = array();
45
-
46
- $edit_link = get_edit_bookmark_link( $link );
47
-
48
- $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
49
- $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . "</a>";
50
-
51
- return implode( ' | ', $actions );
52
- }
53
- }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Actions extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-actions' );
14
+ $this->set_label( __( 'Actions', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return $this->get_column_value_actions( $bookmark );
21
+ }
22
+
23
+ /**
24
+ * Get column value of link actions
25
+ *
26
+ * This part is copied from the Link List Table class
27
+ *
28
+ * @since 1.4.2
29
+ *
30
+ * @param object $link
31
+ *
32
+ * @return string Actions
33
+ */
34
+ public function get_column_value_actions( $link ) {
35
+ $actions = array();
36
+
37
+ $edit_link = get_edit_bookmark_link( $link );
38
+
39
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
40
+ $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . "</a>";
41
+
42
+ return implode( ' | ', $actions );
43
+ }
44
+
45
+ }
 
 
 
 
 
 
 
 
classes/Column/Link/Description.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Description extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-description' );
14
+ $this->set_label( __( 'Description', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return $bookmark->link_description;
21
+ }
22
+
23
+ }
classes/Column/Link/ID.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_ID extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-link_id' );
14
+ $this->set_label( __( 'ID', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $id;
19
+ }
20
+
21
+ }
classes/Column/Link/Image.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Image extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-image' );
14
+ $this->set_label( __( 'Image', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return $bookmark->link_image;
21
+ }
22
+
23
+ public function register_settings() {
24
+ $this->add_setting( new AC_Settings_Column_Image( $this ) );
25
+ }
26
+
27
+ }
classes/Column/Link/Length.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Length extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-length' );
14
+ $this->set_label( __( 'Length', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return strlen( $bookmark->link_name );
21
+ }
22
+
23
+ }
classes/Column/Link/Notes.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Notes extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-notes' );
14
+ $this->set_label( __( 'Notes', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return $bookmark->link_notes;
21
+ }
22
+
23
+ public function register_settings() {
24
+ $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
25
+ }
26
+
27
+ }
classes/Column/Link/Owner.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Owner extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-owner' );
14
+ $this->set_label( __( 'Owner', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ $value = $bookmark->link_owner;
21
+
22
+ // add user link
23
+ $userdata = get_userdata( $bookmark->link_owner );
24
+
25
+ if ( ! empty( $userdata->data ) ) {
26
+ $value = $userdata->data->user_nicename;
27
+ }
28
+
29
+ return $value;
30
+ }
31
+
32
+ }
classes/Column/Link/Rss.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Rss extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-rss' );
14
+ $this->set_label( __( 'Rss', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return ac_helper()->string->shorten_url( $bookmark->link_rss );
21
+ }
22
+
23
+ }
classes/Column/Link/Target.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Link_Target extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-target' );
14
+ $this->set_label( __( 'Target', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $bookmark = get_bookmark( $id );
19
+
20
+ return $bookmark->link_target;
21
+ }
22
+
23
+ }
classes/Column/Media/Actions.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Actions extends AC_Column_Actions {
11
+
12
+ protected function get_object_type() {
13
+ return 'media';
14
+ }
15
+
16
+ }
classes/Column/Media/AlternateText.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_AlternateText extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-alternate_text' );
14
+ $this->set_label( __( 'Alt', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return '_wp_attachment_image_alt';
19
+ }
20
+
21
+ public function get_value( $id ) {
22
+ return ac_helper()->string->strip_trim( $this->get_raw_value( $id ) );
23
+ }
24
+
25
+ public function get_raw_value( $id ) {
26
+ return $this->get_meta_value( $id, $this->get_meta_key() );
27
+ }
28
+
29
+ }
classes/Column/Media/AttachedTo.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_AttachedTo extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-attached_to' );
14
+ $this->set_label( __( 'Attached to Post', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $value = false;
19
+
20
+ if ( $attached_to = $this->get_raw_value( $id ) ) {
21
+ $value = ac_helper()->html->link( get_edit_post_link( $id ), get_the_title( $attached_to ) );
22
+ }
23
+
24
+ return $value;
25
+ }
26
+
27
+ public function get_raw_value( $id ) {
28
+ return ac_helper()->post->get_raw_field( 'post_parent', $id );
29
+ }
30
+
31
+ }
classes/Column/Media/Author.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Author extends AC_Column_Post_Author {
11
+ }
classes/Column/Media/AuthorName.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying information about the author of a post, such as the
9
+ * author's display name, user ID and email address.
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Media_AuthorName extends AC_Column_Post_AuthorName {
14
+ }
classes/Column/Media/AvailableSizes.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_AvailableSizes extends AC_Column_Media_Meta {
11
+
12
+ private $intermediate_image_sizes = null;
13
+
14
+ public function __construct() {
15
+ parent::__construct();
16
+
17
+ $this->set_type( 'column-available_sizes' );
18
+ $this->set_label( __( 'Available Sizes', 'codepress-admin-columns' ) );
19
+ }
20
+
21
+ public function get_intermediate_image_sizes() {
22
+ if ( null === $this->intermediate_image_sizes ) {
23
+ $this->intermediate_image_sizes = get_intermediate_image_sizes();
24
+ }
25
+
26
+ return $this->intermediate_image_sizes;
27
+ }
28
+
29
+ public function get_available_sizes( $id ) {
30
+ $sizes = $this->get_raw_value( $id );
31
+
32
+ return $sizes ? array_intersect( array_keys( $sizes ), $this->get_intermediate_image_sizes() ) : false;
33
+ }
34
+
35
+ public function get_value( $id ) {
36
+ $sizes = $this->get_raw_value( $id );
37
+
38
+ if ( ! $sizes ) {
39
+ return $this->get_empty_char();
40
+ }
41
+
42
+ $paths = array();
43
+
44
+ // available sizes
45
+ if ( $intersect = array_intersect( array_keys( $sizes ), get_intermediate_image_sizes() ) ) {
46
+
47
+ $url = wp_get_attachment_url( $id );
48
+ $filename = basename( $url );
49
+ $paths[] = "<a title='{$filename}' href='{$url}'>" . __( 'full size', 'codepress-admin-columns' ) . "</a>";
50
+
51
+ foreach ( $intersect as $size ) {
52
+ $src = wp_get_attachment_image_src( $id, $size );
53
+
54
+ if ( ! empty( $src[0] ) ) {
55
+ $filename = basename( $src[0] );
56
+ $paths[] = "<a title='{$filename}' href='{$src[0]}' class='available'>{$size}</a>";
57
+ }
58
+ }
59
+ }
60
+
61
+ global $_wp_additional_image_sizes;
62
+
63
+ if ( ! empty( $_wp_additional_image_sizes ) ) {
64
+ if ( isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) {
65
+ unset( $_wp_additional_image_sizes['post-thumbnail'] );
66
+ }
67
+
68
+ // image does not have these additional sizes rendered yet
69
+ if ( $missing = array_diff( array_keys( $_wp_additional_image_sizes ), array_keys( $sizes ) ) ) {
70
+ foreach ( $missing as $size ) {
71
+ $paths[] = "<span title='Missing size: Try regenerate thumbnails with the plugin: Force Regenerate Thumbnails' href='javascript:;' class='not-available'>{$size}</span>";
72
+ }
73
+ }
74
+ }
75
+
76
+ return "<div class='sizes'>" . implode( ac_helper()->html->divider(), $paths ) . "</div>";
77
+ }
78
+
79
+ public function get_raw_value( $id ) {
80
+ $value = parent::get_raw_value( $id );
81
+
82
+ return isset( $value['sizes'] ) ? $value['sizes'] : false;
83
+ }
84
+
85
+ }
classes/Column/Media/Caption.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Caption extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-caption' );
14
+ $this->set_label( __( 'Caption', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return esc_html( $this->get_raw_value( $id ) );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ return ac_helper()->post->get_raw_field( 'post_excerpt', $id );
23
+ }
24
+
25
+ }
classes/Column/Media/Comments.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Comments extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'comments' );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return post_type_supports( $this->get_post_type(), 'comments' );
19
+ }
20
+
21
+ }
classes/Column/Media/Date.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Date extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'date' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 10 );
19
+ }
20
+
21
+ }
classes/Column/Media/Description.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Description extends AC_Column_Post_Content {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+
15
+ $this->set_type( 'column-description' );
16
+ $this->set_label( __( 'Description', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ }
classes/Column/Media/Dimensions.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Dimensions extends AC_Column_Media_Meta {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+
15
+ $this->set_type( 'column-dimensions' );
16
+ $this->set_label( __( 'Dimensions', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_surface( $id ) {
20
+ $meta = $this->get_raw_value( $id );
21
+
22
+ $height = ! empty( $meta['height'] ) ? $meta['height'] : 0;
23
+ $width = ! empty( $meta['width'] ) ? $meta['width'] : 0;
24
+
25
+ return $height * $width;
26
+ }
27
+
28
+ public function get_value( $id ) {
29
+ $value = $this->get_empty_char();
30
+
31
+ $meta = $this->get_raw_value( $id );
32
+
33
+ if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
34
+ $value = "{$meta['width']} x {$meta['height']}";
35
+ }
36
+
37
+ return $value;
38
+ }
39
+
40
+ }
classes/Column/Media/ExifData.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_ExifData extends AC_Column_Media_Meta {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+
15
+ $this->set_type( 'column-exif_data' );
16
+ $this->set_label( __( 'EXIF Data', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_raw_value( $id ) {
20
+ $value = parent::get_raw_value( $id );
21
+
22
+ return ! empty( $value['image_meta'] ) ? $value['image_meta'] : false;
23
+ }
24
+
25
+ public function is_valid() {
26
+ return function_exists( 'exif_read_data' );
27
+ }
28
+
29
+ public function register_settings() {
30
+ $this->add_setting( new AC_Settings_Column_ExifData( $this ) );
31
+ }
32
+
33
+ }
classes/Column/Media/FileName.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_FileName extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-file_name' );
14
+ $this->set_label( __( 'Filename', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return '_wp_attached_file';
19
+ }
20
+
21
+ public function get_value( $id ) {
22
+ return ac_helper()->html->link( wp_get_attachment_url( $id ), $this->get_raw_value( $id ) );
23
+ }
24
+
25
+ public function get_raw_value( $id ) {
26
+ return ac_helper()->image->get_file_name( $id );
27
+ }
28
+
29
+ }
classes/Column/Media/FileSize.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_FileSize extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-file_size' );
14
+ $this->set_label( __( 'File Size', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ $value = '';
19
+
20
+ $file = wp_get_attachment_url( $id );
21
+ $abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file );
22
+
23
+ if ( file_exists( $abs ) ) {
24
+ $value = ac_helper()->file->get_readable_filesize( filesize( $abs ) );
25
+ }
26
+
27
+ return $value;
28
+ }
29
+
30
+ }
classes/Column/Media/FullPath.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_FullPath extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-full_path' );
14
+ $this->set_label( __( 'Full Path', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ return wp_get_attachment_url( $id );
19
+ }
20
+
21
+ public function register_settings() {
22
+ $this->add_setting( new AC_Settings_Column_PathScope( $this ) );
23
+ }
24
+
25
+ }
classes/Column/Media/Height.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Height extends AC_Column_Media_Meta {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+
15
+ $this->set_type( 'column-height' );
16
+ $this->set_label( __( 'Height', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_value( $id ) {
20
+ $value = $this->get_raw_value( $id );
21
+
22
+ return $value ? $value . 'px' : $this->get_empty_char();
23
+ }
24
+
25
+ public function get_raw_value( $id ) {
26
+ $value = parent::get_raw_value( $id );
27
+
28
+ return ! empty( $value['height'] ) ? $value['height'] : false;
29
+ }
30
+
31
+ }
classes/Column/Media/ID.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_ID extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-mediaid' );
14
+ $this->set_label( __( 'ID', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $id;
19
+ }
20
+
21
+ }
classes/Column/Media/Meta.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Column_Media_Meta extends AC_Column_Meta {
8
+
9
+ public function __construct() {
10
+ $this->set_serialized( true );
11
+ }
12
+
13
+ public function get_meta_key() {
14
+ return '_wp_attachment_metadata';
15
+ }
16
+
17
+ public function get_raw_value( $id ) {
18
+ return $this->get_meta_value( $id, $this->get_meta_key() );
19
+ }
20
+
21
+ }
classes/Column/Media/MimeType.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_MimeType extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-mime_type' );
14
+ $this->set_label( __( 'Mime Type', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return $this->get_raw_value( $id );
19
+ }
20
+
21
+ public function get_raw_value( $id ) {
22
+ return get_post_field( 'post_mime_type', $id );
23
+ }
24
+
25
+ }
classes/Column/Media/Parent.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Parent extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'parent' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 15 );
19
+ }
20
+
21
+ }
classes/Column/Media/Taxonomy.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Taxonomy extends AC_Column_Post_Taxonomy {
11
+ }
classes/Column/Media/Title.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Media_Title extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'title' );
15
+ }
16
+
17
+ }
classes/Column/Media/Width.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Media_Width extends AC_Column_Media_Meta {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+
15
+ $this->set_type( 'column-width' );
16
+ $this->set_label( __( 'Width', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_value( $id ) {
20
+ $value = $this->get_raw_value( $id );
21
+
22
+ return $value ? $value . 'px' : $this->get_empty_char();
23
+ }
24
+
25
+ public function get_raw_value( $id ) {
26
+ $value = parent::get_raw_value( $id );
27
+
28
+ return ! empty( $value['width'] ) ? $value['width'] : false;
29
+ }
30
+
31
+ }
classes/Column/Meta.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Column_Meta extends AC_Column {
8
+
9
+ /**
10
+ * Return the meta_key of this column
11
+ *
12
+ * @return string
13
+ */
14
+ abstract public function get_meta_key();
15
+
16
+ /**
17
+ * Is data stored serialized?
18
+ *
19
+ * @var bool
20
+ */
21
+ private $serialized = false;
22
+
23
+ /**
24
+ * @return bool
25
+ */
26
+ public function is_serialized() {
27
+ return $this->serialized;
28
+ }
29
+
30
+ /**
31
+ * @param bool $serialized
32
+ */
33
+ public function set_serialized( $serialized ) {
34
+ $this->serialized = (bool) $serialized;
35
+ }
36
+
37
+ /**
38
+ * @see AC_Column::get_raw_value()
39
+ * @since 2.0.3
40
+ */
41
+ public function get_raw_value( $id ) {
42
+ $value = $this->get_meta_value( $id, $this->get_meta_key(), true );
43
+
44
+ if( ! $value ){
45
+ return false;
46
+ }
47
+
48
+ return $value;
49
+ }
50
+
51
+ /**
52
+ * Retrieve metadata object type (e.g., comment, post, or user)
53
+ *
54
+ * @since 3.0
55
+ * @return bool
56
+ */
57
+ public function get_meta_type() {
58
+ return $this->get_list_screen()->get_meta_type();
59
+ }
60
+
61
+ /**
62
+ * Get meta value
63
+ *
64
+ * @param int $id
65
+ * @param string $meta_key
66
+ * @param bool $single
67
+ *
68
+ * @return mixed
69
+ */
70
+ public function get_meta_value( $id, $meta_key, $single = true ) {
71
+ return get_metadata( $this->get_meta_type(), $id, $meta_key, $single );
72
+ }
73
+
74
+ }
classes/Column/Placeholder.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * ACF Placeholder column, holding a CTA for Admin Columns Pro.
9
+ *
10
+ * @since 2.2
11
+ */
12
+ class AC_Column_Placeholder extends AC_Column {
13
+
14
+ /**
15
+ * @var AC_Addon
16
+ */
17
+ private $addon;
18
+
19
+ /**
20
+ * @param AC_Addon $addon
21
+ */
22
+ public function set_addon( AC_Addon $addon ) {
23
+ $this->addon = $addon;
24
+
25
+ $this->set_type( 'placeholder-' . $addon->get_slug() );
26
+ $this->set_group( $addon->get_slug() );
27
+ $this->set_label( $addon->get_title() );
28
+ }
29
+
30
+ public function get_message() {
31
+ ob_start();
32
+ ?>
33
+
34
+ <p>
35
+ <strong><?php printf( __( "The %s column is only available in Admin Columns Pro - Business or Developer.", 'codepress-admin-columns' ), $this->get_label() ); ?></strong>
36
+ </p>
37
+
38
+ <p>
39
+ <?php printf( __( "If you have a business or developer licence please download & install your %s add-on from the <a href='%s'>add-ons tab</a>.", 'codepress-admin-columns' ), $this->get_label(), AC()->admin()->get_link( 'addons' ) ); ?>
40
+ </p>
41
+
42
+ <p>
43
+ <?php printf( __( "Admin Columns Pro offers full %s integration, allowing you to easily display and edit %s fields from within your overview.", 'codepress-admin-columns' ), $this->get_label(), $this->get_label() ); ?>
44
+ </p>
45
+ <a target="_blank" href="<?php echo $this->addon->get_link(); ?>" class="button button-primary"><?php _e( 'Find out more', 'codepress-admin-columns' ); ?></a>
46
+
47
+ <?php
48
+
49
+ return ob_get_clean();
50
+ }
51
+
52
+ }
classes/Column/Post/Actions.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Actions extends AC_Column_Actions {
11
+
12
+ protected function get_object_type() {
13
+ return 'post';
14
+ }
15
+
16
+ }
classes/Column/Post/Attachment.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Attachment extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-attachment' );
14
+ $this->set_label( __( 'Attachments', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ return $this->get_attachment_ids( $post_id );
19
+ }
20
+
21
+ /**
22
+ * @param $post_id
23
+ *
24
+ * @return int[] Attachment ID's
25
+ */
26
+ private function get_attachment_ids( $post_id ) {
27
+ $attachment_ids = get_posts( array(
28
+ 'post_type' => 'attachment',
29
+ 'posts_per_page' => -1,
30
+ 'post_status' => null,
31
+ 'post_parent' => $post_id,
32
+ 'fields' => 'ids',
33
+ ) );
34
+
35
+ if ( ! $attachment_ids ) {
36
+ return array();
37
+ }
38
+
39
+ return $attachment_ids;
40
+ }
41
+
42
+ public function register_settings() {
43
+ $this->add_setting( new AC_Settings_Column_Image( $this ) );
44
+ }
45
+
46
+ }
classes/Column/Post/AttachmentCount.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying number of attachment for an item.
9
+ *
10
+ * @since 2.0
11
+ */
12
+ class AC_Column_Post_AttachmentCount extends AC_Column {
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-attachment_count' );
16
+ $this->set_label( __( 'Attachment Count', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_raw_value( $post_id ) {
20
+ $attachment_ids = get_posts( array(
21
+ 'post_type' => 'attachment',
22
+ 'posts_per_page' => -1,
23
+ 'post_status' => null,
24
+ 'post_parent' => $post_id,
25
+ 'fields' => 'ids',
26
+ ) );
27
+
28
+ return count( $attachment_ids );
29
+ }
30
+
31
+ }
classes/Column/Post/Author.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Author extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'author' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 10 );
19
+ }
20
+
21
+ }
classes/Column/Post/AuthorName.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying information about the author of a post, such as the
9
+ * author's display name, user ID and email address.
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Post_AuthorName extends AC_Column {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-author_name' );
17
+ $this->set_label( __( 'Author', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ public function get_raw_value( $post_id ) {
21
+ return $this->get_post_author( $post_id );
22
+ }
23
+
24
+ private function get_post_author( $post_id ) {
25
+ return ac_helper()->post->get_raw_field( 'post_author', $post_id );
26
+ }
27
+
28
+ public function register_settings() {
29
+ $this->add_setting( new AC_Settings_Column_User( $this ) );
30
+ }
31
+
32
+ }
classes/Column/Post/BeforeMoreTag.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_BeforeMoreTag extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-before_moretag' );
14
+ $this->set_label( __( 'Before More Tag', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ $value = false;
19
+
20
+ $p = get_post( $post_id );
21
+ $extended = get_extended( $p->post_content );
22
+
23
+ if ( ! empty( $extended['extended'] ) ) {
24
+ $value = $extended['main'];
25
+ }
26
+
27
+ return $value;
28
+ }
29
+
30
+ public function register_settings() {
31
+ $word_limit = new AC_Settings_Column_WordLimit( $this );
32
+ $word_limit->set_default( 15 );
33
+
34
+ $this->add_setting( $word_limit );
35
+ }
36
+
37
+ }
classes/Column/Post/Categories.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Categories extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'categories' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 15 );
19
+ }
20
+
21
+ public function get_taxonomy() {
22
+ return 'category';
23
+ }
24
+
25
+ public function is_valid() {
26
+ return ac_helper()->taxonomy->is_taxonomy_registered( $this->get_post_type(), $this->get_taxonomy() );
27
+ }
28
+
29
+ }
classes/Column/Post/CommentCount.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying the number of comments for an item, displaying either the total
9
+ * amount of comments, or the amount per status (e.g. "Approved", "Pending").
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Post_CommentCount extends AC_Column {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-comment_count' );
17
+ $this->set_label( __( 'Comment Count', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ public function get_value( $id ) {
21
+ return $this->get_formatted_value( $id );
22
+ }
23
+
24
+ public function is_valid() {
25
+ return post_type_supports( $this->get_post_type(), 'comments' );
26
+ }
27
+
28
+ public function register_settings() {
29
+ $this->add_setting( new AC_Settings_Column_CommentCount( $this ) );
30
+ }
31
+
32
+ }
classes/Column/Post/CommentStatus.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying whether an item is open for comments, i.e. whether users can
9
+ * comment on this item.
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Post_CommentStatus extends AC_Column {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-comment_status' );
17
+ $this->set_label( __( 'Comment Status', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ public function is_valid() {
21
+ return post_type_supports( $this->get_post_type(), 'comments' );
22
+ }
23
+
24
+ public function get_value( $post_id ) {
25
+ $comment_status = $this->get_raw_value( $post_id );
26
+
27
+ return ac_helper()->icon->yes_or_no( ( 'open' == $comment_status ), $comment_status );
28
+ }
29
+
30
+ public function get_raw_value( $post_id ) {
31
+ return get_post_field( 'comment_status', $post_id, 'raw' );
32
+ }
33
+
34
+ }
classes/Column/Post/Comments.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Comments extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'comments' );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return post_type_supports( $this->get_post_type(), 'comments' );
19
+ }
20
+
21
+ }
classes/Column/Post/Content.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4
9
+ */
10
+ class AC_Column_Post_Content extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-content' );
14
+ $this->set_label( __( 'Content', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ return get_post_field( 'post_content', $post_id, 'raw' );
19
+ }
20
+
21
+ public function register_settings() {
22
+ $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
23
+ }
24
+
25
+ }
classes/Column/Post/Date.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Date extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'date' );
15
+ }
16
+
17
+ }
classes/Column/Post/DatePublished.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4
9
+ */
10
+ class AC_Column_Post_DatePublished extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-date_published' );
14
+ $this->set_label( __( 'Date Published' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ $post = get_post( $post_id );
19
+
20
+ return $post->post_date;
21
+ }
22
+
23
+ public function register_settings() {
24
+ $this->add_setting( new AC_Settings_Column_Date( $this ) );
25
+ }
26
+
27
+ }
classes/Column/Post/Depth.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Depth of the current page (number of ancestors + 1)
9
+ *
10
+ * @since 2.3.4
11
+ */
12
+ class AC_Column_Post_Depth extends AC_Column {
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-depth' );
16
+ $this->set_label( __( 'Depth', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_value( $post_id ) {
20
+ return $this->get_raw_value( $post_id );
21
+ }
22
+
23
+ public function get_raw_value( $post_id ) {
24
+ return count( get_post_ancestors( $post_id ) ) + 1;
25
+ }
26
+
27
+ public function is_valid() {
28
+ return is_post_type_hierarchical( $this->get_post_type() );
29
+ }
30
+
31
+ }
classes/Column/Post/EstimatedReadingTime.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.3.3
9
+ */
10
+ class AC_Column_Post_EstimatedReadingTime extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-estimated_reading_time' );
14
+ $this->set_label( __( 'Estimated Reading Time', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ /**
18
+ * Estimate read time in seconds
19
+ * @since 2.3.3
20
+ *
21
+ * @return int Seconds
22
+ */
23
+ public function get_raw_value( $post_id ) {
24
+ return ac_helper()->post->get_raw_field( 'post_content', $post_id );
25
+ }
26
+
27
+ public function is_valid() {
28
+ return post_type_supports( $this->get_post_type(), 'editor' );
29
+ }
30
+
31
+ public function register_settings() {
32
+ $this->add_setting( new AC_Settings_Column_WordsPerMinute( $this ) );
33
+ }
34
+
35
+ }
classes/Column/Post/Excerpt.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Excerpt extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-excerpt' );
14
+ $this->set_label( __( 'Excerpt', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $post_id ) {
18
+ $value = parent::get_value( $post_id );
19
+
20
+ if ( $value && ! has_excerpt( $post_id ) && $value !== $this->get_empty_char() ) {
21
+ $value = '<span class="ac-inline-info">' . __( 'Excerpt from content', 'codepress-admin-columns' ) . '</span> ' . $value;
22
+ }
23
+
24
+ return $value;
25
+ }
26
+
27
+ public function get_raw_value( $post_id ) {
28
+ return ac_helper()->post->excerpt( $post_id );
29
+ }
30
+
31
+ public function register_settings() {
32
+ $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
33
+ }
34
+
35
+ }
classes/Column/Post/FeaturedImage.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_FeaturedImage extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-featured_image' );
14
+ $this->set_label( __( 'Featured Image', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ // Meta
18
+
19
+ public function get_meta_key() {
20
+ return '_thumbnail_id';
21
+ }
22
+
23
+ // Display
24
+
25
+ public function get_value( $post_id ) {
26
+ $value = parent::get_value( $post_id );
27
+
28
+ if ( ! $value ) {
29
+ return false;
30
+ }
31
+
32
+ if ( $link = get_edit_post_link( $post_id ) ) {
33
+ $value = ac_helper()->html->link( $link . '#postimagediv', $value );
34
+ }
35
+
36
+ return $value;
37
+ }
38
+
39
+ /**
40
+ * Returns Attachment ID
41
+ *
42
+ * @param int $post_id
43
+ *
44
+ * @return int|false
45
+ */
46
+ public function get_raw_value( $post_id ) {
47
+ if ( ! has_post_thumbnail( $post_id ) ) {
48
+ return false;
49
+ }
50
+
51
+ return get_post_thumbnail_id( $post_id );
52
+ }
53
+
54
+ public function register_settings() {
55
+ $this->add_setting( new AC_Settings_Column_Image( $this ) );
56
+ }
57
+
58
+ public function is_valid() {
59
+ return post_type_supports( $this->get_post_type(), 'thumbnail' );
60
+ }
61
+
62
+ }
classes/Column/Post/Formats.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Formats extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-post_formats' );
14
+ $this->set_label( __( 'Post Format', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return post_type_supports( $this->get_post_type(), 'post-formats' );
19
+ }
20
+
21
+ public function get_value( $post_id ) {
22
+ $format = $this->get_raw_value( $post_id );
23
+
24
+ return $format ? esc_html( get_post_format_string( $format ) ) : __( 'Standard', 'codepress-admin-columns' );
25
+ }
26
+
27
+ public function get_raw_value( $post_id ) {
28
+ $format = get_post_format( $post_id );
29
+
30
+ return $format ? $format : false;
31
+ }
32
+
33
+ public function get_taxonomy() {
34
+ return 'post_format';
35
+ }
36
+
37
+ }
classes/Column/Post/ID.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_ID extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-postid' );
14
+ $this->set_label( __( 'ID', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $post_id ) {
18
+ return $post_id;
19
+ }
20
+
21
+ }
classes/Column/Post/LastModifiedAuthor.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying information about the author of a post, such as the
9
+ * author's display name, user ID and email address.
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Post_LastModifiedAuthor extends AC_Column_Meta {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-last_modified_author' );
17
+ $this->set_label( __( 'Last Modified Author', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ public function get_meta_key() {
21
+ return '_edit_last';
22
+ }
23
+
24
+ public function register_settings() {
25
+ $this->add_setting( new AC_Settings_Column_User( $this ) );
26
+ }
27
+
28
+ }
classes/Column/Post/Modified.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Modified extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-modified' );
14
+ $this->set_label( __( 'Last Modified', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ return get_post_field( 'post_modified', $post_id );
19
+ }
20
+
21
+ public function register_settings() {
22
+ $date = new AC_Settings_Column_Date( $this );
23
+ $date->set_default( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) );
24
+
25
+ $this->add_setting( $date );
26
+ }
27
+
28
+ }
classes/Column/Post/Order.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Order extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-order' );
14
+ $this->set_label( __( 'Order', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return is_post_type_hierarchical( $this->get_post_type() ) || post_type_supports( $this->get_post_type(), 'page-attributes' );
19
+ }
20
+
21
+ public function get_value( $post_id ) {
22
+ return $this->get_raw_value( $post_id );
23
+ }
24
+
25
+ public function get_raw_value( $post_id ) {
26
+ return get_post_field( 'menu_order', $post_id );
27
+ }
28
+
29
+ }
classes/Column/Post/PageTemplate.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_PageTemplate extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-page_template' );
14
+ $this->set_label( __( 'Page Template', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return '_wp_page_template';
19
+ }
20
+
21
+ function get_value( $post_id ) {
22
+ return array_search( $this->get_raw_value( $post_id ), $this->get_page_templates() );
23
+ }
24
+
25
+ function is_valid() {
26
+ return $this->get_page_templates() ? true : false;
27
+ }
28
+
29
+ /**
30
+ * @return array
31
+ */
32
+ public function get_page_templates() {
33
+ global $wp_version;
34
+
35
+ if ( version_compare( $wp_version, '4.7', '>=' ) ) {
36
+ return get_page_templates( null, $this->get_post_type() );
37
+ }
38
+
39
+ return get_page_templates();
40
+ }
41
+
42
+ }
classes/Column/Post/Parent.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Parent extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-parent' );
14
+ $this->set_label( __( 'Parent', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $post_id ) {
18
+ $title = false;
19
+
20
+ if ( $parent_id = $this->get_raw_value( $post_id ) ) {
21
+ $title = ac_helper()->html->link( get_edit_post_link( $parent_id ), ac_helper()->post->get_raw_field( 'post_title', $parent_id ) );
22
+ }
23
+
24
+ return $title;
25
+ }
26
+
27
+ public function get_raw_value( $post_id ) {
28
+ $parent_id = ac_helper()->post->get_raw_field( 'post_parent', $post_id );
29
+
30
+ return $parent_id && is_numeric( $parent_id ) ? $parent_id : false;
31
+ }
32
+
33
+ public function is_valid() {
34
+ return is_post_type_hierarchical( $this->get_post_type() );
35
+ }
36
+
37
+ }
classes/Column/Post/Path.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying path (without URL, e.g. "/my-category/sample-post/") to the front-end location of this item.
9
+ *
10
+ * @since 2.2.3
11
+ */
12
+ class AC_Column_Post_Path extends AC_Column {
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-path' );
16
+ $this->set_label( __( 'Path', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_value( $post_id ) {
20
+ return $this->get_raw_value( $post_id );
21
+ }
22
+
23
+ public function get_raw_value( $post_id ) {
24
+ return str_replace( home_url(), '', get_permalink( $post_id ) );
25
+ }
26
+
27
+ }
classes/Column/Post/Permalink.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying full item permalink (including URL).
9
+ *
10
+ * @since 2.0
11
+ */
12
+ class AC_Column_Post_Permalink extends AC_Column {
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-permalink' );
16
+ $this->set_label( __( 'Permalink', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_raw_value( $id ) {
20
+ $link = get_permalink( $id );
21
+
22
+ return ac_helper()->html->link( $link, $link, array( 'target' => '_blank' ) );
23
+ }
24
+
25
+ }
classes/Column/Post/PingStatus.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_PingStatus extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-ping_status' );
14
+ $this->set_label( __( 'Ping Status', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return post_type_supports( $this->get_post_type(), 'comments' );
19
+ }
20
+
21
+ public function get_value( $post_id ) {
22
+ $ping_status = $this->get_raw_value( $post_id );
23
+
24
+ return ac_helper()->icon->yes_or_no( 'open' == $ping_status, $ping_status );
25
+ }
26
+
27
+ public function get_raw_value( $post_id ) {
28
+ return get_post_field( 'ping_status', $post_id, 'raw' );
29
+ }
30
+
31
+ }
classes/Column/Post/Roles.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Roles extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-roles' );
14
+ $this->set_label( __( 'Roles', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ /**
18
+ * @param int $post_id
19
+ *
20
+ * @return string
21
+ */
22
+ public function get_value( $post_id ) {
23
+ $roles = ac_helper()->user->get_roles();
24
+
25
+ $role_names = array();
26
+
27
+ foreach ( $this->get_raw_value( $post_id ) as $role ) {
28
+ if ( isset( $roles[ $role ] ) ) {
29
+ $role_names[ $role ] = $roles[ $role ];
30
+ }
31
+ }
32
+
33
+ return implode( __( ', ' ), $role_names );
34
+ }
35
+
36
+ public function get_raw_value( $post_id ) {
37
+ $userdata = get_userdata( get_post_field( 'post_author', $post_id ) );
38
+
39
+ return empty( $userdata->roles[0] ) ? array() : $userdata->roles;
40
+ }
41
+
42
+ }
classes/{column/post/shortcodes.php → Column/Post/Shortcodes.php} RENAMED
@@ -1,68 +1,61 @@
1
- <?php
2
-
3
- /**
4
- * Display used shortcodes
5
- *
6
- * @since 2.3.5
7
- */
8
- class CPAC_Column_Post_Shortcodes extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.3.4
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-shortcode';
20
- $this->properties['label'] = __( 'Shortcodes', 'codepress-admin-columns' );
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.3.5
26
- */
27
- public function get_value( $post_id ) {
28
- if ( ! ( $shortcodes = $this->get_raw_value( $post_id ) ) ) {
29
- return false;
30
- }
31
-
32
- $display = array();
33
- foreach ( $shortcodes as $sc => $count ) {
34
- $string = '[' . $sc . ']';
35
- $string = $count > 1 ? $string . '<span class="cpac-rounded">' . $count . '</span>' : $string;
36
- $display[ $sc ] = '<span class="cpac-spacing">' . $string . '</span>';
37
- }
38
-
39
- return implode( ' ', $display );
40
- }
41
-
42
- /**
43
- * @see CPAC_Column::get_raw_value()
44
- * @since 2.3.5
45
- */
46
- public function get_raw_value( $post_id ) {
47
- global $shortcode_tags;
48
-
49
- if ( ! $shortcode_tags ) {
50
- return false;
51
- }
52
-
53
- $content = get_post_field( 'post_content', $post_id );
54
-
55
- $shortcodes = array();
56
-
57
- $_shortcodes = array_keys( $shortcode_tags );
58
- asort( $_shortcodes );
59
-
60
- foreach ( $_shortcodes as $sc ) {
61
- if ( $count = substr_count( $content, '[' . $sc ) ) {
62
- $shortcodes[ $sc ] = $count;
63
- }
64
- }
65
-
66
- return $shortcodes;
67
- }
68
- }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Display used shortcodes
9
+ *
10
+ * @since 2.3.5
11
+ */
12
+ class AC_Column_Post_Shortcodes extends AC_Column {
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-shortcode' );
16
+ $this->set_label( __( 'Shortcodes', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ public function get_value( $post_id ) {
20
+ if ( ! ( $shortcodes = $this->get_raw_value( $post_id ) ) ) {
21
+ return false;
22
+ }
23
+
24
+ $display = array();
25
+ foreach ( $shortcodes as $sc => $count ) {
26
+ $string = '[' . $sc . ']';
27
+
28
+ if ( $count > 1 ) {
29
+ $string .= ac_helper()->html->rounded( $count );
30
+ }
31
+
32
+ $display[ $sc ] = '<span class="ac-spacing">' . $string . '</span>';
33
+ }
34
+
35
+ return implode( ' ', $display );
36
+ }
37
+
38
+ public function get_raw_value( $post_id ) {
39
+ global $shortcode_tags;
40
+
41
+ if ( ! $shortcode_tags ) {
42
+ return false;
43
+ }
44
+
45
+ $content = get_post_field( 'post_content', $post_id );
46
+
47
+ $shortcodes = array();
48
+
49
+ $_shortcodes = array_keys( $shortcode_tags );
50
+ asort( $_shortcodes );
51
+
52
+ foreach ( $_shortcodes as $sc ) {
53
+ if ( $count = substr_count( $content, '[' . $sc ) ) {
54
+ $shortcodes[ $sc ] = $count;
55
+ }
56
+ }
57
+
58
+ return $shortcodes;
59
+ }
60
+
61
+ }
 
 
 
 
 
 
 
classes/Column/Post/Shortlink.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Shortlink extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-shortlink' );
14
+ $this->set_label( __( 'Shortlink', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ function get_value( $post_id ) {
18
+ $link = $this->get_raw_value( $post_id );
19
+
20
+ return ac_helper()->html->link( $link, $link );
21
+ }
22
+
23
+ function get_raw_value( $post_id ) {
24
+ return wp_get_shortlink( $post_id );
25
+ }
26
+
27
+ }
classes/Column/Post/Slug.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Slug extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-slug' );
14
+ $this->set_label( __( 'Slug', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ function get_value( $post_id ) {
18
+ return $this->get_raw_value( $post_id );
19
+ }
20
+
21
+ function get_raw_value( $post_id ) {
22
+ return get_post_field( 'post_name', $post_id, 'raw' );
23
+ }
24
+
25
+ }
classes/Column/Post/Status.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Status extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-status' );
14
+ $this->set_label( __( 'Status', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $post_id ) {
18
+ global $wp_post_statuses;
19
+
20
+ $post_status = $this->get_raw_value( $post_id );
21
+
22
+ if ( ! isset( $wp_post_statuses[ $post_status ] ) ) {
23
+ return false;
24
+ }
25
+
26
+ $label = $wp_post_statuses[ $post_status ]->label;
27
+
28
+ if ( 'future' === $post_status ) {
29
+ $label .= " <p class='description'>" . date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( get_post_field( 'post_date', $post_id ) ) ) . "</p>";
30
+ }
31
+
32
+ return $label;
33
+ }
34
+
35
+ public function get_raw_value( $post_id ) {
36
+ return get_post_field( 'post_status', $post_id );
37
+ }
38
+
39
+ }
classes/Column/Post/Sticky.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_Sticky extends AC_Column {
11
+
12
+ private $stickies = null;
13
+
14
+ public function __construct() {
15
+ $this->set_type( 'column-sticky' );
16
+ $this->set_label( __( 'Sticky', 'codepress-admin-columns' ) );
17
+ }
18
+
19
+ function is_valid() {
20
+ return 'post' == $this->get_post_type();
21
+ }
22
+
23
+ function get_value( $post_id ) {
24
+ return ac_helper()->icon->yes_or_no( $this->is_sticky( $post_id ) );
25
+ }
26
+
27
+ function get_raw_value( $post_id ) {
28
+ return $this->is_sticky( $post_id );
29
+ }
30
+
31
+ // Helpers
32
+ private function is_sticky( $post_id ) {
33
+ if ( null === $this->stickies ) {
34
+ $this->stickies = get_option( 'sticky_posts' );
35
+ }
36
+
37
+ return in_array( $post_id, (array) $this->stickies );
38
+ }
39
+
40
+ }
classes/Column/Post/Tags.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Tags extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'tags' );
15
+ }
16
+
17
+ public function register_settings() {
18
+ $this->get_setting( 'width' )->set_default( 15 );
19
+ }
20
+
21
+ public function get_taxonomy() {
22
+ return 'post_tag';
23
+ }
24
+
25
+ public function is_valid() {
26
+ return ac_helper()->taxonomy->is_taxonomy_registered( $this->get_post_type(), $this->get_taxonomy() );
27
+ }
28
+
29
+ }
classes/Column/Post/Taxonomy.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Taxonomy extends AC_Column_Taxonomy {
11
+
12
+ /**
13
+ * @return bool True when post type has associated taxonomies
14
+ */
15
+ public function is_valid() {
16
+ return get_object_taxonomies( $this->get_post_type() ) ? true : false;
17
+ }
18
+
19
+ }
classes/Column/Post/Title.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_Post_Title extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'title' );
15
+ }
16
+
17
+ public function is_valid() {
18
+ return post_type_supports( $this->get_post_type(), 'title' );
19
+ }
20
+
21
+ }
classes/Column/Post/TitleRaw.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.2.4
9
+ */
10
+ class AC_Column_Post_TitleRaw extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-title_raw' );
14
+ $this->set_label( __( 'Title without actions', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ function get_value( $post_id ) {
18
+ return $this->get_raw_value( $post_id );
19
+ }
20
+
21
+ function get_raw_value( $post_id ) {
22
+ return get_post_field( 'post_title', $post_id );
23
+ }
24
+
25
+ }
classes/Column/Post/WordCount.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_Post_WordCount extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-word_count' );
14
+ $this->set_label( __( 'Word Count', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $post_id ) {
18
+ return ac_helper()->string->word_count( get_post_field( 'post_content', $post_id ) );
19
+ }
20
+
21
+ function is_valid() {
22
+ return post_type_supports( $this->get_post_type(), 'editor' );
23
+ }
24
+
25
+ }
classes/Column/Taxonomy.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Taxonomy column, displaying terms from a taxonomy for any object type (i.e. posts)
9
+ * supporting WordPress' native way of handling terms.
10
+ *
11
+ * @since 2.0
12
+ */
13
+ class AC_Column_Taxonomy extends AC_Column {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-taxonomy' );
17
+ $this->set_label( __( 'Taxonomy', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ public function get_taxonomy() {
21
+ return $this->get_option( 'taxonomy' );
22
+ }
23
+
24
+ // Display
25
+
26
+ public function get_value( $post_id ) {
27
+ return implode( __( ', ' ), ac_helper()->taxonomy->get_term_links( get_the_terms( $post_id, $this->get_taxonomy() ), get_post_type( $post_id ) ) );
28
+ }
29
+
30
+ public function get_raw_value( $post_id ) {
31
+ $terms = wp_get_post_terms( $post_id, $this->get_taxonomy(), array( 'fields' => 'ids' ) );
32
+
33
+ if ( ! $terms || is_wp_error( $terms ) ) {
34
+ return false;
35
+ }
36
+
37
+ return $terms;
38
+ }
39
+
40
+ // Settings
41
+
42
+ public function register_settings() {
43
+ $this->add_setting( new AC_Settings_Column_Taxonomy( $this ) );
44
+ }
45
+
46
+ }
classes/Column/UsedByMenu.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Column displaying the menus the item is used in. Supported by all object types that
9
+ * can be referenced in menus (i.e. posts).
10
+ *
11
+ * @since 2.2.5
12
+ */
13
+ class AC_Column_UsedByMenu extends AC_Column {
14
+
15
+ public function __construct() {
16
+ $this->set_type( 'column-used_by_menu' );
17
+ $this->set_label( __( 'Used by Menu', 'codepress-admin-columns' ) );
18
+ }
19
+
20
+ /**
21
+ * @see AC_Column::get_raw_value()
22
+ * @since 2.2.5
23
+ */
24
+ function get_raw_value( $object_id ) {
25
+ $object_type = $this->get_post_type();
26
+
27
+ if ( ! $object_type ) {
28
+ $object_type = $this->get_taxonomy();
29
+ }
30
+
31
+ if ( ! $object_type ) {
32
+ $object_type = $this->get_list_screen()->get_meta_type();
33
+ }
34
+
35
+ $menu_item_ids = get_posts( array(
36
+ 'post_type' => 'nav_menu_item',
37
+ 'posts_per_page' => -1,
38
+ 'post_status' => 'publish',
39
+ 'fields' => 'ids',
40
+ 'meta_query' => array(
41
+ array(
42
+ 'key' => '_menu_item_object_id',
43
+ 'value' => $object_id,
44
+ ),
45
+ array(
46
+ 'key' => '_menu_item_object',
47
+ 'value' => $object_type,
48
+ ),
49
+ ),
50
+ ) );
51
+
52
+ if ( ! $menu_item_ids ) {
53
+ return false;
54
+ }
55
+
56
+ $menu_ids = wp_get_object_terms( $menu_item_ids, 'nav_menu', array( 'fields' => 'ids' ) );
57
+
58
+ if ( ! $menu_ids || is_wp_error( $menu_ids ) ) {
59
+ return false;
60
+ }
61
+
62
+ return $menu_ids;
63
+ }
64
+
65
+ public function register_settings() {
66
+ $this->add_setting( new AC_Settings_Column_LinkToMenu( $this ) );
67
+ }
68
+
69
+ public function is_valid() {
70
+ return in_array( $this->get_list_screen()->get_meta_type(), array( 'post', 'user', 'term', 'comment' ) );
71
+ }
72
+
73
+ }
classes/Column/User/Actions.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_Actions extends AC_Column_Actions {
11
+
12
+ protected function get_object_type() {
13
+ return 'user';
14
+ }
15
+
16
+ }
classes/Column/User/CommentCount.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_CommentCount extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_commentcount' );
14
+ $this->set_label( __( 'Comment Count', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $user_id ) {
18
+ return $this->get_raw_value( $user_id );
19
+ }
20
+
21
+ public function get_raw_value( $user_id ) {
22
+ return get_comments( array(
23
+ 'user_id' => $user_id,
24
+ 'count' => true,
25
+ 'orderby' => false,
26
+ ) );
27
+ }
28
+
29
+ }
classes/Column/User/Description.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_Description extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_description' );
14
+ $this->set_label( __( 'Description', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_raw_value( $user_id ) {
18
+ return get_the_author_meta( 'user_description', $user_id );
19
+ }
20
+
21
+ public function register_settings() {
22
+ $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
23
+ }
24
+
25
+ }
classes/Column/User/DisplayName.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_DisplayName extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-display_name' );
14
+ $this->set_label( __( 'Display Name', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ function get_value( $user_id ) {
18
+ return $this->get_raw_value( $user_id );
19
+ }
20
+
21
+ function get_raw_value( $user_id ) {
22
+ $userdata = get_userdata( $user_id );
23
+
24
+ return $userdata->display_name;
25
+ }
26
+
27
+ }
classes/Column/User/Email.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_Email extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'email' );
15
+ }
16
+
17
+ }
classes/Column/User/FirstName.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_FirstName extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-first_name' );
14
+ $this->set_label( __( 'First Name', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return 'first_name';
19
+ }
20
+
21
+ public function get_value( $user_id ) {
22
+ return $this->get_raw_value( $user_id );
23
+ }
24
+
25
+ public function get_raw_value( $user_id ) {
26
+ return get_user_meta( $user_id, $this->get_meta_key(), true );
27
+ }
28
+
29
+ }
classes/Column/User/ID.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_ID extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_id' );
14
+ $this->set_label( __( 'User ID', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ function get_value( $user_id ) {
18
+ return $this->get_raw_value( $user_id );
19
+ }
20
+
21
+ function get_raw_value( $user_id ) {
22
+ return $user_id;
23
+ }
24
+
25
+ }
classes/Column/User/LastName.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_LastName extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-last_name' );
14
+ $this->set_label( __( 'Last name', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return 'last_name';
19
+ }
20
+
21
+ public function get_value( $user_id ) {
22
+ return $this->get_raw_value( $user_id );
23
+ }
24
+
25
+ public function get_raw_value( $user_id ) {
26
+ return $this->get_meta_value( $user_id, $this->get_meta_key() );
27
+ }
28
+
29
+ }
classes/Column/User/Name.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_Name extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'name' );
15
+ }
16
+
17
+ }
classes/Column/User/Nickname.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_Nickname extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-nickname' );
14
+ $this->set_label( __( 'Nickname', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_meta_key() {
18
+ return 'nickname';
19
+ }
20
+
21
+ public function get_value( $user_id ) {
22
+ return $this->get_raw_value( $user_id );
23
+ }
24
+
25
+ public function get_raw_value( $user_id ) {
26
+ return $this->get_meta_value( $user_id, $this->get_meta_key() );
27
+ }
28
+
29
+ }
classes/Column/User/PostCount.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_PostCount extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_postcount' );
14
+ $this->set_label( __( 'Post Count', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ /**
18
+ * Get count
19
+ *
20
+ * @since 2.0
21
+ */
22
+ public function get_count( $user_id ) {
23
+ return ac_helper()->user->get_postcount( $user_id, $this->get_option( 'post_type' ) );
24
+ }
25
+
26
+ public function get_value( $user_id ) {
27
+ $value = $this->get_empty_char();
28
+ $count = $this->get_raw_value( $user_id );
29
+
30
+ if ( $count > 0 ) {
31
+ $link = add_query_arg( array( 'post_type' => $this->get_option( 'post_type' ), 'author' => $user_id ), admin_url( 'edit.php' ) );
32
+ $value = ac_helper()->html->link( $link, $count );
33
+ }
34
+
35
+ return $value;
36
+ }
37
+
38
+ public function get_raw_value( $user_id ) {
39
+ return $this->get_count( $user_id );
40
+ }
41
+
42
+ protected function register_settings() {
43
+ $this->add_setting( new AC_Settings_Column_PostType( $this ) );
44
+ }
45
+
46
+ }
classes/Column/User/Posts.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_Posts extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'posts' );
15
+ }
16
+
17
+ }
classes/Column/User/Registered.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_Registered extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_registered' );
14
+ $this->set_label( __( 'Registered', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $user_id ) {
18
+ return $this->get_formatted_value( get_date_from_gmt( $this->get_raw_value( $user_id ) ) );
19
+ }
20
+
21
+ public function get_raw_value( $user_id ) {
22
+ return get_userdata( $user_id )->user_registered;
23
+ }
24
+
25
+ public function register_settings() {
26
+ $this->add_setting( new AC_Settings_Column_Date( $this ) );
27
+ }
28
+
29
+ }
classes/Column/User/RichEditing.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Column_User_RichEditing extends AC_Column {
8
+
9
+ public function __construct() {
10
+ $this->set_type( 'column-rich_editing' );
11
+ $this->set_label( __( 'Visual Editor', 'codepress-admin-columns' ) );
12
+ }
13
+
14
+ public function get_value( $user_id ) {
15
+ return ac_helper()->icon->yes_or_no( $this->has_rich_editing( $user_id ) );
16
+ }
17
+
18
+ public function get_raw_value( $user_id ) {
19
+ return $this->has_rich_editing( $user_id );
20
+ }
21
+
22
+ private function has_rich_editing( $user_id ) {
23
+ $userdata = get_userdata( $user_id );
24
+
25
+ return $userdata->rich_editing == 'true' ? true : false;
26
+ }
27
+
28
+ }
classes/Column/User/Role.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_Role extends AC_Column_Meta {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'role' );
14
+ $this->set_original( true );
15
+ }
16
+
17
+ public function get_value( $id ) {
18
+ return null;
19
+ }
20
+
21
+ // Meta
22
+
23
+ public function get_meta_key() {
24
+ global $wpdb;
25
+
26
+ return $wpdb->get_blog_prefix() . 'capabilities'; // WPMU compatible
27
+ }
28
+
29
+ // Settings
30
+
31
+ public function register_settings() {
32
+ $this->get_setting( 'width' )->set_default( 15 );
33
+ }
34
+
35
+ }
classes/Column/User/ShowToolbar.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_ShowToolbar extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_show_toolbar' );
14
+ $this->set_label( __( 'Show Toolbar', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $user_id ) {
18
+ return ac_helper()->icon->yes_or_no( 'true' == $this->show_admin_bar_front( $user_id ) );
19
+ }
20
+
21
+ public function get_raw_value( $user_id ) {
22
+ return $this->show_admin_bar_front( $user_id );
23
+ }
24
+
25
+ private function show_admin_bar_front( $user_id ) {
26
+ $userdata = get_userdata( $user_id );
27
+
28
+ return $userdata->show_admin_bar_front;
29
+ }
30
+
31
+ }
classes/Column/User/Url.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_Column_User_Url extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_type( 'column-user_url' );
14
+ $this->set_label( __( 'Website', 'codepress-admin-columns' ) );
15
+ }
16
+
17
+ public function get_value( $user_id ) {
18
+ return $this->get_raw_value( $user_id );
19
+ }
20
+
21
+ public function get_raw_value( $user_id ) {
22
+ $userdata = get_userdata( $user_id );
23
+
24
+ return $userdata->user_url;
25
+ }
26
+
27
+ }
classes/Column/User/Username.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 3.0
9
+ */
10
+ class AC_Column_User_Username extends AC_Column {
11
+
12
+ public function __construct() {
13
+ $this->set_original( true );
14
+ $this->set_type( 'username' );
15
+ }
16
+
17
+ }
classes/Column/WooCommercePlaceholder.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.4.7
9
+ */
10
+ class AC_Column_WooCommercePlaceholder extends AC_Column_Placeholder {
11
+
12
+ public function is_valid() {
13
+ return in_array( $this->get_post_type(), array( 'product', 'shop_order', 'shop_coupon' ) );
14
+ }
15
+
16
+ }
classes/Groups.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Holds the groups to which columns can belong.
9
+ */
10
+ final class AC_Groups {
11
+
12
+ const SORT_PRIORITY = 1;
13
+
14
+ const SORT_SLUG = 2;
15
+
16
+ const SORT_LABEL = 3;
17
+
18
+ /**
19
+ * @var array
20
+ */
21
+ private $groups = array();
22
+
23
+ /**
24
+ * @return array
25
+ */
26
+ public function get_groups() {
27
+ return $this->groups;
28
+ }
29
+
30
+ /**
31
+ * Return the registered groups sorted by either label, slug or priority
32
+ *
33
+ * @param int $sort_by Default is self::SORT_PRIORITY
34
+ *
35
+ * @return array
36
+ */
37
+ public function get_groups_sorted( $sort_by = null ) {
38
+ switch ( $sort_by ) {
39
+ case self::SORT_LABEL :
40
+ $sorted = $this->sort_groups_by_string( $this->get_groups(), 'label' );
41
+
42
+ break;
43
+ case self::SORT_SLUG :
44
+ $sorted = $this->sort_groups_by_string( $this->get_groups(), 'slug' );
45
+
46
+ break;
47
+ default :
48
+ $sorted = $this->sort_groups_by_priority( $this->get_groups() );
49
+ }
50
+
51
+ return $sorted;
52
+ }
53
+
54
+ /**
55
+ * Sort the group by priority
56
+ *
57
+ * If there are more groups with the same priority it will those groups by label
58
+ *
59
+ * @param $groups
60
+ *
61
+ * @return array
62
+ */
63
+ private function sort_groups_by_priority( array $groups ) {
64
+ $aggregated = $sorted = array();
65
+
66
+ foreach ( $groups as $group ) {
67
+ $aggregated[ $group['priority'] ][] = $group;
68
+ }
69
+
70
+ ksort( $aggregated, SORT_NUMERIC );
71
+
72
+ foreach ( $aggregated as $priority => $groups ) {
73
+ $sorted = array_merge( $sorted, $this->sort_groups_by_string( $groups, 'label' ) );
74
+ }
75
+
76
+ return $sorted;
77
+ }
78
+
79
+ /**
80
+ * Sort the group by label or slug
81
+ *
82
+ * @param array $groups
83
+ * @param string $key
84
+ *
85
+ * @return array
86
+ */
87
+ private function sort_groups_by_string( array $groups, $key ) {
88
+ $sorted = array();
89
+
90
+ foreach ( $groups as $k => $group ) {
91
+ $sorted[ $k ] = $group[ $key ];
92
+ }
93
+
94
+ natcasesort( $sorted );
95
+
96
+ foreach ( array_keys( $sorted ) as $k ) {
97
+ $sorted[ $k ] = $groups[ $k ];
98
+ }
99
+
100
+ return $sorted;
101
+ }
102
+
103
+ /**
104
+ * @param string $slug
105
+ *
106
+ * @return bool|mixed
107
+ */
108
+ public function get_group( $slug ) {
109
+ if ( ! $this->has_group( $slug ) ) {
110
+ return false;
111
+ }
112
+
113
+ return $this->groups[ $slug ];
114
+ }
115
+
116
+ public function get_group_label( $slug ) {
117
+ $group = $this->get_group( $slug );
118
+
119
+ return $group ? $group['label'] : false;
120
+ }
121
+
122
+ /**
123
+ * @param string $slug
124
+ *
125
+ * @return bool
126
+ */
127
+ public function has_group( $slug ) {
128
+ return isset( $this->groups[ $slug ] );
129
+ }
130
+
131
+ /**
132
+ * Register a (column) group
133
+ *
134
+ * @param string $slug
135
+ * @param string $label Should be translatable
136
+ * @param int $priority
137
+ *
138
+ * @return bool
139
+ */
140
+ public function register_group( $slug, $label, $priority = 10 ) {
141
+ if ( $this->has_group( $slug ) ) {
142
+ return false;
143
+ }
144
+
145
+ $this->groups[ $slug ] = array(
146
+ 'slug' => $slug,
147
+ 'label' => $label,
148
+ 'priority' => $priority,
149
+ );
150
+
151
+ return true;
152
+ }
153
+
154
+ }
classes/Helper.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Class AC_Helper
9
+ *
10
+ * Implements __call to work around any keyword restrictions for PHP versions > 7
11
+ *
12
+ * @property AC_Helper_Array array
13
+ * @property AC_Helper_Date date
14
+ * @property AC_Helper_Image image
15
+ * @property AC_Helper_Post post
16
+ * @property AC_Helper_String string
17
+ * @property AC_Helper_Taxonomy taxonomy
18
+ * @property AC_Helper_User user
19
+ * @property AC_Helper_Icon icon
20
+ * @property AC_Helper_Html html
21
+ * @property AC_Helper_Network network
22
+ * @property AC_Helper_File file
23
+ */
24
+ final class AC_Helper {
25
+
26
+ public function __get( $helper ) {
27
+ $class = 'AC_Helper_' . ucfirst( $helper );
28
+
29
+ if ( class_exists( 'AC_Helper_' . ucfirst( $helper ) ) ) {
30
+ return new $class;
31
+ }
32
+
33
+ return false;
34
+ }
35
+
36
+ }
classes/Helper/Array.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Array {
8
+
9
+ /**
10
+ * Implode for multi dimensional array
11
+ *
12
+ * @since 3.0
13
+ *
14
+ * @param string $glue
15
+ * @param string|array $pieces
16
+ *
17
+ * @return string Imploded array
18
+ */
19
+ public function implode_recursive( $glue, $pieces ) {
20
+ if ( is_array( $pieces ) ) {
21
+ foreach ( $pieces as $r_pieces ) {
22
+ if ( is_array( $r_pieces ) ) {
23
+ $retVal[] = $this->implode_recursive( $glue, $r_pieces );
24
+ } else {
25
+ $retVal[] = $r_pieces;
26
+ }
27
+ }
28
+ if ( isset( $retVal ) && is_array( $retVal ) ) {
29
+ return implode( $glue, $retVal );
30
+ }
31
+ }
32
+
33
+ if ( is_scalar( $pieces ) ) {
34
+ return $pieces;
35
+ }
36
+
37
+ return false;
38
+ }
39
+
40
+ /**
41
+ * Replace a single key in an associative array
42
+ *
43
+ * @since 2.2.7
44
+ *
45
+ * @param array $input Input array.
46
+ * @param int|string $old_key Key to replace.
47
+ * @param int|string $new_key Key to replace $old_key with
48
+ */
49
+ public function key_replace( $input, $old_key, $new_key ) {
50
+ $keys = array_keys( $input );
51
+ $old_key_pos = array_search( $old_key, $keys );
52
+
53
+ if ( $old_key_pos === false ) {
54
+ return $input;
55
+ }
56
+
57
+ $keys[ $old_key_pos ] = $new_key;
58
+
59
+ return array_combine( $keys, array_values( $input ) );
60
+ }
61
+
62
+ /**
63
+ * Indents any object as long as it has a unique id and that of its parent.
64
+ *
65
+ * @since 1.0
66
+ *
67
+ * @param array $array
68
+ * @param int $parentId
69
+ * @param string $parentKey
70
+ * @param string $selfKey
71
+ * @param string $childrenKey
72
+ *
73
+ * @return array Indented Array
74
+ */
75
+ public function indent( $array, $parentId = 0, $parentKey = 'post_parent', $selfKey = 'ID', $childrenKey = 'children' ) {
76
+ $indent = array();
77
+
78
+ $i = 0;
79
+ foreach ( $array as $v ) {
80
+ if ( $v->$parentKey == $parentId ) {
81
+ $indent[ $i ] = $v;
82
+ $indent[ $i ]->$childrenKey = $this->indent( $array, $v->$selfKey, $parentKey, $selfKey );
83
+
84
+ $i++;
85
+ }
86
+ }
87
+
88
+ return $indent;
89
+ }
90
+
91
+ /**
92
+ * Remove empty values from array
93
+ *
94
+ * @param array $array
95
+ *
96
+ * @return array
97
+ */
98
+ public function filter( $array ) {
99
+ return array_filter( $array, array( ac_helper()->string, 'is_not_empty' ) );
100
+ }
101
+
102
+ /**
103
+ * Insert element into array at specific position
104
+ *
105
+ * @param array $array
106
+ * @param array $insert
107
+ * @param string $position
108
+ *
109
+ * @return array
110
+ */
111
+ public function insert( $array, $insert, $position ) {
112
+ $new = array();
113
+ foreach ( $array as $key => $value ) {
114
+ $new[ $key ] = $value;
115
+ if ( $key === $position ) {
116
+ $new = array_merge( $new, $insert );
117
+ }
118
+
119
+ }
120
+
121
+ return $new;
122
+ }
123
+
124
+ /**
125
+ * Get duplicates from array
126
+ *
127
+ * @param array $array
128
+ *
129
+ * @return array
130
+ */
131
+ public function get_duplicates( array $array ) {
132
+ return array_intersect( $array, array_unique( array_diff_key( $array, array_unique( $array ) ) ) );
133
+ }
134
+
135
+ }
classes/Helper/Date.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Date {
8
+
9
+ /**
10
+ * @param string $date
11
+ *
12
+ * @return int|false
13
+ */
14
+ public function strtotime( $date ) {
15
+ if ( empty( $date ) || in_array( $date, array( '0000-00-00 00:00:00', '0000-00-00', '00:00:00' ) ) || ! is_scalar( $date ) ) {
16
+ return false;
17
+ }
18
+
19
+ // some plugins store dates in a jquery timestamp format, format is in ms since The Epoch.
20
+ // See http://api.jqueryui.com/datepicker/#utility-formatDate
21
+ if ( is_numeric( $date ) ) {
22
+ $length = strlen( trim( $date ) );
23
+
24
+ // Dates before / around September 8th, 2001 are saved as 9 numbers * 1000 resulting in 12 numbers to store the time.
25
+ // Dates after September 8th are saved as 10 numbers * 1000, resulting in 13 numbers.
26
+ // For example the ACF Date and Time Picker uses this format.
27
+ // credits: Ben C
28
+ if ( 12 === $length || 13 === $length ) {
29
+ $date = round( $date / 1000 ); // remove the ms
30
+ }
31
+
32
+ // Date format: yyyymmdd ( often used by ACF ) must start with 19xx or 20xx and is 8 long
33
+ // @todo: in theory a numeric string of 8 can also be a unix timestamp; no conversion would be needed
34
+ if ( 8 === $length && ( strpos( $date, '20' ) === 0 || strpos( $date, '19' ) === 0 ) ) {
35
+ $date = strtotime( $date );
36
+ }
37
+ } else {
38
+ $date = strtotime( $date );
39
+ }
40
+
41
+ return $date;
42
+ }
43
+
44
+ /**
45
+ * @param string $date
46
+ * @param string $format
47
+ *
48
+ * @return int|false
49
+ */
50
+ public function get_timestamp_from_format( $date, $format ) {
51
+ if ( ! $date ) {
52
+ return false;
53
+ }
54
+
55
+ // Already a timestamp
56
+ if ( 'U' === $format ) {
57
+ return $date;
58
+ }
59
+
60
+ $timestamp = false;
61
+
62
+ // since PHP 5.3.0
63
+ // Create timestamp from a specific date format
64
+ if ( function_exists( 'date_create_from_format' ) && $format ) {
65
+ if ( $date = date_create_from_format( $format, $date ) ) {
66
+ $timestamp = date_format( $date, 'U' );
67
+ }
68
+ } // before PHP 5.3.0
69
+ else {
70
+ $timestamp = $this->strtotime( $date );
71
+ }
72
+
73
+ return $timestamp;
74
+ }
75
+
76
+ /**
77
+ * @since 1.3.1
78
+ *
79
+ * @param string $date PHP Date format
80
+ * @param string $display_format Date display format
81
+ *
82
+ * @return string Formatted date
83
+ */
84
+ public function date( $date, $display_format = '' ) {
85
+ $timestamp = ac_helper()->date->strtotime( $date );
86
+
87
+ return $this->date_by_timestamp( $timestamp, $display_format );
88
+ }
89
+
90
+ /**
91
+ * @since 3.0
92
+ *
93
+ * @param string $date PHP Date format
94
+ * @param string $display_format Date display format
95
+ *
96
+ * @return string Formatted date
97
+ */
98
+ public function date_by_timestamp( $timestamp, $display_format = '' ) {
99
+ if ( ! $timestamp ) {
100
+ return false;
101
+ }
102
+
103
+ // Get date format from the General Settings
104
+ if ( ! $display_format ) {
105
+ $display_format = get_option( 'date_format' );
106
+ }
107
+
108
+ // Fallback in case the date format from General Settings is empty
109
+ if ( ! $display_format ) {
110
+ $display_format = 'F j, Y';
111
+ }
112
+
113
+ return date_i18n( $display_format, $timestamp );
114
+ }
115
+
116
+ /**
117
+ * @since 1.3.1
118
+ *
119
+ * @param string $date
120
+ *
121
+ * @return string Formatted time
122
+ */
123
+ public function time( $date, $format = '' ) {
124
+ $timestamp = ac_helper()->date->strtotime( $date );
125
+
126
+ if ( ! $format ) {
127
+ $format = get_option( 'time_format' );
128
+ }
129
+
130
+ if ( ! $timestamp ) {
131
+ return false;
132
+ }
133
+
134
+ return date_i18n( $format, $timestamp );
135
+ }
136
+
137
+ /**
138
+ * Translate a jQuery date format to the PHP date format
139
+ *
140
+ * @since 1.1
141
+ *
142
+ * @param string $format jQuery date format
143
+ *
144
+ * @return string PHP date format
145
+ */
146
+ public function parse_jquery_dateformat( $format ) {
147
+ $replace = array(
148
+ '^dd^d' => 'j',
149
+ 'dd' => 'd',
150
+ 'DD' => 'l',
151
+ 'o' => 'z',
152
+ 'MM' => 'F',
153
+ '^mm^m' => 'n',
154
+ 'mm' => 'm',
155
+ 'yy' => 'Y',
156
+ );
157
+
158
+ $replace_from = array();
159
+ $replace_to = array();
160
+
161
+ foreach ( $replace as $from => $to ) {
162
+ $replace_from[] = '/' . $from . '/';
163
+ $replace_to[] = $to;
164
+ }
165
+
166
+ return preg_replace( $replace_from, $replace_to, $format );
167
+ }
168
+
169
+ }
classes/Helper/File.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_File {
8
+
9
+ /**
10
+ * Convert file size to readable format
11
+ *
12
+ * @since 1.4.5
13
+ *
14
+ * @param string $size Size in bytes
15
+ * @param int $decimals
16
+ *
17
+ * @return string|false Readable file size
18
+ */
19
+ public function get_readable_filesize( $bytes, $decimals = 2, $empty_text = false ) {
20
+ if ( ! $bytes ) {
21
+ return $empty_text;
22
+ }
23
+
24
+ $filesize_units = array( 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' );
25
+
26
+ $i = (int) floor( log( $bytes, 1024 ) );
27
+
28
+ return round( $bytes / pow( 1024, $i ), $decimals ) . ' ' . $filesize_units[ $i ];
29
+ }
30
+
31
+ }
classes/Helper/Html.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Html {
8
+
9
+ /**
10
+ * @param string $key
11
+ * @param string $value
12
+ *
13
+ * @since 3.0
14
+ * @return string
15
+ */
16
+ public function get_attribute_as_string( $key, $value ) {
17
+ return sprintf( '%s="%s"', $key, esc_attr( trim( $value ) ) );
18
+ }
19
+
20
+ /**
21
+ * @param array $attributes
22
+ *
23
+ * @since 3.0
24
+ * @return string
25
+ */
26
+ public function get_attributes_as_string( array $attributes ) {
27
+ $output = array();
28
+
29
+ foreach ( $attributes as $key => $value ) {
30
+ $output[] = $this->get_attribute_as_string( $key, $value );
31
+ }
32
+
33
+ return implode( ' ', $output );
34
+ }
35
+
36
+ /**
37
+ * @param string $url
38
+ * @param string $label
39
+ *
40
+ * @return string|false HTML Anchor element
41
+ */
42
+ public function link( $url, $label = null, $attributes = array() ) {
43
+ if ( false === $label ) {
44
+ return $label;
45
+ }
46
+
47
+ if ( ! $url ) {
48
+ return $label;
49
+ }
50
+
51
+ if ( null === $label ) {
52
+ $label = $url;
53
+ }
54
+
55
+ if ( ! $label ) {
56
+ return false;
57
+ }
58
+
59
+ if ( ! $this->contains_html( $label ) ) {
60
+ $label = esc_html( $label );
61
+ }
62
+
63
+ if ( array_key_exists( 'tooltip', $attributes ) ) {
64
+ $attributes['data-ac-tip'] = $attributes['tooltip'];
65
+ unset( $attributes['tooltip'] );
66
+ }
67
+
68
+ $allowed = wp_allowed_protocols();
69
+ $allowed[] = 'skype';
70
+ $allowed[] = 'call';
71
+
72
+ return '<a href="' . esc_url( $url, $allowed ) . '" ' . $this->get_attributes( $attributes ) . '>' . $label . '</a>';
73
+ }
74
+
75
+ /**
76
+ * @since 2.5
77
+ */
78
+ public function divider() {
79
+ return '<span class="ac-divider"></span>';
80
+ }
81
+
82
+ /**
83
+ * @param string $content
84
+ *
85
+ * @return string
86
+ */
87
+ public function get_tooltip_attr( $content ) {
88
+ if ( ! $content ) {
89
+ return false;
90
+ }
91
+
92
+ return 'data-ac-tip="' . esc_attr( $content ) . '"';
93
+ }
94
+
95
+ /**
96
+ * @param $label
97
+ * @param $tooltip
98
+ *
99
+ * @return string
100
+ */
101
+ public function tooltip( $label, $tooltip ) {
102
+ if ( $label && $tooltip ) {
103
+ $label = '<span ' . $this->get_tooltip_attr( $tooltip ) . '>' . $label . '</span>';
104
+ }
105
+
106
+ return $label;
107
+ }
108
+
109
+ /**
110
+ * Displays a toggle Box.
111
+ *
112
+ * @param string $label
113
+ * @param string $contents
114
+ */
115
+ public function toggle_box( $label, $contents ) {
116
+ if ( ! $label ) {
117
+ return;
118
+ }
119
+
120
+ if ( $contents ) : ?>
121
+ <a class="ac-toggle-box-link" href="#"><?php echo $label; ?></a>
122
+ <div class="ac-toggle-box-contents"><?php echo $contents; ?></div>
123
+ <?php
124
+ else :
125
+ echo $label;
126
+ endif;
127
+ }
128
+
129
+ /**
130
+ * Display a toggle box which trigger an ajax event on click. The ajax callback calls AC_Column::get_ajax_value.
131
+ *
132
+ * @param int $id
133
+ * @param string $label
134
+ * @param string $column_name
135
+ *
136
+ * @return string|false HTML
137
+ */
138
+ public function toggle_box_ajax( $id, $label, $column_name ) {
139
+ if ( ! $label ) {
140
+ return false;
141
+ }
142
+
143
+ return ac_helper()->html->link( '#', $label . '<div class="spinner"></div>', array(
144
+ 'class' => 'ac-toggle-box-link',
145
+ 'data-column' => $column_name,
146
+ 'data-item-id' => $id,
147
+ 'data-ajax-populate' => 1,
148
+ ) );
149
+ }
150
+
151
+ /**
152
+ * @param string $string
153
+ * @param int $max_chars
154
+ *
155
+ * @return string
156
+ */
157
+ public function codearea( $string, $max_chars = 1000 ) {
158
+ if ( ! $string ) {
159
+ return false;
160
+ }
161
+
162
+ return '<textarea style="color: #808080; width: 100%; min-height: 60px;" readonly>' . substr( $string, 0, $max_chars ) . '</textarea>';
163
+ }
164
+
165
+ /**
166
+ * @param array $attributes
167
+ *
168
+ * @return string
169
+ */
170
+ private function get_attributes( $attributes ) {
171
+ $_attributes = array();
172
+
173
+ foreach ( $attributes as $attribute => $value ) {
174
+ if ( in_array( $attribute, array( 'title', 'id', 'class', 'style', 'target' ) ) || 'data-' === substr( $attribute, 0, 5 ) ) {
175
+ $_attributes[] = $this->get_attribute_as_string( $attribute, $value );
176
+ }
177
+ }
178
+
179
+ return ' ' . implode( ' ', $_attributes );
180
+ }
181
+
182
+ /**
183
+ * @param string $string
184
+ *
185
+ * @return bool
186
+ */
187
+ private function contains_html( $string ) {
188
+ return $string && is_string( $string ) ? $string !== strip_tags( $string ) : false;
189
+ }
190
+
191
+ /**
192
+ * Display indicator icon in the column settings header
193
+ *
194
+ * @param string $name
195
+ */
196
+ public function indicator( $class, $id, $title = false ) { ?>
197
+ <span class="indicator-<?php echo esc_attr( $class ); ?>" data-indicator-id="<?php echo esc_attr( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"></span>
198
+ <?php
199
+ }
200
+
201
+ /**
202
+ * Adds a divider to the implode
203
+ *
204
+ * @param $array
205
+ *
206
+ * @return string
207
+ */
208
+ public function implode( $array, $divider = true ) {
209
+ if ( ! is_array( $array ) ) {
210
+ return $array;
211
+ }
212
+
213
+ // Remove empty values
214
+ $array = $this->remove_empty( $array );
215
+
216
+ if ( true === $divider ) {
217
+ $divider = $this->divider();
218
+ }
219
+
220
+ return implode( $divider, $array );
221
+ }
222
+
223
+ public function remove_empty( $array ) {
224
+ return array_filter( $array, array( ac_helper()->string, 'is_not_empty' ) );
225
+ }
226
+
227
+ /**
228
+ * Remove attribute from an html tag
229
+ *
230
+ * @param string $html HTML tag
231
+ * @param string|array $attribute Attribute: style, class, alt, data etc.
232
+ *
233
+ * @return mixed
234
+ */
235
+ public function strip_attributes( $html, $attributes ) {
236
+ if ( $this->contains_html( $html ) ) {
237
+ foreach ( (array) $attributes as $attribute ) {
238
+ $html = preg_replace( '/(<[^>]+) ' . $attribute . '=".*?"/i', '$1', $html );
239
+ }
240
+ }
241
+
242
+ return $html;
243
+ }
244
+
245
+ /**
246
+ * Small HTML block with grey background and rounded corners
247
+ *
248
+ * @param string|array $items
249
+ *
250
+ * @return string
251
+ */
252
+ public function small_block( $items ) {
253
+ $blocks = array();
254
+
255
+ foreach ( (array) $items as $item ) {
256
+ if ( $item && is_string( $item ) ) {
257
+ $blocks[] = '<span class="ac-small-block">' . $item . '</span>';
258
+ }
259
+ }
260
+
261
+ return implode( $blocks );
262
+ }
263
+
264
+ /**
265
+ * @param array $args
266
+ *
267
+ * @return string
268
+ */
269
+ public function progress_bar( $args = array() ) {
270
+ $defaults = array(
271
+ 'current' => 0,
272
+ 'total' => 100, // -1 is infinitive
273
+ 'label_left' => '',
274
+ 'label_right' => '',
275
+ 'label_main' => '',
276
+ );
277
+
278
+ $args = wp_parse_args( $args, $defaults );
279
+
280
+ if ( -1 === $args['total'] ) {
281
+ $args['current'] = 0;
282
+ $args['total'] = 100;
283
+ $args['label_right'] = '&infin;';
284
+ }
285
+
286
+ $args['current'] = absint( $args['current'] );
287
+ $args['total'] = absint( $args['total'] );
288
+
289
+ if ( $args['total'] < 0 ) {
290
+ return false;
291
+ }
292
+
293
+ $percentage = 0;
294
+
295
+ if ( $args['total'] > 0 ) {
296
+ $percentage = round( ( $args['current'] / $args['total'] ) * 100 );
297
+ }
298
+
299
+ // Allowed size is zero, but current has a value
300
+ if ( 0 === $args['total'] && $args['current'] > 0 ) {
301
+ $percentage = 101;
302
+ }
303
+
304
+ $class = '';
305
+ if ( $percentage > 100 ) {
306
+ $percentage = 100;
307
+ $class = ' full';
308
+ }
309
+
310
+ ob_start();
311
+ ?>
312
+ <div class="ac-progress-bar<?php echo esc_attr( $class ); ?>">
313
+ <?php if ( $args['label_main'] ) : ?>
314
+ <span class="ac-label-main"><?php echo esc_html( $args['label_main'] ); ?></span>
315
+ <?php endif; ?>
316
+ <div class="ac-bar-container">
317
+ <span class="ac-label-left"><?php echo esc_html( $args['label_left'] ); ?></span>
318
+ <span class="ac-label-right"><?php echo esc_html( $args['label_right'] ); ?></span>
319
+ <?php if ( $percentage ) : ?>
320
+ <div class="ac-bar" style="width:<?php echo esc_attr( $percentage ); ?>%"></div>
321
+ <?php endif; ?>
322
+ </div>
323
+ </div>
324
+ <?php
325
+
326
+ return ob_get_clean();
327
+ }
328
+
329
+ public function more( $array, $number = 10, $glue = ', ' ) {
330
+ $first_set = array_slice( $array, 0, $number );
331
+ $last_set = array_slice( $array, $number );
332
+
333
+ ob_start();
334
+
335
+ if ( $first_set ) {
336
+
337
+ echo implode( $glue, $first_set );
338
+
339
+ if ( $last_set ) { ?>
340
+ <span class="ac-more-link-show">( <a><?php printf( __( 'Show %s more', 'codepress-admin-columns' ), count( $last_set ) ); ?></a> )</span>
341
+ <span class="ac-show-more-block">
342
+ <?php echo $glue . implode( $glue, $first_set ); ?>
343
+ <br/>
344
+ <span class="ac-more-link-hide">( <a><?php _e( 'Hide', 'codepress-admin-columns' ); ?></a> )</span>
345
+ </span>
346
+ <?php
347
+ }
348
+ }
349
+
350
+ return ob_get_clean();
351
+ }
352
+
353
+ /**
354
+ * Return round HTML span
355
+ *
356
+ * @param $string
357
+ *
358
+ * @return string
359
+ */
360
+ public function rounded( $string ) {
361
+ return '<span class="ac-rounded">' . $string . '</span>';
362
+ }
363
+
364
+ }
classes/Helper/Icon.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Icon {
8
+
9
+ public function dashicon( $args = array() ) {
10
+ $defaults = array(
11
+ 'icon' => '',
12
+ 'title' => '',
13
+ 'class' => '',
14
+ 'tooltip' => '',
15
+ );
16
+
17
+ $data = (object) wp_parse_args( $args, $defaults );
18
+
19
+ $class = 'dashicons dashicons-' . $data->icon;
20
+
21
+ if ( $data->class ) {
22
+ $class .= ' ' . trim( $data->class );
23
+ }
24
+
25
+ $attributes = array();
26
+
27
+ if ( $data->title ) {
28
+ $attributes[] = 'title="' . esc_attr( $data->title ) . '"';
29
+ }
30
+
31
+ if ( $data->tooltip ) {
32
+ $attributes[] = ac_helper()->html->get_tooltip_attr( $data->tooltip );
33
+ }
34
+
35
+ return '<span class="' . esc_attr( $class ) . '" ' . implode( ' ', $attributes ) . '></span>';
36
+ }
37
+
38
+ /**
39
+ * @since 3.0
40
+ * @return string
41
+ */
42
+ public function yes( $tooltip = false, $title = true ) {
43
+ if ( true === $title ) {
44
+ $title = __( 'Yes' );
45
+ }
46
+
47
+ return $this->dashicon( array( 'icon' => 'yes', 'class' => 'green', 'title' => $title, 'tooltip' => $tooltip ) );
48
+ }
49
+
50
+ /**
51
+ * @since 3.0
52
+ * @return string
53
+ */
54
+ public function no( $tooltip = false, $title = true ) {
55
+ if ( true === $title ) {
56
+ $title = __( 'No' );
57
+ }
58
+
59
+ return $this->dashicon( array( 'icon' => 'no', 'class' => 'red', 'title' => $title, 'tooltip' => $tooltip ) );
60
+ }
61
+
62
+ /**
63
+ * @since 3.0
64
+ *
65
+ * @param bool $display
66
+ *
67
+ * @return string HTML Dashicon
68
+ */
69
+ public function yes_or_no( $is_true, $tooltip = '' ) {
70
+ return $is_true ? $this->yes( $tooltip ) : $this->no( $tooltip );
71
+ }
72
+
73
+ }
classes/Helper/Image.php ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Image {
8
+
9
+ /**
10
+ * Resize image
11
+ *
12
+ * @param string $file
13
+ * @param int $max_w
14
+ * @param int $max_h
15
+ * @param bool $crop
16
+ * @param null|string $suffix
17
+ * @param null|string $dest_path
18
+ * @param int $jpeg_quality
19
+ *
20
+ * @return bool|string|WP_Error
21
+ */
22
+ public function resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
23
+ $editor = wp_get_image_editor( $file );
24
+
25
+ if ( is_wp_error( $editor ) ) {
26
+ return false;
27
+ }
28
+
29
+ $editor->set_quality( $jpeg_quality );
30
+
31
+ $resized = $editor->resize( $max_w, $max_h, $crop );
32
+
33
+ if ( is_wp_error( $resized ) ) {
34
+ return false;
35
+ }
36
+
37
+ $dest_file = $editor->generate_filename( $suffix, $dest_path );
38
+ $saved = $editor->save( $dest_file );
39
+
40
+ if ( is_wp_error( $saved ) ) {
41
+ return false;
42
+ }
43
+
44
+ return $dest_file;
45
+ }
46
+
47
+ /**
48
+ * @param int[]|int $ids
49
+ * @param array|string $size
50
+ *
51
+ * @return string HTML Images
52
+ */
53
+ public function get_images_by_ids( $ids, $size ) {
54
+ $images = array();
55
+
56
+ $ids = is_array( $ids ) ? $ids : array( $ids );
57
+ foreach ( $ids as $id ) {
58
+ $images[] = $this->get_image_by_id( $id, $size );
59
+ }
60
+
61
+ return implode( $images );
62
+ }
63
+
64
+ /**
65
+ * @param int $id
66
+ * @param string|array $size
67
+ *
68
+ * @return string
69
+ */
70
+ public function get_image_by_id( $id, $size ) {
71
+ $image = false;
72
+
73
+ if ( ! is_numeric( $id ) ) {
74
+ return false;
75
+ }
76
+
77
+ // Is Image
78
+ if ( $attributes = wp_get_attachment_image_src( $id, $size ) ) {
79
+ $src = $attributes[0];
80
+
81
+ if ( is_array( $size ) ) {
82
+ $image = $this->markup_cover( $src, $size[0], $size[1], $id );
83
+ } else {
84
+ $image = $this->markup( $src, $attributes[1], $attributes[2], $id );
85
+ }
86
+ } // Is File, use icon
87
+ else if ( $attributes = wp_get_attachment_image_src( $id, $size, true ) ) {
88
+ $image = $this->markup( $attributes[0], $this->scale_size( $attributes[1], 0.8 ), $this->scale_size( $attributes[2], 0.8 ), $id, true );
89
+ }
90
+
91
+ return $image;
92
+ }
93
+
94
+ /**
95
+ * @param $size
96
+ * @param int $scale
97
+ *
98
+ * @return float
99
+ */
100
+ private function scale_size( $size, $scale = 1 ) {
101
+ return round( absint( $size ) * $scale );
102
+ }
103
+
104
+ /**
105
+ * @param string $url
106
+ * @param array|string $size
107
+ *
108
+ * @return string
109
+ */
110
+ public function get_image_by_url( $url, $size ) {
111
+ $dimensions = array( 80, 80 );
112
+
113
+ if ( is_string( $size ) && ( $sizes = $this->get_image_sizes_by_name( $size ) ) ) {
114
+ $dimensions = array( $sizes['width'], $sizes['height'] );
115
+ } else if ( is_array( $size ) ) {
116
+ $dimensions = $size;
117
+ }
118
+
119
+ $image_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $url );
120
+
121
+ if ( is_file( $image_path ) ) {
122
+ // try to resize image
123
+ if ( $resized = $this->resize( $image_path, $dimensions[0], $dimensions[1], true ) ) {
124
+ $src = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $resized );
125
+
126
+ $image = $this->markup( $src, $dimensions[0], $dimensions[1] );
127
+ } else {
128
+
129
+ $image = $this->markup( $url, $dimensions[0], $dimensions[1] );
130
+ }
131
+ } // External image
132
+ else {
133
+ $image = $this->markup_cover( $image_path, $dimensions[0], $dimensions[1] );
134
+ }
135
+
136
+ return $image;
137
+ }
138
+
139
+ /**
140
+ * @param mixed $images
141
+ * @param array|string $size
142
+ *
143
+ * @return array
144
+ */
145
+ public function get_images( $images, $size = 'thumbnail' ) {
146
+ $thumbnails = array();
147
+
148
+ foreach ( (array) $images as $value ) {
149
+ if ( ac_helper()->string->is_image( $value ) ) {
150
+ $thumbnails[] = $this->get_image_by_url( $value, $size );
151
+ } // Media Attachment
152
+ else if ( is_numeric( $value ) && wp_get_attachment_url( $value ) ) {
153
+ $thumbnails[] = $this->get_image_by_id( $value, $size );
154
+ }
155
+ }
156
+
157
+ return $thumbnails;
158
+ }
159
+
160
+ /**
161
+ * @param int|string $image ID of Url
162
+ * @param string $size
163
+ *
164
+ * @return string
165
+ */
166
+ public function get_image( $image, $size = 'thumbnail' ) {
167
+ return implode( $this->get_images( $image, $size ) );
168
+ }
169
+
170
+ /**
171
+ * @param string $name
172
+ *
173
+ * @return array Image sizes
174
+ */
175
+ public function get_image_sizes_by_name( $name ) {
176
+ global $_wp_additional_image_sizes;
177
+
178
+ $sizes = false;
179
+
180
+ if ( is_scalar( $name ) && isset( $_wp_additional_image_sizes[ $name ] ) ) {
181
+ $sizes = $_wp_additional_image_sizes[ $name ];
182
+ }
183
+
184
+ return $sizes;
185
+ }
186
+
187
+ /**
188
+ * @param int $attachment_id
189
+ *
190
+ * @return bool|string
191
+ */
192
+ public function get_file_name( $attachment_id ) {
193
+ $file = get_post_meta( $attachment_id, '_wp_attached_file', true );
194
+
195
+ if ( ! $file ) {
196
+ return false;
197
+ }
198
+
199
+ return basename( $file );
200
+ }
201
+
202
+ /**
203
+ * @param int $attachment_id
204
+ *
205
+ * @return string File extension
206
+ */
207
+ public function get_file_extension( $attachment_id ) {
208
+ return pathinfo( $this->get_file_name( $attachment_id ), PATHINFO_EXTENSION );
209
+ }
210
+
211
+ // Helpers
212
+
213
+ private function get_file_tooltip_attr( $media_id ) {
214
+ return ac_helper()->html->get_tooltip_attr( $this->get_file_name( $media_id ) );
215
+ }
216
+
217
+ private function markup_cover( $src, $width, $height, $media_id = null ) {
218
+ ob_start(); ?>
219
+ <span class="ac-image cpac-cover" data-media-id="<?php echo esc_attr( $media_id ); ?>" style="width:<?php echo esc_attr( $width ); ?>px;height:<?php echo esc_attr( $height ); ?>px;background-size:cover;background-image:url(<?php echo esc_attr( $src ); ?>);background-position:center;"<?php echo $this->get_file_tooltip_attr( $media_id ); ?>></span>
220
+
221
+ <?php
222
+ return ob_get_clean();
223
+ }
224
+
225
+ private function markup( $src, $width, $height, $media_id = null, $add_extension = false ) {
226
+ $class = false;
227
+
228
+ if ( $media_id && ! wp_attachment_is_image( $media_id ) ) {
229
+ $class = ' ac-icon';
230
+ }
231
+
232
+ ob_start(); ?>
233
+ <span class="ac-image<?php echo $class; ?>" data-media-id="<?php echo esc_attr( $media_id ); ?>"<?php echo $this->get_file_tooltip_attr( $media_id ); ?>>
234
+ <img style="max-width:<?php echo esc_attr( $width ); ?>px;max-height:<?php echo esc_attr( $height ); ?>px;" src="<?php echo esc_attr( $src ); ?>">
235
+
236
+ <?php if ( $add_extension ) : ?>
237
+ <span class="ac-extension"><?php echo esc_attr( $this->get_file_extension( $media_id ) ); ?></span>
238
+ <?php endif; ?>
239
+
240
+ </span>
241
+
242
+ <?php
243
+ return ob_get_clean();
244
+ }
245
+
246
+ }
classes/Helper/Network.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Network {
8
+
9
+ /**
10
+ * @param int $blog_id
11
+ * @param string $option Option name
12
+ *
13
+ * @return null|string
14
+ */
15
+ public function get_site_option( $blog_id, $option ) {
16
+ global $wpdb;
17
+
18
+ $table = $wpdb->get_blog_prefix( $blog_id ) . 'options';
19
+
20
+ $sql = "
21
+ SELECT {$table}.option_value
22
+ FROM {$table}
23
+ WHERE option_name = %s
24
+ ";
25
+
26
+ return (string) $wpdb->get_var( $wpdb->prepare( $sql, $option) );
27
+ }
28
+
29
+ /**
30
+ * @param int $blog_id
31
+ *
32
+ * @return WP_Theme
33
+ */
34
+ public function get_active_theme( $blog_id ) {
35
+ return wp_get_theme( ac_helper()->network->get_site_option( $blog_id, 'stylesheet' ) );
36
+ }
37
+
38
+ }
classes/Helper/Post.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Post {
8
+
9
+ /**
10
+ * @param int $id
11
+ *
12
+ * @return bool
13
+ */
14
+ public function exists( $id ) {
15
+ return $this->get_raw_field( 'ID', $id ) ? true : false;
16
+ }
17
+
18
+ /**
19
+ * @param int $id Post ID
20
+ *
21
+ * @return false|string Post Title
22
+ */
23
+ public function get_raw_post_title( $id ) {
24
+ return ac_helper()->post->get_raw_field( 'post_title', $id );
25
+ }
26
+
27
+ /**
28
+ * @since 1.0
29
+ *
30
+ * @param int $post_id Post ID
31
+ *
32
+ * @return string Post Excerpt.
33
+ */
34
+ public function excerpt( $post_id, $words = 400 ) {
35
+ global $post;
36
+
37
+ $save_post = $post;
38
+ $post = get_post( $post_id );
39
+
40
+ setup_postdata( $post );
41
+
42
+ $excerpt = get_the_excerpt();
43
+ $post = $save_post;
44
+
45
+ if ( $post ) {
46
+ setup_postdata( $post );
47
+ }
48
+
49
+ return ac_helper()->string->trim_words( $excerpt, $words );
50
+ }
51
+
52
+ /**
53
+ * @param string $post_type
54
+ * @param bool $plural
55
+ *
56
+ * @return bool
57
+ */
58
+ public function get_post_type_label( $post_type, $plural = false ) {
59
+ $post_type = get_post_type_object( $post_type );
60
+
61
+ if ( ! $post_type ) {
62
+ return false;
63
+ }
64
+
65
+ if ( $plural ) {
66
+ return $post_type->labels->name;
67
+ }
68
+
69
+ return $post_type->labels->singular_name;
70
+ }
71
+
72
+ /**
73
+ * @param string $field Field
74
+ * @param int $id Post ID
75
+ *
76
+ * @return string|false
77
+ */
78
+ public function get_raw_field( $field, $id ) {
79
+ global $wpdb;
80
+
81
+ if ( ! $id || ! is_numeric( $id ) ) {
82
+ return false;
83
+ }
84
+
85
+ $sql = "
86
+ SELECT " . $wpdb->_real_escape( $field ) . "
87
+ FROM $wpdb->posts
88
+ WHERE ID = %d
89
+ LIMIT 1
90
+ ";
91
+
92
+ return $wpdb->get_var( $wpdb->prepare( $sql, $id ) );
93
+ }
94
+
95
+ /**
96
+ * Get Post Title or Media Filename
97
+ *
98
+ * @param int|WP_Post $post
99
+ *
100
+ * @return bool|string
101
+ */
102
+ public function get_title( $post ) {
103
+ $post = get_post( $post );
104
+
105
+ if ( ! $post ) {
106
+ return false;
107
+ }
108
+
109
+ $title = $post->post_title;
110
+
111
+ if ( 'attachment' == $post->post_type ) {
112
+ $title = ac_helper()->image->get_file_name( $post->ID );
113
+ }
114
+
115
+ return $title;
116
+ }
117
+
118
+ }
classes/Helper/String.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_String {
8
+
9
+ /**
10
+ * @since 1.3.1
11
+ */
12
+ public function shorten_url( $url ) {
13
+ if ( ! $url ) {
14
+ return false;
15
+ }
16
+
17
+ return ac_helper()->html->link( $url, url_shorten( $url ), array( 'title' => $url ) );
18
+ }
19
+
20
+ /**
21
+ * @since 1.3
22
+ */
23
+ public function strip_trim( $string ) {
24
+ return trim( strip_tags( $string ) );
25
+ }
26
+
27
+ /**
28
+ * Count the number of words in a string (multibyte-compatible)
29
+ *
30
+ * @since 3.0
31
+ *
32
+ * @param $string
33
+ *
34
+ * @return int Number of words
35
+ */
36
+ public function word_count( $string ) {
37
+ if ( empty( $string ) ) {
38
+ return false;
39
+ }
40
+
41
+ $string = $this->strip_trim( $string );
42
+
43
+ if ( empty( $string ) ) {
44
+ return false;
45
+ }
46
+
47
+ $patterns = array(
48
+ 'strip' => '/<[a-zA-Z\/][^<>]*>/',
49
+ 'clean' => '/[0-9.(),;:!?%#$¿\'"_+=\\/-]+/',
50
+ 'w' => '/\S\s+/',
51
+ 'c' => '/\S/',
52
+ );
53
+
54
+ $string = preg_replace( $patterns['strip'], ' ', $string );
55
+ $string = preg_replace( '/&nbsp;|&#160;/i', ' ', $string );
56
+ $string = preg_replace( $patterns['clean'], '', $string );
57
+
58
+ if ( ! strlen( preg_replace( '/\s/', '', $string ) ) ) {
59
+ return 0;
60
+ }
61
+
62
+ return preg_match_all( $patterns['w'], $string, $matches ) + 1;
63
+ }
64
+
65
+ /**
66
+ * @see wp_trim_words();
67
+ *
68
+ * @since 3.0
69
+ *
70
+ * @return string
71
+ */
72
+ public function trim_words( $string = '', $num_words = 30, $more = null ) {
73
+ return $string ? wp_trim_words( $string, $num_words, $more ) : false;
74
+ }
75
+
76
+ /**
77
+ * @param string $string
78
+ * @param int $limit
79
+ *
80
+ * @return string
81
+ */
82
+ public function trim_characters( $string, $limit = 10, $trail = '&hellip;' ) {
83
+ $limit = absint( $limit );
84
+
85
+ if ( 1 > $limit || strlen( $string ) <= $limit ) {
86
+ return $string;
87
+ }
88
+
89
+ return substr( $string, 0, $limit ) . $trail;
90
+ }
91
+
92
+ /**
93
+ * Formats a valid hex color to a 6 digit string, optionally prefixed with a #
94
+ *
95
+ * Example: #FF0 will be fff000 based on the $prefix parameter
96
+ *
97
+ * @param string $hex Valid hex color
98
+ * @param bool $prefix Prefix with a # or not
99
+ *
100
+ * @return string
101
+ */
102
+ protected function hex_format( $hex, $prefix = false ) {
103
+ $hex = ltrim( $hex, '#' );
104
+
105
+ if ( strlen( $hex ) == 3 ) {
106
+ $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
107
+ }
108
+
109
+ if ( $prefix ) {
110
+ $hex = '#' . $hex;
111
+ }
112
+
113
+ return strtolower( $hex );
114
+ }
115
+
116
+ /**
117
+ * Get RGB values from a hex color string
118
+ *
119
+ * @since 3.0
120
+ *
121
+ * @param string $hex Valid hex color
122
+ *
123
+ * @return array
124
+ */
125
+ public function hex_to_rgb( $hex ) {
126
+ $hex = $this->hex_format( $hex );
127
+
128
+ return sscanf( $hex, '%2x%2x%2x' );
129
+ }
130
+
131
+ /**
132
+ * Get contrasting hex color based on given hex color
133
+ *
134
+ * @since 3.0
135
+ *
136
+ * @param string $hex Valid hex color
137
+ *
138
+ * @return string
139
+ */
140
+ public function hex_get_contrast( $hex ) {
141
+ $rgb = $this->hex_to_rgb( $hex );
142
+ $contrast = ( $rgb[0] * 0.299 + $rgb[1] * 0.587 + $rgb[2] * 0.114 ) < 186 ? 'fff' : '333';
143
+
144
+ return $this->hex_format( $contrast, true );
145
+ }
146
+
147
+ /**
148
+ * @since 1.2.0
149
+ *
150
+ * @param string $url
151
+ *
152
+ * @return bool
153
+ */
154
+ public function is_image( $url ) {
155
+ return $url && is_string( $url ) ? in_array( strrchr( $url, '.' ), array( '.jpg', '.jpeg', '.gif', '.png', '.bmp' ) ) : false;
156
+ }
157
+
158
+ /**
159
+ * @since 3.0
160
+ *
161
+ * @param string $string
162
+ *
163
+ * @return array
164
+ */
165
+ public function comma_separated_to_array( $string ) {
166
+ $array = array();
167
+ if ( is_scalar( $string ) ) {
168
+ if ( strpos( $string, ',' ) !== false ) {
169
+ $array = array_filter( explode( ',', ac_helper()->string->strip_trim( str_replace( ' ', '', $string ) ) ) );
170
+ } else {
171
+ $array = array( $string );
172
+ }
173
+ } else if ( is_array( $string ) ) {
174
+ $array = $string;
175
+ }
176
+
177
+ return $array;
178
+ }
179
+
180
+ /**
181
+ * @since 3.0
182
+ *
183
+ * @param string $string
184
+ *
185
+ * @return array
186
+ */
187
+ public function string_to_array_integers( $string ) {
188
+ $values = $this->comma_separated_to_array( $string );
189
+
190
+ foreach ( $values as $k => $value ) {
191
+ if ( ! is_numeric( trim( $value ) ) ) {
192
+ unset( $values[ $k ] );
193
+ }
194
+ }
195
+
196
+ return $values;
197
+ }
198
+
199
+ /**
200
+ * @since 3.0
201
+ *
202
+ * @param string $hex Color Hex Code
203
+ */
204
+ public function get_color_block( $hex ) {
205
+ if ( ! $hex ) {
206
+ return false;
207
+ }
208
+
209
+ return '<div class="cpac-color"><span style="background-color:' . esc_attr( $hex ) . ';color:' . esc_attr( $this->hex_get_contrast( $hex ) ) . '">' . esc_html( $hex ) . '</span></div>';
210
+ }
211
+
212
+ /**
213
+ * @return bool
214
+ */
215
+ public function is_valid_url( $url ) {
216
+ return filter_var( $url, FILTER_VALIDATE_URL ) || preg_match( '/[^\w.-]/', $url );
217
+ }
218
+
219
+ /**
220
+ * @return string Display empty value
221
+ */
222
+ public function get_empty_char() {
223
+ _deprecated_function( __METHOD__, '3.0' );
224
+
225
+ return '&ndash;';
226
+ }
227
+
228
+ /**
229
+ * @param string $string
230
+ *
231
+ * @return bool
232
+ */
233
+ public function contains_html_only( $string ) {
234
+ return strlen( $string ) !== strlen( strip_tags( $string ) );
235
+ }
236
+
237
+ /**
238
+ * @param string $value
239
+ *
240
+ * @return bool
241
+ */
242
+ public function is_empty( $value ) {
243
+ return ! $this->is_not_empty( $value );
244
+ }
245
+
246
+ /**
247
+ * @param string $value
248
+ *
249
+ * @return bool
250
+ */
251
+ public function is_not_empty( $value ) {
252
+ return $value || 0 === $value;
253
+ }
254
+
255
+ /**
256
+ * Return an array into a comma separated sentence. For example [minute, hours, days] becomes: "minute, hours or days".
257
+ *
258
+ * @param array $words
259
+ *
260
+ * @return string
261
+ */
262
+ public function enumeration_list( $words, $compound = 'or' ) {
263
+ if ( empty( $words ) || ! is_array( $words ) ) {
264
+ return false;
265
+ }
266
+
267
+ if ( 'or' === $compound ) {
268
+ $compound = __( ' or ', 'codepress-admin-columns' );
269
+ } else {
270
+ $compound = __( ' and ', 'codepress-admin-columns' );
271
+ }
272
+
273
+ $last = end( $words );
274
+ $delimiter = ', ';
275
+
276
+ return str_replace( $delimiter . $last, $compound . $last, implode( $delimiter, $words ) );
277
+ }
278
+
279
+ }
classes/Helper/Taxonomy.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_Taxonomy {
8
+
9
+ /**
10
+ * @param WP_Term[] $terms Term objects
11
+ * @param null|string $post_type
12
+ *
13
+ * @return array
14
+ */
15
+ public function get_term_links( $terms, $post_type = null ) {
16
+ if ( ! $terms || is_wp_error( $terms ) ) {
17
+ return array();
18
+ }
19
+
20
+ $values = array();
21
+
22
+ foreach ( $terms as $t ) {
23
+ if ( ! is_a( $t, 'WP_Term' ) ) {
24
+ continue;
25
+ }
26
+
27
+ $args = array(
28
+ 'post_type' => $post_type,
29
+ 'taxonomy' => $t->taxonomy,
30
+ 'term' => $t->slug,
31
+ );
32
+
33
+ $page = 'attachment' === $post_type ? 'upload' : 'edit';
34
+
35
+ $values[] = ac_helper()->html->link( add_query_arg( $args, $page . '.php' ), sanitize_term_field( 'name', $t->name, $t->term_id, $t->taxonomy, 'display' ) );
36
+ }
37
+
38
+ return $values;
39
+ }
40
+
41
+ /**
42
+ * @param WP_Term $term
43
+ *
44
+ * @return false|string
45
+ */
46
+ public function get_term_display_name( $term ) {
47
+ if ( ! $term || is_wp_error( $term ) ) {
48
+ return false;
49
+ }
50
+
51
+ return sanitize_term_field( 'name', $term->name, $term->term_id, $term->taxonomy, 'display' );
52
+ }
53
+
54
+ /**
55
+ * @param string $object_type post, page, user etc.
56
+ * @param string $taxonomy Taxonomy Name
57
+ *
58
+ * @return bool
59
+ */
60
+ public function is_taxonomy_registered( $object_type, $taxonomy = '' ) {
61
+ if ( ! $object_type ) {
62
+ return false;
63
+ }
64
+ $taxonomies = get_object_taxonomies( $object_type );
65
+
66
+ if ( ! $taxonomies ) {
67
+ return false;
68
+ }
69
+
70
+ if ( $taxonomy ) {
71
+ return in_array( $taxonomy, $taxonomies );
72
+ }
73
+
74
+ return true;
75
+ }
76
+
77
+ /**
78
+ * @since 3.0
79
+ */
80
+ public function get_taxonomy_selection_options( $post_type ) {
81
+ $taxonomies = get_object_taxonomies( $post_type, 'objects' );
82
+
83
+ $options = array();
84
+ foreach ( $taxonomies as $index => $taxonomy ) {
85
+ if ( $taxonomy->name == 'post_format' ) {
86
+ unset( $taxonomies[ $index ] );
87
+ }
88
+ $options[ $taxonomy->name ] = $taxonomy->label;
89
+ }
90
+
91
+ natcasesort( $options );
92
+
93
+ return $options;
94
+ }
95
+
96
+ /**
97
+ * @param string $field
98
+ * @param int $term_id
99
+ * @param string $taxonomy
100
+ *
101
+ * @since 3.0
102
+ */
103
+ public function get_term_field( $field, $term_id, $taxonomy ) {
104
+ $term = get_term_by( 'id', $term_id, $taxonomy );
105
+
106
+ if ( ! $term || is_wp_error( $term ) ) {
107
+ return false;
108
+ }
109
+
110
+ if ( ! isset( $term->{$field} ) ) {
111
+ return false;
112
+ }
113
+
114
+ return $term->{$field};
115
+ }
116
+
117
+ /**
118
+ * @param int $term_ids
119
+ * @param string $taxonomy
120
+ *
121
+ * @return WP_Term[]
122
+ */
123
+ public function get_terms_by_ids( $term_ids, $taxonomy ) {
124
+ $terms = array();
125
+
126
+ foreach ( (array) $term_ids as $term_id ) {
127
+ $term = get_term( $term_id, $taxonomy );
128
+ if ( $term && ! is_wp_error( $term ) ) {
129
+ $terms[] = $term;
130
+ }
131
+ }
132
+
133
+ return $terms;
134
+ }
135
+
136
+ }
classes/Helper/User.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Helper_User {
8
+
9
+ /**
10
+ * @param string $field
11
+ * @param int $user_id
12
+ *
13
+ * @return bool|string|array
14
+ */
15
+ public function get_user_field( $field, $user_id ) {
16
+ $user = get_user_by( 'id', $user_id );
17
+
18
+ return isset( $user->{$field} ) ? $user->{$field} : false;
19
+ }
20
+
21
+ public function get_user( $user ) {
22
+ if ( is_numeric( $user ) ) {
23
+ $user = get_userdata( $user );
24
+ }
25
+
26
+ return $user && is_a( $user, 'WP_User' ) ? $user : false;
27
+ }
28
+
29
+ /**
30
+ * @param array $role_names
31
+ *
32
+ * @return array
33
+ */
34
+ public function translate_roles( $role_names ) {
35
+ $roles = array();
36
+
37
+ $wp_roles = wp_roles()->roles;
38
+
39
+ foreach ( (array) $role_names as $role ) {
40
+ if ( isset( $wp_roles[ $role ] ) ) {
41
+ $roles[ $role ] = translate_user_role( $wp_roles[ $role ]['name'] );
42
+ }
43
+ }
44
+
45
+ return $roles;
46
+ }
47
+
48
+ /**
49
+ * @param $user
50
+ * @param bool $format
51
+ *
52
+ * @return false|string
53
+ */
54
+ public function get_display_name( $user, $format = false ) {
55
+ $name = false;
56
+
57
+ if ( $user = $this->get_user( $user ) ) {
58
+ $name = $user->display_name;
59
+
60
+ if ( ! empty( $user->{$format} ) ) {
61
+ $name = $user->{$format};
62
+ }
63
+
64
+ if ( 'first_last_name' == $format ) {
65
+ $name_parts = array();
66
+ if ( $user->first_name ) {
67
+ $name_parts[] = $user->first_name;
68
+ }
69
+ if ( $user->last_name ) {
70
+ $name_parts[] = $user->last_name;
71
+ }
72
+ if ( $name_parts ) {
73
+ $name = implode( ' ', $name_parts );
74
+ }
75
+ }
76
+ }
77
+
78
+ return $name;
79
+ }
80
+
81
+ /**
82
+ * @since 3.4.4
83
+ */
84
+ public function get_postcount( $user_id, $post_type ) {
85
+ global $wpdb;
86
+ $sql = "
87
+ SELECT COUNT(ID)
88
+ FROM {$wpdb->posts}
89
+ WHERE post_status = 'publish'
90
+ AND post_author = %d
91
+ AND post_type = %s
92
+ ";
93
+
94
+ return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $post_type ) );
95
+ }
96
+
97
+ /**
98
+ * @return array Translatable roles
99
+ */
100
+ public function get_roles() {
101
+ $roles = array();
102
+ foreach ( wp_roles()->roles as $k => $role ) {
103
+ $roles[ $k ] = translate_user_role( $role['name'] );
104
+ }
105
+
106
+ return $roles;
107
+ }
108
+
109
+ /**
110
+ * @return array
111
+ */
112
+ public function get_ids() {
113
+ global $wpdb;
114
+
115
+ return $wpdb->get_col( "SELECT {$wpdb->users}.ID FROM {$wpdb->users}" );
116
+ }
117
+
118
+ /**
119
+ * Store current user meta data that is compatible with multi sites
120
+ *
121
+ * @param string $key
122
+ * @param array|string $value
123
+ */
124
+ public function update_meta_site( $key, $value, $prev_value = '' ) {
125
+ return update_user_meta( get_current_user_id(), $key . get_current_blog_id(), $value, $prev_value );
126
+ }
127
+
128
+ /**
129
+ * Get current user meta data
130
+ * @param string $key
131
+ */
132
+ public function get_meta_site( $key, $single = false ) {
133
+ return get_user_meta( get_current_user_id(), $key . get_current_blog_id(), $single );
134
+ }
135
+
136
+ /**
137
+ * Get current user meta data
138
+ * @param string $key
139
+ */
140
+ public function delete_meta_site( $key, $value = '' ) {
141
+ return delete_user_meta( get_current_user_id(), $key . get_current_blog_id(), $value );
142
+ }
143
+
144
+ }
classes/ListScreen.php ADDED
@@ -0,0 +1,839 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * List Screen
9
+ *
10
+ * @since 2.0
11
+ */
12
+ abstract class AC_ListScreen {
13
+
14
+ const OPTIONS_KEY = 'cpac_options_';
15
+
16
+ /**
17
+ * Unique Identifier for List Screen.
18
+ *
19
+ * @since 2.0
20
+ * @var string
21
+ */
22
+ private $key;
23
+
24
+ /**
25
+ * @since 2.0
26
+ * @var string
27
+ */
28
+ private $label;
29
+
30
+ /**
31
+ * @since 2.3.5
32
+ * @var string
33
+ */
34
+ private $singular_label;
35
+
36
+ /**
37
+ * Meta type of list screen; post, user, comment. Mostly used for fetching meta data.
38
+ *
39
+ * @since 3.0
40
+ * @var string
41
+ */
42
+ private $meta_type;
43
+
44
+ /**
45
+ * Page menu slug. Applies only when a menu page is used.
46
+ *
47
+ * @since 2.4.10
48
+ * @var string
49
+ */
50
+ private $page;
51
+
52
+ /**
53
+ * Class name of the WP_List_Table instance
54
+ * @see WP_List_Table
55
+ * @since 3.0
56
+ * @var string
57
+ */
58
+ private $list_table_class;
59
+
60
+ /**
61
+ * Group slug. Used for menu.
62
+ * @var string
63
+ */
64
+ private $group;
65
+
66
+ /**
67
+ * Name of the base PHP file (without extension).
68
+ *
69
+ * @see WP_Screen::base
70
+ *
71
+ * @since 2.0
72
+ * @var string
73
+ */
74
+ private $screen_base;
75
+
76
+ /**
77
+ * The unique ID of the screen.
78
+ *
79
+ * @see WP_Screen::id
80
+ *
81
+ * @since 2.5
82
+ * @var string
83
+ */
84
+ private $screen_id;
85
+
86
+ /**
87
+ * @since 2.0.1
88
+ * @var AC_Column[]
89
+ */
90
+ private $columns;
91
+
92
+ /**
93
+ * @since 2.2
94
+ * @var AC_Column[]
95
+ */
96
+ private $column_types;
97
+
98
+ /**
99
+ * @var array [ Column name => Label ]
100
+ */
101
+ private $original_columns;
102
+
103
+ /**
104
+ * @var string Layout ID
105
+ */
106
+ private $layout_id;
107
+
108
+ /**
109
+ * @var string Storage key used for saving column data to the database
110
+ */
111
+ private $storage_key;
112
+
113
+ /**
114
+ * @var array Column settings data
115
+ */
116
+ private $settings;
117
+
118
+ /**
119
+ * @var bool True when column settings can not be overwritten
120
+ */
121
+ private $read_only = false;
122
+
123
+ /**
124
+ * @var bool
125
+ */
126
+ private $network_only = false;
127
+
128
+ /**
129
+ * Contains the hook that contains the manage_value callback
130
+ *
131
+ * @return void
132
+ */
133
+ abstract public function set_manage_value_callback();
134
+
135
+ /**
136
+ * Register column types
137
+ * @return void
138
+ */
139
+ abstract protected function register_column_types();
140
+
141
+ public function get_key() {
142
+ return $this->key;
143
+ }
144
+
145
+ protected function set_key( $key ) {
146
+ $this->key = $key;
147
+ }
148
+
149
+ public function get_label() {
150
+ return $this->label;
151
+ }
152
+
153
+ protected function set_label( $label ) {
154
+ $this->label = $label;
155
+ }
156
+
157
+ public function get_singular_label() {
158
+ if ( null === $this->singular_label ) {
159
+ $this->set_singular_label( $this->label );
160
+ }
161
+
162
+ return $this->singular_label;
163
+ }
164
+
165
+ protected function set_singular_label( $label ) {
166
+ $this->singular_label = $label;
167
+ }
168
+
169
+ public function get_meta_type() {
170
+ return $this->meta_type;
171
+ }
172
+
173
+ protected function set_meta_type( $meta_type ) {
174
+ $this->meta_type = $meta_type;
175
+ }
176
+
177
+ public function get_screen_base() {
178
+ return $this->screen_base;
179
+ }
180
+
181
+ protected function set_screen_base( $screen_base ) {
182
+ $this->screen_base = $screen_base;
183
+ }
184
+
185
+ public function get_screen_id() {
186
+ return $this->screen_id;
187
+ }
188
+
189
+ protected function set_screen_id( $screen_id ) {
190
+ $this->screen_id = $screen_id;
191
+ }
192
+
193
+ public function get_page() {
194
+ return $this->page;
195
+ }
196
+
197
+ protected function set_page( $page ) {
198
+ $this->page = $page;
199
+ }
200
+
201
+ public function get_group() {
202
+ return $this->group;
203
+ }
204
+
205
+ public function set_group( $group ) {
206
+ $this->group = $group;
207
+ }
208
+
209
+ public function get_list_table_class() {
210
+ return $this->list_table_class;
211
+ }
212
+
213
+ protected function set_list_table_class( $list_table_class ) {
214
+ $this->list_table_class = $list_table_class;
215
+ }
216
+
217
+ /**
218
+ * @return string
219
+ */
220
+ public function get_storage_key() {
221
+ if ( null === $this->storage_key ) {
222
+ $this->set_storage_key( $this->get_key() );
223
+ }
224
+
225
+ return $this->storage_key;
226
+ }
227
+
228
+ /**
229
+ * @param string $key
230
+ */
231
+ private function set_storage_key( $key ) {
232
+ $this->storage_key = $key;
233
+
234
+ $this->reset();
235
+ }
236
+
237
+ /**
238
+ * @return string
239
+ */
240
+ public function get_layout_id() {
241
+ return $this->layout_id;
242
+ }
243
+
244
+ /**
245
+ * @param string $layout_id
246
+ *
247
+ * @return $this
248
+ */
249
+ public function set_layout_id( $layout_id ) {
250
+ $this->layout_id = $layout_id;
251
+
252
+ $this->set_storage_key( $this->get_key() . $layout_id );
253
+
254
+ return $this;
255
+ }
256
+
257
+ /**
258
+ * Return a single object based on it's ID (post, user, comment etc.)
259
+ *
260
+ * @since 3.0
261
+ * @return mixed
262
+ */
263
+ protected function get_object_by_id( $id ) {
264
+ return null;
265
+ }
266
+
267
+ /**
268
+ * ID attribute of targeted list table
269
+ *
270
+ * @since 3.0
271
+ * @return string
272
+ */
273
+ public function get_table_attr_id() {
274
+ return '#the-list';
275
+ }
276
+
277
+ /**
278
+ * @since 2.0.3
279
+ *
280
+ * @param WP_Screen $screen
281
+ *
282
+ * @return boolean
283
+ */
284
+ public function is_current_screen( $wp_screen ) {
285
+ return $wp_screen && $wp_screen->id === $this->get_screen_id() && $wp_screen->base === $this->get_screen_base();
286
+ }
287
+
288
+ /**
289
+ * Settings can not be overwritten
290
+ */
291
+ public function is_read_only() {
292
+ return $this->read_only;
293
+ }
294
+
295
+ /**
296
+ * @param bool $read_only
297
+ */
298
+ public function set_read_only( $read_only ) {
299
+ $this->read_only = (bool) $read_only;
300
+ }
301
+
302
+ /**
303
+ * Settings can not be overwritten
304
+ */
305
+ public function is_network_only() {
306
+ return $this->network_only;
307
+ }
308
+
309
+ /**
310
+ * @param bool $network_only
311
+ */
312
+ public function set_network_only( $network_only ) {
313
+ $this->network_only = (bool) $network_only;
314
+ }
315
+
316
+ /**
317
+ * @return string
318
+ */
319
+ protected function get_admin_url() {
320
+ return admin_url( $this->get_screen_base() . '.php' );
321
+ }
322
+
323
+ /**
324
+ * @since 2.0
325
+ * @return string Link
326
+ */
327
+ public function get_screen_link() {
328
+ return add_query_arg( array( 'page' => $this->get_page(), 'layout' => $this->get_layout_id() ), $this->get_admin_url() );
329
+ }
330
+
331
+ /**
332
+ * @since 2.0
333
+ */
334
+ public function get_edit_link() {
335
+ return add_query_arg( array( 'list_screen' => $this->key, 'layout_id' => $this->get_layout_id() ), AC()->admin_columns_screen()->get_link() );
336
+ }
337
+
338
+ /**
339
+ * @since 3.0
340
+ *
341
+ * @return AC_Column[]
342
+ */
343
+ public function get_columns() {
344
+ if ( null === $this->columns ) {
345
+ $this->set_columns();
346
+ }
347
+
348
+ return $this->columns;
349
+ }
350
+
351
+ /**
352
+ * @return AC_Column[]
353
+ */
354
+ public function get_column_types() {
355
+ if ( null === $this->column_types ) {
356
+ $this->set_column_types();
357
+ }
358
+
359
+ return $this->column_types;
360
+ }
361
+
362
+ /**
363
+ * Clears columns variable, which allow it to be repopulated by get_columns().
364
+ *
365
+ * @since 2.5
366
+ */
367
+ public function reset() {
368
+ $this->columns = null;
369
+ $this->column_types = null;
370
+ $this->settings = null;
371
+ }
372
+
373
+ /**
374
+ * @since 2.0
375
+ * @return false|AC_Column
376
+ */
377
+ public function get_column_by_name( $name ) {
378
+ $columns = $this->get_columns();
379
+
380
+ foreach ( $columns as $column ) {
381
+ if ( $column->get_name() === $name ) {
382
+ return $column;
383
+ }
384
+ }
385
+
386
+ return false;
387
+ }
388
+
389
+ /**
390
+ * @param string $type
391
+ *
392
+ * @return false|AC_Column
393
+ */
394
+ public function get_column_by_type( $type ) {
395
+ $column_types = $this->get_column_types();
396
+
397
+ if ( ! isset( $column_types[ $type ] ) ) {
398
+ return false;
399
+ }
400
+
401
+ return $column_types[ $type ];
402
+ }
403
+
404
+ /**
405
+ * @param string $type
406
+ *
407
+ * @return false|string
408
+ */
409
+ public function get_class_by_type( $type ) {
410
+ $column = $this->get_column_by_type( $type );
411
+
412
+ if ( ! $column ) {
413
+ return false;
414
+ }
415
+
416
+ return get_class( $column );
417
+ }
418
+
419
+ /**
420
+ * @param string $type Column type
421
+ */
422
+ public function deregister_column_type( $type ) {
423
+ if ( isset( $this->column_types[ $type ] ) ) {
424
+ unset( $this->column_types[ $type ] );
425
+ }
426
+ }
427
+
428
+ /**
429
+ * @param AC_Column $column
430
+ */
431
+ public function register_column_type( AC_Column $column ) {
432
+ if ( ! $column->get_type() ) {
433
+ return false;
434
+ }
435
+
436
+ $column->set_list_screen( $this );
437
+
438
+ if ( ! $column->is_valid() ) {
439
+ return false;
440
+ }
441
+
442
+ // Skip the custom registered columns which are marked 'original' but are not available for this list screen
443
+ if ( $column->is_original() && ! in_array( $column->get_type(), array_keys( $this->get_original_columns() ) ) ) {
444
+ return false;
445
+ }
446
+
447
+ $this->column_types[ $column->get_type() ] = $column;
448
+
449
+ return true;
450
+ }
451
+
452
+ /**
453
+ * @param string $type
454
+ *
455
+ * @return string Label
456
+ */
457
+ public function get_original_label( $type ) {
458
+ $columns = $this->get_original_columns();
459
+
460
+ if ( ! isset( $columns[ $type ] ) ) {
461
+ return false;
462
+ }
463
+
464
+ return $columns[ $type ];
465
+ }
466
+
467
+ /**
468
+ * @return array
469
+ */
470
+ public function get_original_columns() {
471
+ if ( null === $this->original_columns ) {
472
+ $this->set_original_columns( $this->get_stored_default_headings() );
473
+ }
474
+
475
+ return $this->original_columns;
476
+ }
477
+
478
+ /**
479
+ * @param array $columns
480
+ */
481
+ public function set_original_columns( $columns ) {
482
+ $this->original_columns = $columns;
483
+ }
484
+
485
+ /**
486
+ * Available column types
487
+ */
488
+ private function set_column_types() {
489
+
490
+ // Register default columns
491
+ foreach ( $this->get_original_columns() as $type => $label ) {
492
+
493
+ // Ignore the mandatory checkbox column
494
+ if ( 'cb' === $type ) {
495
+ continue;
496
+ }
497
+
498
+ $column = new AC_Column();
499
+
500
+ $column
501
+ ->set_type( $type )
502
+ ->set_original( true );
503
+
504
+ $this->register_column_type( $column );
505
+ }
506
+
507
+ // Placeholder columns
508
+ foreach ( AC()->addons()->get_addons() as $addon ) {
509
+ if ( $addon->is_plugin_active() && ! $addon->is_active() ) {
510
+ $this->register_column_type( $addon->get_placeholder_column() );
511
+ }
512
+ }
513
+
514
+ // Load Custom columns
515
+ $this->register_column_types();
516
+
517
+ /**
518
+ * Register column types
519
+ *
520
+ * @param AC_ListScreen $this
521
+ */
522
+ do_action( 'ac/column_types', $this );
523
+ }
524
+
525
+ /**
526
+ * @param string $dir Absolute path to the column directory
527
+ * @param string $prefix Autoload prefix
528
+ */
529
+ public function register_column_types_from_dir( $dir, $prefix ) {
530
+ $prefix = rtrim( $prefix, '_' ) . '_';
531
+ $classes = AC()->autoloader()->get_class_names_from_dir( $dir, $prefix );
532
+
533
+ foreach ( $classes as $class ) {
534
+ $this->register_column_type( new $class );
535
+ }
536
+ }
537
+
538
+ /**
539
+ * @param string $type Column type
540
+ *
541
+ * @return bool
542
+ */
543
+ private function is_original_column( $type ) {
544
+ $column = $this->get_column_by_type( $type );
545
+
546
+ if ( ! $column ) {
547
+ return false;
548
+ }
549
+
550
+ return $column->is_original();
551
+ }
552
+
553
+ /**
554
+ * @param array $settings Column options
555
+ *
556
+ * @return AC_Column|false
557
+ */
558
+ public function create_column( array $settings ) {
559
+ if ( ! isset( $settings['type'] ) ) {
560
+ return false;
561
+ }
562
+
563
+ $class = $this->get_class_by_type( $settings['type'] );
564
+
565
+ if ( ! $class ) {
566
+ return false;
567
+ }
568
+
569
+ /* @var AC_Column $column */
570
+ $column = new $class();
571
+
572
+ $column->set_list_screen( $this )
573
+ ->set_type( $settings['type'] );
574
+
575
+ if ( isset( $settings['name'] ) ) {
576
+ $column->set_name( $settings['name'] );
577
+ }
578
+
579
+ // Mark as original
580
+ if ( $this->is_original_column( $settings['type'] ) ) {
581
+
582
+ $column->set_original( true );
583
+ $column->set_name( $settings['type'] );
584
+ }
585
+
586
+ $column->set_options( $settings );
587
+
588
+ return $column;
589
+ }
590
+
591
+ /**
592
+ * @since 3.0
593
+ *
594
+ * @param string $column_name Column name
595
+ */
596
+ public function deregister_column( $column_name ) {
597
+ unset( $this->columns[ $column_name ] );
598
+ }
599
+
600
+ /**
601
+ * @param array $data Column options
602
+ */
603
+ protected function register_column( AC_Column $column ) {
604
+ $this->columns[ $column->get_name() ] = $column;
605
+ }
606
+
607
+ /**
608
+ * @since 3.0
609
+ */
610
+ private function set_columns() {
611
+
612
+ foreach ( $this->get_settings() as $name => $data ) {
613
+ $data['name'] = $name;
614
+ if ( $column = $this->create_column( $data ) ) {
615
+ $this->register_column( $column );
616
+ }
617
+ }
618
+
619
+ // Nothing stored. Use WP default columns.
620
+ if ( null === $this->columns ) {
621
+ foreach ( $this->get_original_columns() as $type => $label ) {
622
+ if ( $column = $this->create_column( array( 'type' => $type, 'original' => true ) ) ) {
623
+ $this->register_column( $column );
624
+ }
625
+ }
626
+ }
627
+
628
+ if ( null === $this->columns ) {
629
+ $this->columns = array();
630
+ }
631
+ }
632
+
633
+ /**
634
+ * Store column data
635
+ *
636
+ * @param array $column_data
637
+ *
638
+ * @return WP_Error|true
639
+ */
640
+ public function store( $column_data ) {
641
+ if ( ! $column_data ) {
642
+ return new WP_Error( 'no-settings', __( 'No columns settings available.', 'codepress-admin-columns' ) );
643
+ }
644
+
645
+ $settings = array();
646
+
647
+ foreach ( $column_data as $column_name => $options ) {
648
+ if ( empty( $options['type'] ) ) {
649
+ continue;
650
+ }
651
+
652
+ // New column, new key
653
+ if ( 0 === strpos( $column_name, '_new_column_' ) ) {
654
+ $column_name = uniqid();
655
+ }
656
+
657
+ $options['name'] = $column_name;
658
+
659
+ $column = $this->create_column( $options );
660
+
661
+ if ( ! $column ) {
662
+ continue;
663
+ }
664
+
665
+ // Skip duplicate original columns
666
+ if ( $column->is_original() ) {
667
+ if ( in_array( $column->get_type(), wp_list_pluck( $settings, 'type' ), true ) ) {
668
+ continue;
669
+ }
670
+ }
671
+
672
+ $sanitized = array();
673
+
674
+ // Sanitize data
675
+ foreach ( $column->get_settings() as $setting ) {
676
+ $sanitized += $setting->get_values();
677
+ }
678
+
679
+ // Encode site url
680
+ if ( $setting = $column->get_setting( 'label' ) ) {
681
+ $sanitized[ $setting->get_name() ] = $setting->get_encoded_label();
682
+ }
683
+
684
+ $settings[ $column_name ] = array_merge( $options, $sanitized );
685
+ }
686
+
687
+ $result = update_option( self::OPTIONS_KEY . $this->get_storage_key(), $settings );
688
+
689
+ if ( ! $result ) {
690
+ return new WP_Error( 'same-settings' );
691
+ }
692
+
693
+ /**
694
+ * Fires after a new column setup is stored in the database
695
+ * Primarily used when columns are saved through the Admin Columns settings screen
696
+ *
697
+ * @since 3.0
698
+ *
699
+ * @param AC_ListScreen $list_screen
700
+ */
701
+ do_action( 'ac/columns_stored', $this );
702
+
703
+ return true;
704
+ }
705
+
706
+ /**
707
+ * Populate settings from the database
708
+ */
709
+ public function populate_settings() {
710
+
711
+ // Load from DB
712
+ $this->set_settings( get_option( self::OPTIONS_KEY . $this->get_storage_key() ) );
713
+
714
+ // Load from API
715
+ AC()->api()->set_column_settings( $this );
716
+ }
717
+
718
+ /**
719
+ * @param array $settings Column settings
720
+ */
721
+ public function set_settings( $settings ) {
722
+ if ( ! is_array( $settings ) ) {
723
+ $settings = array();
724
+ }
725
+
726
+ $this->settings = $settings;
727
+
728
+ return $this;
729
+ }
730
+
731
+ /**
732
+ * @return array
733
+ */
734
+ public function get_settings() {
735
+ if ( null === $this->settings ) {
736
+ $this->populate_settings();
737
+ }
738
+
739
+ return $this->settings;
740
+ }
741
+
742
+ /**
743
+ * @return string
744
+ */
745
+ private function get_default_key() {
746
+ return self::OPTIONS_KEY . $this->get_key() . "__default";
747
+ }
748
+
749
+ /**
750
+ * @param array $column_headings Default column headings
751
+ *
752
+ * @return bool
753
+ */
754
+ public function save_default_headings( $column_headings ) {
755
+ return update_option( $this->get_default_key(), $column_headings );
756
+ }
757
+
758
+ /**
759
+ * @return array [ Column Name => Label ]
760
+ */
761
+ public function get_stored_default_headings() {
762
+ return get_option( $this->get_default_key(), array() );
763
+ }
764
+
765
+ /**
766
+ * @return bool
767
+ */
768
+ public function delete_default_headings() {
769
+ return delete_option( $this->get_default_key() );
770
+ }
771
+
772
+ /**
773
+ * @return bool
774
+ */
775
+ public function delete() {
776
+ return delete_option( self::OPTIONS_KEY . $this->get_storage_key() );
777
+ }
778
+
779
+ /**
780
+ * @param string $column_name
781
+ * @param int $id
782
+ * @param null $original_value
783
+ *
784
+ * @return string
785
+ */
786
+ public function get_display_value_by_column_name( $column_name, $id, $original_value = null ) {
787
+ $column = $this->get_column_by_name( $column_name );
788
+
789
+ if ( ! $column ) {
790
+ return $original_value;
791
+ }
792
+
793
+ $value = $column->get_value( $id );
794
+
795
+ // You can overwrite the display value for original columns by making sure get_value() does not return an empty string.
796
+ if ( $column->is_original() && ac_helper()->string->is_empty( $value ) ) {
797
+ return $original_value;
798
+ }
799
+
800
+ /**
801
+ * Column display value
802
+ *
803
+ * @since 3.0
804
+ *
805
+ * @param string $value Column display value
806
+ * @param int $id Object ID
807
+ * @param AC_Column $column Column object
808
+ */
809
+ $value = apply_filters( 'ac/column/value', $value, $id, $column );
810
+
811
+ // Display a toggle box with an ajax callback.
812
+ if ( $column instanceof AC_Column_AjaxValue && $value !== $column->get_empty_char() ) {
813
+ $value = ac_helper()->html->toggle_box_ajax( $id, $value, $column->get_name() );
814
+ }
815
+
816
+ return $value;
817
+ }
818
+
819
+ /**
820
+ * Get a single row from list table
821
+ *
822
+ * @since 3.0
823
+ */
824
+ public function get_single_row( $object_id ) {
825
+ ob_start();
826
+
827
+ $this->get_list_table()->single_row( $this->get_object_by_id( $object_id ) );
828
+
829
+ return ob_get_clean();
830
+ }
831
+
832
+ /**
833
+ * @return WP_List_Table|object
834
+ */
835
+ public function get_list_table() {
836
+ return _get_list_table( $this->get_list_table_class(), array( 'screen' => $this->get_screen_id() ) );
837
+ }
838
+
839
+ }
classes/ListScreen/Comment.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * @since 2.0
9
+ */
10
+ class AC_ListScreen_Comment extends AC_ListScreen {
11
+
12
+ public function __construct() {
13
+
14
+ $this->set_label( __( 'Comments' ) );
15
+ $this->set_singular_label( __( 'Comment' ) );
16
+ $this->set_meta_type( 'comment' );
17
+ $this->set_screen_base( 'edit-comments' );
18
+ $this->set_key( 'wp-comments' );
19
+ $this->set_screen_id( 'edit-comments' );
20
+ $this->set_group( 'comment' );
21
+
22
+ /* @see WP_Comments_List_Table */
23
+ $this->set_list_table_class( 'WP_Comments_List_Table' );
24
+ }
25
+
26
+ public function get_list_table() {
27
+ $table = parent::get_list_table();
28
+
29
+ // Since 4.4 the `floated_admin_avatar` filter is added in the constructor of the `WP_Comments_List_Table` class.
30
+ // Here we remove the filter from the constructor.
31
+ remove_filter( 'comment_author', array( $table, 'floated_admin_avatar' ), 10 );
32
+
33
+ return $table;
34
+ }
35
+
36
+ public function set_manage_value_callback() {
37
+ add_action( 'manage_comments_custom_column', array( $this, 'manage_value' ), 100, 2 );
38
+ }
39
+
40
+ /**
41
+ * @since 3.5
42
+ */
43
+ public function get_table_attr_id() {
44
+ return '#the-comment-list';
45
+ }
46
+
47
+ /**
48
+ * @since 3.0
49
+ * @return WP_Comment Comment
50
+ */
51
+ protected function get_object_by_id( $comment_id ) {
52
+ return get_comment( $comment_id );
53
+ }
54
+
55
+ /**
56
+ * @param string $column_name
57
+ * @param int $id
58
+ */
59
+ public function manage_value( $column_name, $id ) {
60
+ echo $this->get_display_value_by_column_name( $column_name, $id );
61
+ }
62
+
63
+ protected function register_column_types() {
64
+ $this->register_column_type( new AC_Column_CustomField() );
65
+ $this->register_column_type( new AC_Column_UsedByMenu() );
66
+
67
+ $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/Comment', 'AC_' );
68
+ }
69
+
70
+ }
classes/ListScreen/Link.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ListScreen_Link extends AC_ListScreen {
8
+
9
+ public function __construct() {
10
+
11
+ $this->set_label( __( 'Links' ) );
12
+ $this->set_singular_label( __( 'Link' ) );
13
+ $this->set_screen_base( 'link-manager' );
14
+ $this->set_key( 'wp-links' );
15
+ $this->set_screen_id( 'link-manager' );
16
+ $this->set_group( 'link' );
17
+
18
+ /* @see WP_Links_List_Table */
19
+ $this->set_list_table_class( 'WP_Links_List_Table' );
20
+ }
21
+
22
+ public function set_manage_value_callback() {
23
+ add_action( 'manage_link_custom_column', array( $this, 'manage_value' ), 100, 2 );
24
+ }
25
+
26
+ /**
27
+ * @since 3.0
28
+ * @return stdClass
29
+ */
30
+ protected function get_object_by_id( $bookmark_id ) {
31
+ return get_bookmark( $bookmark_id );
32
+ }
33
+
34
+ public function manage_value( $column_name, $id ) {
35
+ echo $this->get_display_value_by_column_name( $column_name, $id );
36
+ }
37
+
38
+ protected function register_column_types() {
39
+ $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/Link', 'AC_' );
40
+ }
41
+
42
+ }
classes/ListScreen/Media.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ListScreen_Media extends AC_ListScreenPost {
8
+
9
+ public function __construct() {
10
+ parent::__construct( 'attachment' );
11
+
12
+ $this->set_screen_id( 'upload' );
13
+ $this->set_screen_base( 'upload' );
14
+ $this->set_key( 'wp-media' );
15
+ $this->set_group( 'media' );
16
+ $this->set_label( __( 'Media' ) );
17
+
18
+ /* @see WP_Media_List_Table */
19
+ $this->set_list_table_class( 'WP_Media_List_Table' );
20
+ }
21
+
22
+ public function set_manage_value_callback() {
23
+ add_action( 'manage_media_custom_column', array( $this, 'manage_value' ), 100, 2 );
24
+ }
25
+
26
+ protected function get_object_by_id( $post_id ) {
27
+ // Author column depends on this global to be set.
28
+ global $authordata;
29
+
30
+ $authordata = get_userdata( get_post_field( 'post_author', $post_id ) );
31
+
32
+ return parent::get_object_by_id( $post_id );
33
+ }
34
+
35
+ /**
36
+ * @since 2.4.7
37
+ */
38
+ public function manage_value( $column_name, $id ) {
39
+ echo $this->get_display_value_by_column_name( $column_name, $id );
40
+ }
41
+
42
+ protected function register_column_types() {
43
+ $this->register_column_type( new AC_Column_CustomField() );
44
+ $this->register_column_type( new AC_Column_UsedByMenu() );
45
+
46
+ $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/Media', 'AC_' );
47
+ }
48
+
49
+ }
classes/ListScreen/Post.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ListScreen_Post extends AC_ListScreenPost {
8
+
9
+ public function __construct( $post_type ) {
10
+ parent::__construct( $post_type );
11
+
12
+ $this->set_screen_base( 'edit' );
13
+ $this->set_group( 'post' );
14
+ $this->set_key( $post_type );
15
+ $this->set_screen_id( $this->get_screen_base() . '-' . $post_type );
16
+
17
+ /* @see WP_Posts_List_Table */
18
+ $this->set_list_table_class( 'WP_Posts_List_Table' );
19
+ }
20
+
21
+ /**
22
+ * @since 3.0
23
+ * @return WP_Post Post object
24
+ */
25
+ protected function get_object_by_id( $post_id ) {
26
+ return get_post( $post_id );
27
+ }
28
+
29
+ public function set_manage_value_callback() {
30
+ /* @see WP_Posts_List_Table::column_default */
31
+ add_action( "manage_" . $this->get_post_type() . "_posts_custom_column", array( $this, 'manage_value' ), 100, 2 );
32
+ }
33
+
34
+ /**
35
+ * @since 2.0
36
+ */
37
+ public function get_screen_link() {
38
+ return add_query_arg( array( 'post_type' => $this->get_post_type() ), parent::get_screen_link() );
39
+ }
40
+
41
+ /**
42
+ * @return string|false
43
+ */
44
+ public function get_label() {
45
+ return $this->get_post_type_label_var( 'name' );
46
+ }
47
+
48
+ /**
49
+ * @return false|string
50
+ */
51
+ public function get_singular_label() {
52
+ return $this->get_post_type_label_var( 'singular_name' );
53
+ }
54
+
55
+ /**
56
+ * @since 2.4.7
57
+ */
58
+ public function manage_value( $column_name, $id ) {
59
+ echo $this->get_display_value_by_column_name( $column_name, $id );
60
+ }
61
+
62
+ protected function register_column_types() {
63
+ $this->register_column_type( new AC_Column_CustomField() );
64
+ $this->register_column_type( new AC_Column_UsedByMenu() );
65
+
66
+ $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/Post', 'AC_' );
67
+ }
68
+
69
+ }
classes/ListScreen/User.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ListScreen_User extends AC_ListScreen {
8
+
9
+ public function __construct() {
10
+
11
+ $this->set_label( __( 'Users' ) );
12
+ $this->set_singular_label( __( 'User' ) );
13
+ $this->set_meta_type( 'user' );
14
+ $this->set_screen_base( 'users' );
15
+ $this->set_screen_id( 'users' );
16
+ $this->set_key( 'wp-users' );
17
+ $this->set_group( 'user' );
18
+
19
+ /* @see WP_Users_List_Table */
20
+ $this->set_list_table_class( 'WP_Users_List_Table' );
21
+ }
22
+
23
+ /**
24
+ * @see set_manage_value_callback()
25
+ */
26
+ public function set_manage_value_callback() {
27
+ add_filter( 'manage_users_custom_column', array( $this, 'manage_value' ), 100, 3 );
28
+ }
29
+
30
+ /**
31
+ * @since 2.4.10
32
+ */
33
+ public function is_current_screen( $wp_screen ) {
34
+ return parent::is_current_screen( $wp_screen ) && 'delete' !== filter_input( INPUT_GET, 'action' );
35
+ }
36
+
37
+ /**
38
+ * @since 2.0.2
39
+ *
40
+ * @param string $value
41
+ * @param string $column_name
42
+ * @param int $user_id
43
+ */
44
+ public function manage_value( $value, $column_name, $user_id ) {
45
+ return $this->get_display_value_by_column_name( $column_name, $user_id, $value );
46
+ }
47
+
48
+ /**
49
+ * @since 3.0
50
+ * @return string HTML
51
+ */
52
+ public function get_single_row( $user_id ) {
53
+
54
+ /* @var WP_Users_List_Table $table */
55
+ $table = $this->get_list_table();
56
+
57
+ return $table->single_row( get_userdata( $user_id ) );
58
+ }
59
+
60
+ protected function register_column_types() {
61
+ $this->register_column_type( new AC_Column_CustomField() );
62
+ $this->register_column_type( new AC_Column_UsedByMenu() );
63
+
64
+ $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/User', 'AC_' );
65
+ }
66
+
67
+ }
classes/ListScreenPost.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_ListScreenPost extends AC_ListScreen {
8
+
9
+ /**
10
+ * @var string Post type
11
+ */
12
+ private $post_type;
13
+
14
+ /**
15
+ * @param string $post_type
16
+ */
17
+ public function __construct( $post_type ) {
18
+ $this->set_meta_type( 'post' );
19
+ $this->set_post_type( $post_type );
20
+ }
21
+
22
+ /**
23
+ * @return string
24
+ */
25
+ public function get_post_type() {
26
+ return $this->post_type;
27
+ }
28
+
29
+ /**
30
+ * @param string $post_type
31
+ */
32
+ protected function set_post_type( $post_type ) {
33
+ $this->post_type = (string) $post_type;
34
+ }
35
+
36
+ /**
37
+ * @since 3.0
38
+ * @param int $post_id Post ID
39
+ * @return WP_Post
40
+ */
41
+ protected function get_object_by_id( $post_id ) {
42
+ return get_post( $post_id );
43
+ }
44
+
45
+ /**
46
+ * @param string $var
47
+ *
48
+ * @return string|false
49
+ */
50
+ protected function get_post_type_label_var( $var ) {
51
+ $post_type_object = get_post_type_object( $this->get_post_type() );
52
+
53
+ return $post_type_object && isset( $post_type_object->labels->{$var} ) ? $post_type_object->labels->{$var} : false;
54
+ }
55
+
56
+ }
classes/Meta/Query.php ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Meta_Query {
8
+
9
+ /**
10
+ * @var WP_Meta_Query
11
+ */
12
+ private $query;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $sql;
18
+
19
+ /**
20
+ * @var array
21
+ */
22
+ private $select = array();
23
+
24
+ /**
25
+ * @var string|false
26
+ */
27
+ private $count = false;
28
+
29
+ /**
30
+ * @var bool
31
+ */
32
+ private $distinct = false;
33
+
34
+ /**
35
+ * @var bool
36
+ */
37
+ private $join = false;
38
+
39
+ /**
40
+ * @var array
41
+ */
42
+ private $join_where = array();
43
+
44
+ /**
45
+ * @var array
46
+ */
47
+ private $where = array();
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ private $group_by = array();
53
+
54
+ /**
55
+ * @var array
56
+ */
57
+ private $order_by = array();
58
+
59
+ /**
60
+ * @param string $meta_type
61
+ */
62
+ public function __construct( $meta_type ) {
63
+ $this->set_query( $meta_type );
64
+ }
65
+
66
+ /**
67
+ * Add a single field or multiple comma separated
68
+ *
69
+ * @param string $field e.g. id or id, meta_value
70
+ *
71
+ * @return $this
72
+ */
73
+ public function select( $field ) {
74
+ $fields = explode( ',', $field );
75
+
76
+ foreach ( $fields as $field ) {
77
+ $this->select[] = trim( $field );
78
+ }
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Add a COUNT clause AS count
85
+ *
86
+ * @param string $field
87
+ *
88
+ * @return $this
89
+ */
90
+ public function count( $field ) {
91
+ $this->count = $field;
92
+
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Group by an aggregated column.
98
+ *
99
+ * Supports: count
100
+ *
101
+ * @param string $field
102
+ *
103
+ * @return $this
104
+ */
105
+ public function group_by( $field ) {
106
+ $this->group_by = $field;
107
+
108
+ return $this;
109
+ }
110
+
111
+ public function join( $type = 'inner' ) {
112
+ $this->join = strtoupper( $type );
113
+
114
+ return $this;
115
+ }
116
+
117
+ public function left_join() {
118
+ return $this->join( 'left' );
119
+ }
120
+
121
+ /**
122
+ * @see get_where_clause()
123
+ *
124
+ * @return $this
125
+ */
126
+ public function join_where( $field, $operator = null, $value = null, $boolean = 'AND' ) {
127
+ // set default join
128
+ if ( ! $this->join ) {
129
+ $this->join();
130
+ }
131
+
132
+ $this->join_where[] = $this->get_where_clause( $field, $operator, $value, $boolean );
133
+
134
+ return $this;
135
+ }
136
+
137
+ public function order_by( $order_by, $order = 'asc' ) {
138
+ $parts = explode( ',', $order_by );
139
+
140
+ foreach ( $parts as $order_by ) {
141
+ $this->order_by[] = array(
142
+ 'order_by' => trim( $order_by ),
143
+ 'order' => strtoupper( $order ),
144
+ );
145
+ }
146
+
147
+ return $this;
148
+ }
149
+
150
+ public function distinct() {
151
+ $this->distinct = true;
152
+
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Set a where clause
158
+ *
159
+ * @param string|array $field
160
+ * @param string $operator
161
+ * @param string|int|array $value
162
+ * @param string $type
163
+ *
164
+ * @return array
165
+ */
166
+ private function get_where_clause( $field, $operator = null, $value = null, $boolean = 'AND' ) {
167
+ // allows to omit operator
168
+ if ( null === $value ) {
169
+ $value = $operator;
170
+ $operator = '=';
171
+ }
172
+
173
+ $where = array(
174
+ 'nested' => false,
175
+ 'boolean' => strtoupper( $boolean ),
176
+ 'field' => $field,
177
+ 'operator' => strtoupper( $operator ),
178
+ 'value' => $value,
179
+ );
180
+
181
+ // set default join
182
+ if ( $field === 'post_type' && ! $this->join ) {
183
+ $this->join();
184
+ }
185
+
186
+ $nested = array();
187
+
188
+ if ( is_array( $field ) ) {
189
+ for ( $i = 0; $i < count( $field ); $i++ ) {
190
+ $nested[] = array_pop( $this->where );
191
+ }
192
+ }
193
+
194
+ if ( $nested ) {
195
+ $where['nested'] = true;
196
+ $where['field'] = array_reverse( $nested );
197
+ }
198
+
199
+ return $where;
200
+ }
201
+
202
+ /**
203
+ * @see get_where_clause()
204
+ *
205
+ * @return $this
206
+ */
207
+ public function remove_where( $field, $operator = null, $value = null, $boolean = 'AND' ) {
208
+ $where = $this->get_where_clause( $field, $operator, $value, $boolean );
209
+
210
+ foreach ( $this->where as $k => $v ) {
211
+ if ( $v == $where ) {
212
+ unset( $this->where[ $k ] );
213
+ }
214
+ }
215
+
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * @see get_where_clause()
221
+ *
222
+ * @return $this
223
+ */
224
+ public function where( $field, $operator = null, $value = null, $boolean = 'AND' ) {
225
+ $this->where[] = $this->get_where_clause( $field, $operator, $value, $boolean );
226
+
227
+ return $this;
228
+ }
229
+
230
+ /**
231
+ * @see get_where_clause()
232
+ *
233
+ * @return $this
234
+ */
235
+ public function or_where( $field, $operator = null, $value = null ) {
236
+ return $this->where( $field, $operator, $value, 'OR' );
237
+ }
238
+
239
+ /**
240
+ * @param array $in
241
+ *
242
+ * @return $this
243
+ */
244
+ public function where_in( array $in ) {
245
+ return $this->where( 'id', 'in', $in );
246
+ }
247
+
248
+ public function where_is_null( $field ) {
249
+ return $this->where( $field, '', 'IS NULL' );
250
+ }
251
+
252
+ public function where_post_type( $post_type ) {
253
+ return $this->where( 'post_type', '=', $post_type );
254
+ }
255
+
256
+ private function parse_field( $field ) {
257
+ switch ( $field ) {
258
+ case 'id':
259
+ $field = $this->join ? 'pt.' . $this->query->primary_id_column : 'mt' . $this->query->meta_id_column;
260
+
261
+ break;
262
+ case 'meta_key':
263
+ case 'meta_value':
264
+ $field = 'mt.' . $field;
265
+
266
+ break;
267
+ case 'taxonomy':
268
+ case 'post_type':
269
+ $field = 'pt.' . $field;
270
+
271
+ break;
272
+ }
273
+
274
+ return $field;
275
+ }
276
+
277
+ private function parse_where( $where, $clauses ) {
278
+ global $wpdb;
279
+
280
+ foreach ( $clauses as $clause ) {
281
+
282
+ if ( $clause['nested'] ) {
283
+ $clause['field'][0]['boolean'] = null;
284
+
285
+ $where .= sprintf( ' %s ( %s ) ', $clause['boolean'], $this->parse_where( '', $clause['field'] ) );
286
+ } else {
287
+ switch ( $clause['operator'] ) {
288
+ case 'IN':
289
+ $clause['value'] = sprintf( ' ( %s ) ', implode( ', ', array_map( 'intval', $clause['value'] ) ) );
290
+
291
+ break;
292
+ default:
293
+ $valid_raw = array( 'IS NULL', 'IS NOT NULL' );
294
+
295
+ if ( ! in_array( $clause['value'], $valid_raw ) ) {
296
+ $clause['value'] = $wpdb->prepare( '%s', $clause['value'] );
297
+ }
298
+ }
299
+
300
+ $clause['field'] = $this->parse_field( $clause['field'] );
301
+
302
+ $where .= implode( ' ', $clause );
303
+ }
304
+
305
+ }
306
+
307
+ return $where;
308
+ }
309
+
310
+ /**
311
+ * @return array
312
+ */
313
+ public function get() {
314
+ global $wpdb;
315
+
316
+ if ( ! $this->query ) {
317
+ return array();
318
+ }
319
+
320
+ // parse SELECT
321
+ $select = 'SELECT ';
322
+ $select .= $this->distinct ? 'DISTINCT ' : '';
323
+
324
+ if ( empty( $this->select ) ) {
325
+ $this->select( 'id' );
326
+ }
327
+
328
+ $fields = array();
329
+
330
+ foreach ( $this->select as $field ) {
331
+ $parsed = $this->parse_field( $field );
332
+
333
+ // output 'id' in the results
334
+ if ( 'id' === $field ) {
335
+ $parsed .= ' AS id';
336
+ }
337
+
338
+ $fields[] = $parsed;
339
+ }
340
+
341
+ if ( $this->count ) {
342
+ $fields[] = sprintf( 'COUNT(%s) AS count', $this->parse_field( $this->count ) );
343
+ }
344
+
345
+ $select .= implode( ', ', $fields );
346
+
347
+ // parse FROM
348
+ $from_tpl = ' FROM %s AS %s';
349
+
350
+ $from = sprintf( $from_tpl, $this->query->meta_table, 'mt' );
351
+ $join = '';
352
+
353
+ if ( $this->join ) {
354
+ $from = sprintf( $from_tpl, $this->query->primary_table, 'pt' );
355
+ $join = sprintf( ' %s JOIN %s AS mt ON mt.%s = pt.%s %s',
356
+ $this->join,
357
+ $this->query->meta_table,
358
+ $this->query->meta_id_column,
359
+ $this->query->primary_id_column,
360
+ $this->parse_where( '', $this->join_where )
361
+ );
362
+ }
363
+
364
+ // parse WHERE
365
+ $where = $this->parse_where( ' WHERE 1=1', $this->where );
366
+
367
+ // parse GROUP BY
368
+ $group_by = '';
369
+
370
+ if ( $this->group_by ) {
371
+ $group_by = ' GROUP BY ' . $this->parse_field( $this->group_by );
372
+ }
373
+
374
+ // parse ORDER BY
375
+ $order_by = '';
376
+
377
+ if ( ! empty( $this->order_by ) ) {
378
+ $order_by_clauses = array();
379
+
380
+ foreach ( $this->order_by as $order_by_clause ) {
381
+ $order_by_clauses[] = $this->parse_field( $order_by_clause['order_by'] ) . ' ' . $order_by_clause['order'];
382
+ }
383
+
384
+ $order_by = ' ORDER BY ' . implode( ', ', $order_by_clauses );
385
+ }
386
+
387
+ // build query and store it
388
+ $sql = $select . $from . $join . $where . $group_by . $order_by;
389
+
390
+ $this->set_sql( $sql );
391
+
392
+ $results = $wpdb->get_results( $sql );
393
+
394
+ if ( ! is_array( $results ) ) {
395
+ return array();
396
+ }
397
+
398
+ $return = $results;
399
+
400
+ if ( count( $fields ) === 1 ) {
401
+ $return = array();
402
+ $field = $this->select[0];
403
+
404
+ foreach ( $results as $result ) {
405
+ $return[] = $result->$field;
406
+ }
407
+ }
408
+
409
+ return $return;
410
+ }
411
+
412
+ /**
413
+ * Return last sql that was queries
414
+ *
415
+ * @return string
416
+ */
417
+ public function get_sql() {
418
+ $sql = preg_replace( '/ +/', ' ', $this->sql );
419
+ $sql = preg_replace( '/(SELECT|FROM|LEFT|INNER|WHERE|(AND|OR) \(|(AND|OR) (?!\()|ORDER BY|GROUP BY)/', "\n$1", $sql );
420
+
421
+ return $sql . "\n";
422
+ }
423
+
424
+ private function set_sql( $sql ) {
425
+ $this->sql = $sql;
426
+ }
427
+
428
+ /**
429
+ * @return WP_Meta_Query
430
+ */
431
+ public function get_query() {
432
+ return $this->query;
433
+ }
434
+
435
+ private function set_query( $type ) {
436
+ global $wpdb;
437
+
438
+ switch ( $type ) {
439
+ case 'user':
440
+ $table = $wpdb->users;
441
+ $id = 'ID';
442
+
443
+ break;
444
+ case 'comment':
445
+ $table = $wpdb->comments;
446
+ $id = 'comment_ID';
447
+
448
+ break;
449
+ case 'post':
450
+ $table = $wpdb->posts;
451
+ $id = 'ID';
452
+
453
+ break;
454
+ case 'term':
455
+ $table = $wpdb->terms;
456
+ $id = 'term_id';
457
+
458
+ break;
459
+
460
+ default:
461
+ return false;
462
+ }
463
+
464
+ $this->query = new WP_Meta_Query();
465
+ $this->query->get_sql( $type, $table, $id );
466
+
467
+ return true;
468
+ }
469
+
470
+ }
classes/Meta/QueryColumn.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Meta_QueryColumn extends AC_Meta_Query {
8
+
9
+ /**
10
+ * @param AC_Column $column
11
+ */
12
+ public function __construct( AC_Column $column ) {
13
+ parent::__construct( $column->get_list_screen()->get_meta_type() );
14
+
15
+ if ( $column instanceof AC_Column_Meta ) {
16
+ $this->join_where( 'meta_key', $column->get_meta_key() );
17
+ }
18
+
19
+ if ( $column->get_post_type() ) {
20
+ $this->where_post_type( $column->get_post_type() );
21
+ }
22
+ }
23
+
24
+ }
classes/Notice/Plugin.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ final class AC_Notice_Plugin {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $plugin_basename;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $message;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ private $class;
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ private $icon;
28
+
29
+ /**
30
+ * @param string $plugin_basename
31
+ */
32
+ public function __construct( $plugin_basename ) {
33
+ $this->plugin_basename = $plugin_basename;
34
+ $this->set_type( 'warning' );
35
+ }
36
+
37
+ /**
38
+ * Check if the plugin has an update available
39
+ *
40
+ * @return bool
41
+ */
42
+ private function update_available() {
43
+ $current = get_site_transient( 'update_plugins' );
44
+
45
+ return isset( $current->response[ $this->plugin_basename ] );
46
+ }
47
+
48
+ public function hook_notice() {
49
+ add_action( 'after_plugin_row_' . $this->plugin_basename, array( $this, 'display_notice' ), 11 );
50
+ }
51
+
52
+ public function display_notice() {
53
+ $class = '';
54
+
55
+ if ( is_plugin_active( $this->plugin_basename ) ) {
56
+ $class .= ' active';
57
+
58
+ if ( $this->update_available() ) {
59
+ $class .= ' update';
60
+ }
61
+ }
62
+
63
+ ?>
64
+
65
+ <style>
66
+ .plugins tr[data-plugin='<?php echo $this->plugin_basename; ?>'] th,
67
+ .plugins tr[data-plugin='<?php echo $this->plugin_basename; ?>'] td {
68
+ box-shadow: none;
69
+ }
70
+
71
+ <?php if ( $this->icon ) : ?>
72
+ .plugins tr[data-plugin='<?php echo $this->plugin_basename; ?>'] .update-message p:before {
73
+ content: "<?php echo $this->icon ?>";
74
+ }
75
+
76
+ <?php endif; ?>
77
+ </style>
78
+
79
+ <tr class="plugin-update-tr <?php echo esc_attr( $class ); ?>" data-slug="<?php echo esc_attr( basename( $this->plugin_basename ) ); ?>" data-plugin="<?php echo esc_attr( $this->plugin_basename ); ?>">
80
+ <td colspan="3" class="plugin-update colspanchange">
81
+ <div class="update-message notice inline <?php echo esc_attr( $this->class ); ?>">
82
+ <p><?php echo $this->message; ?></p>
83
+ </div>
84
+ </td>
85
+ </tr>
86
+
87
+ <?php
88
+ }
89
+
90
+ /**
91
+ * Set the message of this notice. Only links allowed, other HTML is escaped
92
+ *
93
+ * @param string $message
94
+ *
95
+ * @return $this
96
+ */
97
+ public function set_message( $message ) {
98
+ $this->message = wp_kses( $message, array(
99
+ 'strong' => array(),
100
+ 'br' => array(),
101
+ 'a' => array(
102
+ 'class' => true,
103
+ 'data' => true,
104
+ 'href' => true,
105
+ 'id' => true,
106
+ 'title' => true,
107
+ ),
108
+ ) );
109
+
110
+ return $this;
111
+ }
112
+
113
+ private function get_predefined_type( $type ) {
114
+ $mapping = array(
115
+ 'warning' => 'notice-warning|\f348',
116
+ 'error' => 'notice-error|\f534',
117
+ 'success' => 'updated-message notice-success|\f147',
118
+ 'update' => 'notice-warning|\f463',
119
+ );
120
+
121
+ if ( array_key_exists( $type, $mapping ) ) {
122
+ $parts = explode( '|', $mapping[ $type ] );
123
+
124
+ return (object) array(
125
+ 'class' => $parts[0] . ' notice-alt',
126
+ 'icon' => $parts[1],
127
+ );
128
+ }
129
+
130
+ return false;
131
+ }
132
+
133
+ public function set_type( $type ) {
134
+ $type = $this->get_predefined_type( $type );
135
+
136
+ if ( $type ) {
137
+ $this->set_class( $type->class );
138
+ $this->set_icon( $type->icon );
139
+ }
140
+
141
+ return $this;
142
+ }
143
+
144
+ /**
145
+ * Set the color-scheme of the notice
146
+ *
147
+ * @param string $class
148
+ *
149
+ * @return $this
150
+ */
151
+ public function set_class( $class ) {
152
+ $type = $this->get_predefined_type( $class );
153
+
154
+ if ( $type ) {
155
+ $class = $type->class;
156
+ }
157
+
158
+ $this->class = $class;
159
+
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * Set the icon of the notice. Defaults to 'update'
165
+ *
166
+ * @param string $icon
167
+ *
168
+ * @return $this
169
+ */
170
+ public function set_icon( $icon ) {
171
+ $type = $this->get_predefined_type( $icon );
172
+
173
+ if ( $type ) {
174
+ $icon = $type->icon;
175
+ }
176
+
177
+ $this->icon = $icon;
178
+
179
+ return $this;
180
+ }
181
+
182
+ }
classes/Notice/Review.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Notice_Review {
8
+
9
+ const OPTION_INSTALL_DATE = 'cpac-install-timestamp';
10
+
11
+ const OPTION_ADMIN_NOTICE_KEY = 'cpac-hide-review-notice';
12
+
13
+ function __construct() {
14
+ register_activation_hook( __FILE__, array( $this, 'insert_install_timestamp' ) );
15
+
16
+ add_action( 'admin_init', array( $this, 'maybe_display_review_notice' ) );
17
+ add_action( 'wp_ajax_cpac_hide_review_notice', array( $this, 'ajax_hide_review_notice' ) );
18
+ }
19
+
20
+ public function insert_install_timestamp() {
21
+ add_site_option( self::OPTION_INSTALL_DATE, time() );
22
+ }
23
+
24
+ private function get_install_timestamp() {
25
+ $timestamp = get_site_option( self::OPTION_INSTALL_DATE, '' );
26
+
27
+ if ( '' == $timestamp ) {
28
+ $this->insert_install_timestamp();
29
+
30
+ $timestamp = time();
31
+ }
32
+
33
+ return $timestamp;
34
+ }
35
+
36
+ public function maybe_display_review_notice() {
37
+ global $pagenow;
38
+
39
+ // Only show review notice on plugin or settings screen
40
+ if ( ! in_array( $pagenow, array( 'options-general.php', 'plugins.php' ) ) ) {
41
+ return;
42
+ }
43
+
44
+ if ( AC()->suppress_site_wide_notices() ) {
45
+ return;
46
+ }
47
+
48
+ if ( AC()->user_can_manage_admin_columns() && ( ! get_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_KEY, true ) ) ) {
49
+
50
+ // Display notice after 30 days
51
+ if ( ( time() - ( 30 * DAY_IN_SECONDS ) ) >= $this->get_install_timestamp() ) {
52
+ add_action( 'admin_notices', array( $this, 'display_review_notice' ) );
53
+ }
54
+ }
55
+ }
56
+
57
+ public function ajax_hide_review_notice() {
58
+ update_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_KEY, '1', true );
59
+ }
60
+
61
+ public function display_review_notice() {
62
+ $product = __( 'Admin Columns', 'codepress-admin-columns' );
63
+
64
+ if ( ac_is_pro_active() ) {
65
+ $product = __( 'Admin Columns Pro', 'codepress-admin-columns' );
66
+ }
67
+
68
+ wp_enqueue_style( 'ac-sitewide-notices' );
69
+
70
+ ?>
71
+ <div class="ac-message updated">
72
+ <div class="info">
73
+ <p>
74
+ <?php printf( __(
75
+ "We don't mean to bug you, but you've been using %s for some time now, and we were wondering if you're happy with the plugin. If so, could you please leave a review at wordpress.org? If you're not happy with %s, please %s.", 'codepress-admin-columns' ),
76
+ '<strong>' . $product . '</strong>',
77
+ $product,
78
+ '<a class="hide-review-notice hide-review-notice-soft" href="#">' . __( 'click here', 'codepress-admin-columns' ) . '</a>'
79
+ ); ?>
80
+ </p>
81
+ <p class="buttons">
82
+ <a class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/codepress-admin-columns?rate=5#postform" target="_blank"><?php _e( 'Leave a review!', 'codepress-admin-columns' ); ?></a>
83
+ <a class="button button-secondary hide-review-notice" href='#'><?php _e( "Permanently hide notice", 'codepress-admin-columns' ); ?></a>
84
+ </p>
85
+ </div>
86
+ <div class="help hidden">
87
+ <a href="#" class="hide-notice hide-review-notice"></a>
88
+ <p>
89
+ <?php printf(
90
+ __( "We're sorry to hear that; maybe we can help! If you're having problems properly setting up %s or if you would like help with some more advanced features, please visit our %s.", 'codepress-admin-columns' ),
91
+ $product,
92
+ '<a href="' . esc_url( ac_get_site_utm_url( 'documentation', 'review-notice' ) ) . '" target="_blank">' . __( 'documentation page', 'codepress-admin-columns' ) . '</a>'
93
+ ); ?>
94
+ <?php if ( ac_is_pro_active() ) : ?>
95
+ <?php printf(
96
+ __( 'As an Admin Columns Pro user, you can also use your AdminColumns.com account to access product support through %s!', 'codepress-admin-columns' ),
97
+ '<a href="' . esc_url( ac_get_site_utm_url( 'forumns', 'review-notice' ) ) . '" target="_blank">' . __( 'our forums', 'codepress-admin-columns' ) . '</a>'
98
+ ); ?>
99
+ <?php else : ?>
100
+ <?php printf(
101
+ __( 'You can also find help on the %s, and %s.', 'codepress-admin-columns' ),
102
+ '<a href="https://wordpress.org/support/plugin/codepress-admin-columns#postform" target="_blank">' . __( 'Admin Columns forums on WordPress.org', 'codepress-admin-columns' ) . '</a>',
103
+ '<a href="https://wordpress.org/plugins/codepress-admin-columns/faq/#plugin-info" target="_blank">' . __( 'find answers to some frequently asked questions', 'codepress-admin-columns' ) . '</a>'
104
+ ); ?>
105
+ <?php endif; ?>
106
+ </p>
107
+ </div>
108
+ <div class="clear"></div>
109
+ </div>
110
+ <script type="text/javascript">
111
+ jQuery( function( $ ) {
112
+ $( document ).ready( function() {
113
+ $( '.updated a.hide-review-notice' ).click( function( e ) {
114
+ e.preventDefault();
115
+
116
+ var el = $( this ).parents( '.ac-message' );
117
+ var el_close = el.find( '.hide-notice' );
118
+ var soft = $( this ).hasClass( 'hide-review-notice-soft' );
119
+
120
+ if ( soft ) {
121
+ el.find( '.info' ).slideUp();
122
+ el.find( '.help' ).slideDown();
123
+ }
124
+ else {
125
+ el_close.hide();
126
+ el_close.after( '<div class="spinner right"></div>' );
127
+ el.find( '.spinner' ).show();
128
+ }
129
+
130
+ $.post( ajaxurl, {
131
+ 'action' : 'cpac_hide_review_notice'
132
+ }, function() {
133
+ if ( !soft ) {
134
+ el.find( '.spinner' ).remove();
135
+ el.slideUp();
136
+ }
137
+ } );
138
+
139
+ return false;
140
+ } );
141
+ } );
142
+ } );
143
+ </script>
144
+ <?php
145
+ }
146
+
147
+ }
classes/PluginInformation.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_PluginInformation {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $plugin_dirname;
13
+
14
+ /**
15
+ * AC_Helper_Plugin constructor.
16
+ *
17
+ * @param string $plugin_dirname
18
+ */
19
+ public function __construct( $plugin_dirname ) {
20
+ $this->plugin_dirname = sanitize_key( $plugin_dirname );
21
+ }
22
+
23
+ /**
24
+ * @return string
25
+ */
26
+ public function get_dirname() {
27
+ return $this->plugin_dirname;
28
+ }
29
+
30
+ /**
31
+ * @return bool
32
+ */
33
+ public function is_installed() {
34
+ return $this->get_plugin_info() ? true : false;
35
+ }
36
+
37
+ /**
38
+ * @return bool
39
+ */
40
+ public function is_active() {
41
+ return is_plugin_active( $this->get_plugin_var( 'Basename' ) );
42
+ }
43
+
44
+ /**
45
+ * @return string|false Returns the plugin version if the plugin is installed, false otherwise
46
+ */
47
+ public function get_version() {
48
+ return $this->get_plugin_var( 'Version' );
49
+ }
50
+
51
+ /**
52
+ * @return string Basename
53
+ */
54
+ public function get_basename() {
55
+ return $this->get_plugin_var( 'Basename' );
56
+ }
57
+
58
+ /**
59
+ * @return string Name
60
+ */
61
+ public function get_name() {
62
+ return $this->get_plugin_var( 'Name' );
63
+ }
64
+
65
+ /**
66
+ * @return array|false
67
+ */
68
+ public function get_plugin_info() {
69
+ $plugins = (array) get_plugins();
70
+
71
+ foreach ( $plugins as $basename => $info ) {
72
+ if ( $this->plugin_dirname === dirname( $basename ) ) {
73
+ $info['Basename'] = $basename;
74
+
75
+ return $info;
76
+ }
77
+ }
78
+
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * @param string $var
84
+ *
85
+ * @return string|false
86
+ */
87
+ public function get_plugin_var( $var ) {
88
+ $info = $this->get_plugin_info();
89
+
90
+ if ( ! isset( $info[ $var ] ) ) {
91
+ return false;
92
+ }
93
+
94
+ return $info[ $var ];
95
+ }
96
+
97
+ }
classes/Settings/Column.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Settings_Column {
8
+
9
+ /**
10
+ * A (short) reference to this setting
11
+ *
12
+ * @var string
13
+ */
14
+ protected $name;
15
+
16
+ /**
17
+ * The options this field manages (optionally with default values)
18
+ *
19
+ * @var array
20
+ */
21
+ protected $options = array();
22
+
23
+ /**
24
+ * @var AC_Column
25
+ */
26
+ protected $column;
27
+
28
+ /**
29
+ * Options that are set by the user and should not be overwritten with defaults
30
+ *
31
+ * @var array
32
+ */
33
+ private $user_set = array();
34
+
35
+ /**
36
+ * @param AC_Column $column
37
+ */
38
+ public function __construct( AC_Column $column ) {
39
+ $this->column = $column;
40
+
41
+ $this->set_options();
42
+ $this->set_name();
43
+ }
44
+
45
+ /**
46
+ * @see AC_Settings_Column::$options
47
+ * @return array
48
+ */
49
+ protected abstract function define_options();
50
+
51
+ /**
52
+ * Create a string representation of this setting
53
+ *
54
+ * @return AC_View|false
55
+ */
56
+ public abstract function create_view();
57
+
58
+ /**
59
+ * Get settings that depend on this setting
60
+ *
61
+ * @return AC_Settings_Column[]
62
+ */
63
+ public function get_dependent_settings() {
64
+ return array();
65
+ }
66
+
67
+ private function set_options() {
68
+ foreach ( $this->define_options() as $option => $value ) {
69
+ if ( is_numeric( $option ) ) {
70
+ $option = $value;
71
+ $value = null;
72
+ }
73
+
74
+ $this->set_option( $option, $value );
75
+ $this->set_default( $value, $option );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Set an option and set value afterwards
81
+ *
82
+ * @param string $option
83
+ * @param mixed $value
84
+ */
85
+ private function set_option( $option, $value = null ) {
86
+ $this->options[ $option ] = $value;
87
+ }
88
+
89
+ public function has_option( $option ) {
90
+ return array_key_exists( $option, $this->options );
91
+ }
92
+
93
+ /**
94
+ * Get a managed option
95
+ *
96
+ * @param null|string $option
97
+ *
98
+ * @return false|string
99
+ */
100
+ protected function get_default_option() {
101
+ reset( $this->options );
102
+
103
+ return key( $this->options );
104
+ }
105
+
106
+ /**
107
+ * Return the value of all options
108
+ *
109
+ * @return array
110
+ */
111
+ public function get_values() {
112
+ $values = array();
113
+
114
+ foreach ( array_keys( $this->options ) as $option ) {
115
+ $values[ $option ] = $this->get_value( $option );
116
+ }
117
+
118
+ return $values;
119
+ }
120
+
121
+ /**
122
+ * Get value of this setting, optionally specified with a key
123
+ *
124
+ * Will return the value of the default option
125
+ *
126
+ * @param string|null $option
127
+ *
128
+ * @return string|array|int|bool
129
+ */
130
+ public function get_value( $option = null ) {
131
+ if ( null === $option ) {
132
+ $option = $this->get_default_option();
133
+ }
134
+
135
+ if ( ! $this->has_option( $option ) ) {
136
+ return null;
137
+ }
138
+
139
+ $method = 'get_' . $option;
140
+
141
+ if ( ! method_exists( $this, $method ) ) {
142
+ return null;
143
+ }
144
+
145
+ return $this->$method();
146
+ }
147
+
148
+ /**
149
+ * Set the values of this setting
150
+ *
151
+ * @param array $options
152
+ */
153
+ public function set_values( array $values ) {
154
+ foreach ( $values as $option => $value ) {
155
+ $this->set_value( $value, $option );
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Invoke the setter of the setting
161
+ *
162
+ * @param string|array|int|bool $value
163
+ * @param string $option
164
+ *
165
+ * @return bool
166
+ */
167
+ private function invoke_option_setter( $option, $value ) {
168
+ $method = 'set_' . $option;
169
+
170
+ if ( ! method_exists( $this, $method ) ) {
171
+ return false;
172
+ }
173
+
174
+ return $this->$method( $value );
175
+ }
176
+
177
+ /**
178
+ * Set value of an option
179
+ *
180
+ * @param string|array|int|bool $value
181
+ * @param string|null $option
182
+ *
183
+ * @return bool
184
+ */
185
+ public function set_value( $value, $option = null ) {
186
+ if ( null === $option ) {
187
+ $option = $this->get_default_option();
188
+ }
189
+
190
+ if ( ! $this->has_option( $option ) ) {
191
+ return false;
192
+ }
193
+
194
+ $result = $this->invoke_option_setter( $option, $value );
195
+
196
+ if ( $result ) {
197
+ $this->user_set[] = $option;
198
+ }
199
+
200
+ return $result;
201
+ }
202
+
203
+ /**
204
+ * Set a default value unless option is loaded from settings
205
+ *
206
+ * @param string|array|int|bool $value
207
+ * @param string|null $option
208
+ *
209
+ * @return bool
210
+ */
211
+ public function set_default( $value, $option = null ) {
212
+ if ( null === $option ) {
213
+ $option = $this->get_default_option();
214
+ }
215
+
216
+ if ( ! $this->has_option( $option ) ) {
217
+ return false;
218
+ }
219
+
220
+ $this->set_option( $option, $value );
221
+
222
+ // check if value is user set
223
+ if ( ! in_array( $option, $this->user_set ) ) {
224
+ $this->invoke_option_setter( $option, $value );
225
+ }
226
+
227
+ return true;
228
+ }
229
+
230
+ /**
231
+ * Get the default value of an option if set
232
+ *
233
+ * @param string|null $option
234
+ *
235
+ * @return mixed
236
+ */
237
+ public function get_default( $option = null ) {
238
+ if ( null === $option ) {
239
+ $option = $this->get_default_option();
240
+ }
241
+
242
+ return $this->has_option( $option ) ? $this->options[ $option ] : null;
243
+ }
244
+
245
+ /**
246
+ * @return string
247
+ */
248
+ public function get_name() {
249
+ return $this->name;
250
+ }
251
+
252
+ /**
253
+ * Default to self::get_default_option()
254
+ */
255
+ protected function set_name() {
256
+ $this->name = $this->get_default_option();
257
+ }
258
+
259
+ /**
260
+ * Add an element to this setting
261
+ *
262
+ * @param string $type
263
+ * @param string|null $name
264
+ *
265
+ * @return AC_Settings_Form_Element_Select|AC_Settings_Form_Element_Input|AC_Settings_Form_Element_Radio
266
+ */
267
+ protected function create_element( $type, $name = null ) {
268
+ if ( null === $name ) {
269
+ $name = $this->get_default_option();
270
+ }
271
+
272
+ switch ( $type ) {
273
+
274
+ case 'checkbox' :
275
+ $element = new AC_Settings_Form_Element_Checkbox( $name );
276
+
277
+ break;
278
+ case 'radio' :
279
+ $element = new AC_Settings_Form_Element_Radio( $name );
280
+
281
+ break;
282
+ case 'select' :
283
+ $element = new AC_Settings_Form_Element_Select( $name );
284
+
285
+ break;
286
+ default:
287
+ $element = new AC_Settings_Form_Element_Input( $name );
288
+ $element->set_type( $type );
289
+ }
290
+
291
+ $element->set_name( sprintf( 'columns[%s][%s]', $this->column->get_name(), $name ) );
292
+ $element->set_id( sprintf( 'ac-%s-%s', $this->column->get_name(), $name ) );
293
+ $element->add_class( 'ac-setting-input_' . $name );
294
+
295
+ // try to set current value
296
+ $value = $this->get_value( $name );
297
+
298
+ if ( null !== $value ) {
299
+ $element->set_value( $value );
300
+ }
301
+
302
+ return $element;
303
+ }
304
+
305
+ /**
306
+ * Render the output of self::create_header()
307
+ *
308
+ * @return false|string
309
+ */
310
+ public function render_header() {
311
+ if ( ! ( $this instanceof AC_Settings_HeaderInterface ) ) {
312
+ return false;
313
+ }
314
+
315
+ /* @var AC_Settings_HeaderInterface $this */
316
+ $view = $this->create_header_view();
317
+
318
+ if ( ! ( $view instanceof AC_View ) ) {
319
+ return false;
320
+ }
321
+
322
+ if ( null == $view->get_template() ) {
323
+ $view->set_template( 'settings/header' );
324
+ }
325
+
326
+ if ( null == $view->setting ) {
327
+ $view->set( 'setting', $this->get_name() );
328
+ }
329
+
330
+ return $view->render();
331
+ }
332
+
333
+ /**
334
+ * Render the output of self::create_view()
335
+ *
336
+ * @return false|string
337
+ */
338
+ public function render() {
339
+ $view = $this->create_view();
340
+
341
+ if ( ! ( $view instanceof AC_View ) ) {
342
+ return false;
343
+ }
344
+
345
+ $template = 'settings/section';
346
+
347
+ // set default template
348
+ if ( null === $view->get_template() ) {
349
+ $view->set_template( $template );
350
+ }
351
+
352
+ // set default name
353
+ if ( null === $view->get( 'name' ) ) {
354
+ $view->set( 'name', $this->name );
355
+ }
356
+
357
+ // set default template for nested sections
358
+ foreach ( (array) $view->sections as $section ) {
359
+ if ( $section instanceof AC_View && null === $section->get_template() ) {
360
+ $section->set_template( $template );
361
+ }
362
+ }
363
+
364
+ return $view->render();
365
+ }
366
+
367
+ public function __toString() {
368
+ return $this->render();
369
+ }
370
+
371
+ public function get_column() {
372
+ return $this->column;
373
+ }
374
+ }
classes/Settings/Column/ActionIcons.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_ActionIcons extends AC_Settings_Column {
8
+
9
+ private $use_icons;
10
+
11
+ protected function define_options() {
12
+ return array(
13
+ 'use_icons' => '',
14
+ );
15
+ }
16
+
17
+ public function create_view() {
18
+
19
+ $setting = $this->create_element( 'radio' )
20
+ ->set_options( array(
21
+ '1' => __( 'Yes' ),
22
+ '' => __( 'No' ),
23
+ ) );
24
+
25
+ $view = new AC_View( array(
26
+ 'label' => __( 'Use icons?', 'codepress-admin-columns' ),
27
+ 'tooltip' => __( 'Use icons instead of text for displaying the actions.', 'codepress-admin-columns' ),
28
+ 'setting' => $setting,
29
+ ) );
30
+
31
+ return $view;
32
+ }
33
+
34
+ /**
35
+ * @return int
36
+ */
37
+ public function get_use_icons() {
38
+ return $this->use_icons;
39
+ }
40
+
41
+ /**
42
+ * @param int $use_icons
43
+ *
44
+ * @return bool
45
+ */
46
+ public function set_use_icons( $use_icons ) {
47
+ $this->use_icons = $use_icons;
48
+
49
+ return true;
50
+ }
51
+
52
+ }
classes/Settings/Column/BeforeAfter.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_BeforeAfter extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $before;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $after;
19
+
20
+ protected function set_name() {
21
+ $this->name = 'before_after';
22
+ }
23
+
24
+ protected function define_options() {
25
+ return array( 'before', 'after' );
26
+ }
27
+
28
+ public function format( $value, $original_value ) {
29
+ if ( $this->get_before() || $this->get_after() ) {
30
+ $value = $this->get_before() . $value . $this->get_after();
31
+ }
32
+
33
+ return $value;
34
+ }
35
+
36
+ public function create_view() {
37
+ $setting = $this->create_element( 'text', 'before' );
38
+
39
+ $before = new AC_View( array(
40
+ 'label' => __( 'Before', 'codepress-admin-columns' ),
41
+ 'description' => __( 'This text will appear before the column value.', 'codepress-admin-columns' ),
42
+ 'setting' => $setting,
43
+ 'for' => $setting->get_id(),
44
+ ) );
45
+
46
+ $setting = $this->create_element( 'text', 'after' );
47
+
48
+ $after = new AC_View( array(
49
+ 'label' => __( 'After', 'codepress-admin-columns' ),
50
+ 'description' => __( 'This text will appear after the column value.', 'codepress-admin-columns' ),
51
+ 'setting' => $setting,
52
+ 'for' => $setting->get_id(),
53
+ ) );
54
+
55
+ $view = new AC_View( array(
56
+ 'label' => __( 'Display Options', 'codepress-admin-columns' ),
57
+ 'sections' => array( $before, $after ),
58
+ ) );
59
+
60
+ return $view;
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function get_before() {
67
+ return $this->before;
68
+ }
69
+
70
+ /**
71
+ * @param $before
72
+ *
73
+ * @return bool
74
+ */
75
+ public function set_before( $before ) {
76
+ $this->before = $before;
77
+
78
+ return true;
79
+ }
80
+
81
+ /**
82
+ * @return string
83
+ */
84
+ public function get_after() {
85
+ return $this->after;
86
+ }
87
+
88
+ /**
89
+ * @param $after
90
+ *
91
+ * @return bool
92
+ */
93
+ public function set_after( $after ) {
94
+ $this->after = $after;
95
+
96
+ return true;
97
+ }
98
+
99
+ }
classes/Settings/Column/CharacterLimit.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_CharacterLimit extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ private $character_limit;
14
+
15
+ protected function define_options() {
16
+ return array(
17
+ 'character_limit' => 20,
18
+ );
19
+ }
20
+
21
+ public function create_view() {
22
+ $word_limit = $this->create_element( 'number' )
23
+ ->set_attribute( 'min', 0 )
24
+ ->set_attribute( 'step', 1 );
25
+
26
+ $view = new AC_View( array(
27
+ 'label' => __( 'Character Limit', 'codepress-admin-columns' ),
28
+ 'tooltip' => __( 'Maximum number of characters', 'codepress-admin-columns' ) . '<em>' . __( 'Leave empty for no limit', 'codepress-admin-columns' ) . '</em>',
29
+ 'setting' => $word_limit,
30
+ ) );
31
+
32
+ return $view;
33
+ }
34
+
35
+ /**
36
+ * @return int
37
+ */
38
+ public function get_character_limit() {
39
+ return $this->character_limit;
40
+ }
41
+
42
+ /**
43
+ * @param int $character_limit
44
+ *
45
+ * @return bool
46
+ */
47
+ public function set_character_limit( $character_limit ) {
48
+ $this->character_limit = $character_limit;
49
+
50
+ return true;
51
+ }
52
+
53
+ public function format( $value, $original_value ) {
54
+ return ac_helper()->string->trim_characters( $value, $this->get_character_limit() );
55
+ }
56
+
57
+ }
classes/Settings/Column/CommentCount.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_CommentCount extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $comment_status;
14
+
15
+ public function get_name() {
16
+ return 'comment_count';
17
+ }
18
+
19
+ protected function define_options() {
20
+ return array(
21
+ 'comment_status' => 'total_comments',
22
+ );
23
+ }
24
+
25
+ /**
26
+ * @return AC_View
27
+ */
28
+ public function create_view() {
29
+ $view = new AC_View( array(
30
+ 'label' => __( 'Comment status', 'codepress-admin-columns' ),
31
+ 'tooltip' => __( 'Select which comment status you like to display.', 'codepress-admin-columns' ),
32
+ 'setting' => $this->create_element( 'select' )->set_options( $this->get_comment_statuses() ),
33
+ ) );
34
+
35
+ return $view;
36
+ }
37
+
38
+ /**
39
+ * @return array
40
+ */
41
+ private function get_comment_statuses() {
42
+ $options = array(
43
+ 'approved' => __( 'Approved', 'codepress-admin-columns' ),
44
+ 'moderated' => __( 'Pending', 'codepress-admin-columns' ),
45
+ 'spam' => __( 'Spam', 'codepress-admin-columns' ),
46
+ 'trash' => __( 'Trash', 'codepress-admin-columns' ),
47
+ );
48
+
49
+ natcasesort( $options );
50
+
51
+ // First
52
+ $options = array( 'total_comments' => __( 'Total', 'codepress-admin-columns' ) ) + $options;
53
+
54
+ return $options;
55
+ }
56
+
57
+ /**
58
+ * @return int
59
+ */
60
+ public function get_comment_status() {
61
+ return $this->comment_status;
62
+ }
63
+
64
+ /**
65
+ * @param string $comment_status
66
+ *
67
+ * @return bool
68
+ */
69
+ public function set_comment_status( $comment_status ) {
70
+ $this->comment_status = $comment_status;
71
+
72
+ return true;
73
+ }
74
+
75
+ /**
76
+ * @param int $post_id
77
+ * @param int $original_value
78
+ *
79
+ * @return false|string
80
+ */
81
+ public function format( $post_id, $original_value ) {
82
+ $status = $this->get_comment_status();
83
+ $count = wp_count_comments( $post_id );
84
+
85
+ if ( empty( $count->$status ) ) {
86
+ return $this->column->get_empty_char();
87
+ }
88
+
89
+ return ac_helper()->html->link( add_query_arg( array( 'p' => $post_id, 'comment_status' => $status ), admin_url( 'edit-comments.php' ) ), $count->$status );
90
+ }
91
+
92
+ }
classes/Settings/Column/CustomField.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_CustomField extends AC_Settings_Column_Meta {
8
+
9
+ protected function set_name() {
10
+ $this->name = 'custom_field';
11
+ }
12
+
13
+ public function create_view() {
14
+
15
+ /**
16
+ * DOM can get overloaded when dropdown contains to many custom fields. Use this filter to replace the dropdown with a text input.
17
+ *
18
+ * @since 3.0
19
+ *
20
+ * @param bool false
21
+ */
22
+ $use_text_input = apply_filters( 'ac/column/custom_field/use_text_input', false );
23
+
24
+ if ( $use_text_input ) {
25
+ $field = $this->create_element( 'text', 'field' )
26
+ ->set_attribute( 'placeholder', 'Custom field key' );
27
+ } else {
28
+
29
+ // Meta field
30
+ $field = $this->get_setting_field();
31
+
32
+ $field->set_no_result( __( 'No custom fields available.', 'codepress-admin-columns' ) . ' ' . sprintf( __( 'Please create a %s item first.', 'codepress-admin-columns' ), '<strong>' . $this->column->get_list_screen()->get_singular_label() . '</strong>' ) );
33
+ }
34
+
35
+ $view = new AC_View( array(
36
+ 'label' => __( 'Field', 'codepress-admin-columns' ),
37
+ 'setting' => $field,
38
+ ) );
39
+
40
+ return $view;
41
+ }
42
+
43
+ public function get_dependent_settings() {
44
+ return array( new AC_Settings_Column_CustomFieldType( $this->column ) );
45
+ }
46
+
47
+ protected function get_cache_group() {
48
+ return 'ac_settings_custom_field';
49
+ }
50
+
51
+ /**
52
+ * @return string
53
+ */
54
+ protected function get_cache_key() {
55
+ return parent::get_cache_key() . $this->get_post_type();
56
+ }
57
+
58
+ protected function get_meta_type() {
59
+ return $this->column->get_list_screen()->get_meta_type();
60
+ }
61
+
62
+ /**
63
+ * @return string Post type
64
+ */
65
+ protected function get_post_type() {
66
+ return $this->column->get_post_type();
67
+ }
68
+
69
+ /**
70
+ * @return array|false
71
+ */
72
+ protected function get_meta_keys() {
73
+ $query = new AC_Meta_Query( $this->get_meta_type() );
74
+
75
+ $query->select( 'meta_key' )
76
+ ->distinct()
77
+ ->order_by( 'meta_key' );
78
+
79
+ if ( $this->get_post_type() ) {
80
+ $query->where_post_type( $this->get_post_type() );
81
+ }
82
+
83
+ $keys = $query->get();
84
+
85
+ if ( empty( $keys ) ) {
86
+ $keys = false;
87
+ }
88
+
89
+ /**
90
+ * @param array $keys Distinct meta keys from DB
91
+ * @param AC_Settings_Column_CustomField $this
92
+ */
93
+ return apply_filters( 'ac/column/custom_field/meta_keys', $keys, $this );
94
+ }
95
+
96
+ /**
97
+ * @param string $field
98
+ *
99
+ * @return bool
100
+ */
101
+ public function set_field( $field ) {
102
+
103
+ // Backwards compatible for WordPress Settings API not storing fields starting with _
104
+ $prefix_hidden = 'cpachidden';
105
+
106
+ if ( 0 === strpos( $field, $prefix_hidden ) ) {
107
+ $field = substr( $field, strlen( $prefix_hidden ) );
108
+ }
109
+
110
+ return parent::set_field( $field );
111
+ }
112
+
113
+ }
classes/Settings/Column/CustomFieldType.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_CustomFieldType extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $field_type;
14
+
15
+ protected function define_options() {
16
+ return array( 'field_type' );
17
+ }
18
+
19
+ public function get_dependent_settings() {
20
+ $settings = array();
21
+
22
+ switch ( $this->get_field_type() ) {
23
+
24
+ case 'date' :
25
+ $settings[] = new AC_Settings_Column_Date( $this->column );
26
+
27
+ break;
28
+ case 'image' :
29
+ case 'library_id' :
30
+ $settings[] = new AC_Settings_Column_Image( $this->column );
31
+
32
+ break;
33
+ case 'excerpt' :
34
+ $settings[] = new AC_Settings_Column_CharacterLimit( $this->column );
35
+
36
+ break;
37
+ case 'link' :
38
+ $settings[] = new AC_Settings_Column_LinkLabel( $this->column );
39
+
40
+ break;
41
+ }
42
+
43
+ return $settings;
44
+ }
45
+
46
+ public function create_view() {
47
+ $select = $this->create_element( 'select' );
48
+
49
+ $select->set_attribute( 'data-refresh', 'column' )
50
+ ->set_options( $this->get_grouped_options() )
51
+ ->set_description( $this->get_description() );
52
+
53
+ $tooltip = __( 'This will determine how the value will be displayed.', 'codepress-admin-columns' );
54
+
55
+ if ( null !== $this->get_field_type() ) {
56
+ $tooltip .= '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->get_field_type() . '</em>';
57
+ }
58
+
59
+ $view = new AC_View( array(
60
+ 'label' => __( 'Field Type', 'codepress-admin-columns' ),
61
+ 'tooltip' => $tooltip,
62
+ 'setting' => $select,
63
+ ) );
64
+
65
+ return $view;
66
+ }
67
+
68
+ private function get_description_object_ids( $input ) {
69
+ $description = sprintf( __( "Uses the id from a %s to display information about it.", 'codepress-admin-columns' ), '<em>' . $input . '</em>' );
70
+ $description .= ' ' . __( "Multiple ids should be separated by a comma.", 'codepress-admin-columns' );
71
+
72
+ return $description;
73
+ }
74
+
75
+ public function get_description() {
76
+ $description = false;
77
+
78
+ switch ( $this->get_field_type() ) {
79
+ case 'title_by_id' :
80
+ $description = $this->get_description_object_ids( __( "Post Type", 'codepress-admin-columns' ) );
81
+
82
+ break;
83
+ case 'user_by_id' :
84
+ $description = $this->get_description_object_ids( __( "User", 'codepress-admin-columns' ) );
85
+
86
+ break;
87
+ }
88
+
89
+ return $description;
90
+ }
91
+
92
+ /**
93
+ * Get possible field types
94
+ *
95
+ * @return array
96
+ */
97
+ protected function get_field_type_options() {
98
+ $grouped_types = array(
99
+ 'basic' => array(
100
+ 'color' => __( 'Color', 'codepress-admin-columns' ),
101
+ 'date' => __( 'Date', 'codepress-admin-columns' ),
102
+ 'excerpt' => __( 'Text' ),
103
+ 'image' => __( 'Image', 'codepress-admin-columns' ),
104
+ 'link' => __( 'Url', 'codepress-admin-columns' ),
105
+ 'numeric' => __( 'Number', 'codepress-admin-columns' ),
106
+ ),
107
+ 'choice' => array(
108
+ 'has_content' => __( 'Has Content', 'codepress-admin-columns' ),
109
+ 'checkmark' => __( 'True / False', 'codepress-admin-columns' ),
110
+ ),
111
+ 'relational' => array(
112
+ 'library_id' => __( 'Media', 'codepress-admin-columns' ),
113
+ 'title_by_id' => __( 'Post', 'codepress-admin-columns' ),
114
+ 'user_by_id' => __( 'User', 'codepress-admin-columns' ),
115
+ ),
116
+ 'multiple' => array(
117
+ 'count' => __( 'Number of Fields', 'codepress-admin-columns' ),
118
+ 'array' => __( 'Multiple Values', 'codepress-admin-columns' ),
119
+ ),
120
+ );
121
+
122
+ /**
123
+ * Filter the available custom field types for the meta (custom field) field
124
+ *
125
+ * @since 3.0
126
+ *
127
+ * @param array $field_types Available custom field types ([type] => [label])
128
+ */
129
+ $grouped_types['custom'] = apply_filters( 'ac/column/custom_field/field_types', array() );
130
+
131
+ foreach ( $grouped_types as $k => $fields ) {
132
+ natcasesort( $grouped_types[ $k ] );
133
+ }
134
+
135
+ return $grouped_types;
136
+ }
137
+
138
+ /**
139
+ * @return array
140
+ */
141
+ private function get_grouped_options() {
142
+ $field_types = $this->get_field_type_options();
143
+
144
+ foreach ( $field_types as $fields ) {
145
+ asort( $fields );
146
+ }
147
+
148
+ $groups = array(
149
+ 'basic' => __( 'Basic', 'codepress-admin-columns' ),
150
+ 'relational' => __( 'Relational', 'codepress-admin-columns' ),
151
+ 'choice' => __( 'Choice', 'codepress-admin-columns' ),
152
+ 'multiple' => __( 'Multiple', 'codepress-admin-columns' ),
153
+ 'custom' => __( 'Custom', 'codepress-admin-columns' ),
154
+ );
155
+
156
+ $grouped_options = array();
157
+ foreach ( $field_types as $group => $fields ) {
158
+
159
+ if ( ! $fields ) {
160
+ continue;
161
+ }
162
+
163
+ $grouped_options[ $group ]['title'] = $groups[ $group ];
164
+ $grouped_options[ $group ]['options'] = $fields;
165
+ }
166
+
167
+ // Default option comes first
168
+ $grouped_options = array_merge( array( '' => __( 'Default', 'codepress-admin-columns' ) ), $grouped_options );
169
+
170
+ return $grouped_options;
171
+ }
172
+
173
+ /**
174
+ * @param string|array $string
175
+ *
176
+ * @return array
177
+ */
178
+ private function get_ids_from_array_or_string( $string ) {
179
+ $string = ac_helper()->array->implode_recursive( ',', $string );
180
+
181
+ return ac_helper()->string->string_to_array_integers( $string );
182
+ }
183
+
184
+ public function format( $value, $original_value ) {
185
+
186
+ switch ( $this->get_field_type() ) {
187
+
188
+ case 'date' :
189
+ if ( $timestamp = ac_helper()->date->strtotime( $value ) ) {
190
+ $value = date( 'c', $timestamp );
191
+ }
192
+
193
+ break;
194
+
195
+ case "title_by_id" :
196
+ $values = array();
197
+ foreach ( $this->get_ids_from_array_or_string( $value ) as $id ) {
198
+ $post = get_post( $id );
199
+ $values[] = ac_helper()->html->link( get_edit_post_link( $post ), $post->post_title );
200
+ }
201
+
202
+ $value = implode( ac_helper()->html->divider(), $values );
203
+ break;
204
+
205
+ case "user_by_id" :
206
+ $values = array();
207
+ foreach ( $this->get_ids_from_array_or_string( $value ) as $id ) {
208
+ $user = get_userdata( $id );
209
+ $values[] = ac_helper()->html->link( get_edit_user_link( $user ), ac_helper()->user->get_display_name( $user ) );
210
+ }
211
+
212
+ $value = implode( ac_helper()->html->divider(), $values );
213
+ break;
214
+
215
+ case 'image' :
216
+ case 'library_id' :
217
+ $value = new AC_Collection( $this->get_ids_from_array_or_string( $value ) );
218
+
219
+ break;
220
+ case "checkmark" :
221
+ $is_true = ! empty( $value ) && 'false' !== $value && '0' !== $value;
222
+ $value = ac_helper()->icon->yes_or_no( $is_true );
223
+
224
+ break;
225
+ case "color" :
226
+
227
+ if ( $value && is_scalar( $value ) ) {
228
+ $value = ac_helper()->string->get_color_block( $value );
229
+ } else {
230
+ $value = false;
231
+ }
232
+
233
+ break;
234
+ case "count" :
235
+
236
+ if ( $this->column instanceof AC_Column_Meta ) {
237
+ $value = $this->column->get_meta_value( $original_value, $this->column->get_meta_key(), false );
238
+
239
+ if ( $value ) {
240
+ if ( 1 === count( $value ) && is_array( $value[0] ) ) {
241
+
242
+ // Value contains a single serialized array with multiple values
243
+ $value = count( $value[0] );
244
+ } else {
245
+
246
+ // Count multiple usage of meta keys
247
+ $value = count( $value );
248
+ }
249
+ } else {
250
+ $value = false;
251
+ }
252
+ }
253
+
254
+ break;
255
+ case "has_content" :
256
+ $value = ac_helper()->icon->yes_or_no( $value, $value );
257
+
258
+ break;
259
+ default :
260
+ $value = ac_helper()->array->implode_recursive( __( ', ' ), $value );
261
+ }
262
+
263
+ return $value;
264
+ }
265
+
266
+ /**
267
+ * @return string
268
+ */
269
+ public function get_field_type() {
270
+ return $this->field_type;
271
+ }
272
+
273
+ /**
274
+ * @param string $field_type
275
+ *
276
+ * @return bool
277
+ */
278
+ public function set_field_type( $field_type ) {
279
+ $this->field_type = $field_type;
280
+
281
+ return true;
282
+ }
283
+
284
+ }
classes/Settings/Column/Date.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Date extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ private $date_format;
11
+
12
+ protected function set_name() {
13
+ $this->name = 'date';
14
+ }
15
+
16
+ protected function define_options() {
17
+ return array(
18
+ 'date_format' => 'wp_default',
19
+ );
20
+ }
21
+
22
+ public function create_view() {
23
+
24
+ $setting = $this
25
+ ->create_element( 'text' )
26
+ ->set_attribute( 'placeholder', $this->get_default() );
27
+
28
+ $view = new AC_View( array(
29
+ 'setting' => $setting,
30
+ 'date_format' => $this->get_date_format(),
31
+ 'date_options' => $this->get_date_options(),
32
+ 'label' => __( 'Date Format', 'codepress-admin-columns' ),
33
+ 'tooltip' => __( 'This will determine how the date will be displayed.', 'codepress-admin-columns' ),
34
+ ) );
35
+
36
+ $view->set_template( 'settings/setting-date' );
37
+
38
+ return $view;
39
+ }
40
+
41
+ protected function get_html_label( $args ) {
42
+ $defaults = array(
43
+ 'label' => false,
44
+ 'date_format' => false,
45
+ 'description' => false,
46
+ );
47
+
48
+ $data = (object) wp_parse_args( $args, $defaults );
49
+
50
+ $label = '';
51
+
52
+ if ( $data->label ) {
53
+ $label .= '<span class="ac-setting-input-date__value">' . $data->label . '</span>';
54
+ }
55
+ if ( $data->date_format ) {
56
+ $label .= '<code>' . $data->date_format . '</code>';
57
+ }
58
+ if ( $data->description ) {
59
+ $label .= '<span class="ac-setting-input-date__more hidden">' . $data->description . '</span>';
60
+ }
61
+
62
+ return $label;
63
+ }
64
+
65
+ protected function get_date_options() {
66
+
67
+ $options = array(
68
+ 'diff' => $this->get_html_label( array(
69
+ 'label' => __( 'Time Difference', 'codepress-admin-columns' ),
70
+ 'description' => __( 'The difference is returned in a human readable format.', 'codepress-admin-columns' ) . ' <br/>' . sprintf( __( 'For example: %s.', 'codepress-admin-columns' ), '"' . $this->format_human_time_diff( strtotime( "-1 hour" ) ) . '" ' . __( 'or' ) . ' "' . $this->format_human_time_diff( strtotime( "-2 days" ) ) . '"' ),
71
+ )
72
+ ),
73
+ );
74
+
75
+ $default_args = array(
76
+ 'label' => __( 'WordPress Date Format', 'codepress-admin-columns' ),
77
+ 'date_format' => $this->get_wp_date_format(),
78
+ );
79
+
80
+ if ( current_user_can( 'manage_options' ) ) {
81
+ $default_args['description'] = sprintf( __( 'The %s can be changed in %s.', 'codepress-admin-columns' ), $default_args['label'], ac_helper()->html->link( admin_url( 'options-general.php' ) . '#date_format_custom_radio', strtolower( __( 'General Settings' ) ) ) );
82
+ }
83
+
84
+ $options['wp_default'] = $this->get_html_label( $default_args );
85
+
86
+ $formats = array(
87
+ 'j F Y',
88
+ 'Y-m-d',
89
+ 'm/d/Y',
90
+ 'd/m/Y',
91
+ );
92
+
93
+ foreach ( $formats as $format ) {
94
+ $options[ $format ] = $this->get_html_label( array( 'label' => date_i18n( $format ), 'date_format' => $format ) );
95
+ }
96
+
97
+ $custom_label = $this->get_html_label( array(
98
+ 'label' => __( 'Custom:', 'codepress-admin columns' ),
99
+ 'description' => sprintf( __( 'Learn more about %s.', 'codepress-admin-columns' ), ac_helper()->html->link( 'http://codex.wordpress.org/Formatting_Date_and_Time', __( 'date and time formatting', 'codepress-admin-columns' ) ), array( 'target' => '_blank' ) ),
100
+ )
101
+ );
102
+ $custom_label .= '<input type="text" class="ac-setting-input-date__custom" value="' . esc_attr( $this->get_date_format() ) . '" disabled>';
103
+ $custom_label .= '<span class="ac-setting-input-date__example"></span>';
104
+
105
+ $options['custom'] = $custom_label;
106
+
107
+ return $options;
108
+ }
109
+
110
+ private function get_wp_date_format() {
111
+ return get_option( 'date_format' );
112
+ }
113
+
114
+ /**
115
+ * @return mixed
116
+ */
117
+ public function get_date_format() {
118
+ return $this->date_format;
119
+ }
120
+
121
+ /**
122
+ * @param mixed $date_format
123
+ *
124
+ * @return bool
125
+ */
126
+ public function set_date_format( $date_format ) {
127
+ $this->date_format = trim( $date_format );
128
+
129
+ return true;
130
+ }
131
+
132
+ /**
133
+ * @param string $date
134
+ *
135
+ * @return string
136
+ */
137
+ public function format( $date, $original_value ) {
138
+ if ( ! $date || ! is_scalar( $date ) ) {
139
+ return false;
140
+ }
141
+
142
+ $date_format = $this->get_date_format();
143
+
144
+ if ( ! $date_format ) {
145
+ $date_format = $this->get_default();
146
+ }
147
+
148
+ $timestamp = strtotime( $date );
149
+
150
+ switch ( $date_format ) {
151
+
152
+ case 'wp_default' :
153
+ $date = date_i18n( $this->get_wp_date_format(), $timestamp );
154
+
155
+ break;
156
+ case 'diff' :
157
+ $date = $this->format_human_time_diff( $timestamp );
158
+
159
+ break;
160
+ default :
161
+
162
+ $date = date_i18n( $this->get_date_format(), $timestamp );
163
+ }
164
+
165
+ return $date;
166
+ }
167
+
168
+ /**
169
+ * @param int $timestamp Unix time stamp
170
+ *
171
+ * @return string
172
+ */
173
+ public function format_human_time_diff( $timestamp ) {
174
+ if ( ! $timestamp ) {
175
+ return false;
176
+ }
177
+
178
+ $tpl = __( '%s ago' );
179
+
180
+ if ( $timestamp > current_time( 'U' ) ) {
181
+ $tpl = __( 'in %s', 'codepress-admin-columns' );
182
+ }
183
+
184
+ return sprintf( $tpl, human_time_diff( $timestamp ) );
185
+ }
186
+
187
+ }
classes/Settings/Column/ExifData.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_ExifData extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $exif_datatype;
14
+
15
+ protected function set_name() {
16
+ $this->name = 'exif_data';
17
+ }
18
+
19
+ protected function define_options() {
20
+ return array( 'exif_datatype' );
21
+ }
22
+
23
+ public function create_view() {
24
+ return new AC_View( array(
25
+ 'label' => $this->column->get_label(),
26
+ 'setting' => $this->create_element( 'select' )->set_options( $this->get_exif_types() ),
27
+ ) );
28
+ }
29
+
30
+ /**
31
+ * Get EXIF data
32
+ *
33
+ * Get extended image metadata
34
+ *
35
+ * @since 2.0
36
+ *
37
+ * @return array EXIF data types
38
+ */
39
+ private function get_exif_types() {
40
+ $exif_types = array(
41
+ 'aperture' => __( 'Aperture', 'codepress-admin-columns' ),
42
+ 'credit' => __( 'Credit', 'codepress-admin-columns' ),
43
+ 'camera' => __( 'Camera', 'codepress-admin-columns' ),
44
+ 'caption' => __( 'Caption', 'codepress-admin-columns' ),
45
+ 'created_timestamp' => __( 'Timestamp', 'codepress-admin-columns' ),
46
+ 'copyright' => __( 'Copyright EXIF', 'codepress-admin-columns' ),
47
+ 'focal_length' => __( 'Focal Length', 'codepress-admin-columns' ),
48
+ 'iso' => __( 'ISO', 'codepress-admin-columns' ),
49
+ 'shutter_speed' => __( 'Shutter Speed', 'codepress-admin-columns' ),
50
+ 'title' => __( 'Title', 'codepress-admin-columns' ),
51
+ );
52
+
53
+ natcasesort( $exif_types );
54
+
55
+ return $exif_types;
56
+ }
57
+
58
+ /**
59
+ * @return string
60
+ */
61
+ public function get_exif_datatype() {
62
+ return $this->exif_datatype;
63
+ }
64
+
65
+ /**
66
+ * @param string $exif_datatype
67
+ *
68
+ * @return bool
69
+ */
70
+ public function set_exif_datatype( $exif_datatype ) {
71
+ $this->exif_datatype = $exif_datatype;
72
+
73
+ return true;
74
+ }
75
+
76
+ public function format( $value, $original_value ) {
77
+ $exif_datatype = $this->get_exif_datatype();
78
+ $value = isset( $value[ $exif_datatype ] ) ? $value[ $exif_datatype ] : '';
79
+
80
+ if ( false !== $value ) {
81
+ switch ( $exif_datatype ) {
82
+ case 'created_timestamp' :
83
+ $value = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $value ) );
84
+
85
+ break;
86
+ }
87
+ }
88
+
89
+ return $value;
90
+ }
91
+
92
+ }
classes/Settings/Column/Image.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Image extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $image_size;
14
+
15
+ /**
16
+ * @var integer
17
+ */
18
+ private $image_size_w;
19
+
20
+ /**
21
+ * @var integer
22
+ */
23
+ private $image_size_h;
24
+
25
+ protected function set_name() {
26
+ return $this->name = 'image';
27
+ }
28
+
29
+ protected function define_options() {
30
+ return array(
31
+ 'image_size',
32
+ 'image_size_w' => 80,
33
+ 'image_size_h' => 80,
34
+ );
35
+ }
36
+
37
+ public function create_view() {
38
+ $width = new AC_View( array(
39
+ 'setting' => $this->create_element( 'number', 'image_size_w' ),
40
+ 'label' => __( 'Width', 'codepress-admin-columns' ),
41
+ 'tooltip' => __( 'Width in pixels', 'codepress-admin-columns' ),
42
+ ) );
43
+
44
+ $height = new AC_View( array(
45
+ 'setting' => $this->create_element( 'number', 'image_size_h' ),
46
+ 'label' => __( 'Height', 'codepress-admin-columns' ),
47
+ 'tooltip' => __( 'Height in pixels', 'codepress-admin-columns' ),
48
+ ) );
49
+
50
+ $size = $this->create_element( 'select', 'image_size' )
51
+ ->set_options( $this->get_grouped_image_sizes() );
52
+
53
+ $view = new AC_View( array(
54
+ 'label' => __( 'Image Size', 'codepress-admin-columns' ),
55
+ 'setting' => $size,
56
+ 'sections' => array( $width, $height ),
57
+ ) );
58
+
59
+ return $view;
60
+ }
61
+
62
+ /**
63
+ * @since 1.0
64
+ * @return array
65
+ */
66
+ private function get_grouped_image_sizes() {
67
+ global $_wp_additional_image_sizes;
68
+
69
+ $sizes = array(
70
+ 'default' => array(
71
+ 'title' => __( 'Default', 'codepress-admin-columns' ),
72
+ 'options' => array(
73
+ 'thumbnail' => __( 'Thumbnail', 'codepress-admin-columns' ),
74
+ 'medium' => __( 'Medium', 'codepress-admin-columns' ),
75
+ 'large' => __( 'Large', 'codepress-admin-columns' ),
76
+ ),
77
+ ),
78
+ );
79
+
80
+ $all_sizes = get_intermediate_image_sizes();
81
+
82
+ if ( ! empty( $all_sizes ) ) {
83
+ foreach ( $all_sizes as $size ) {
84
+ if ( 'medium_large' == $size || isset( $sizes['default']['options'][ $size ] ) ) {
85
+ continue;
86
+ }
87
+
88
+ if ( ! isset( $sizes['defined'] ) ) {
89
+ $sizes['defined']['title'] = __( 'Others', 'codepress-admin-columns' );
90
+ }
91
+
92
+ $sizes['defined']['options'][ $size ] = ucwords( str_replace( '-', ' ', $size ) );
93
+ }
94
+ }
95
+
96
+ foreach ( $sizes as $key => $group ) {
97
+ foreach ( array_keys( $group['options'] ) as $_size ) {
98
+
99
+ $w = isset( $_wp_additional_image_sizes[ $_size ]['width'] ) ? $_wp_additional_image_sizes[ $_size ]['width'] : get_option( "{$_size}_size_w" );
100
+ $h = isset( $_wp_additional_image_sizes[ $_size ]['height'] ) ? $_wp_additional_image_sizes[ $_size ]['height'] : get_option( "{$_size}_size_h" );
101
+
102
+ if ( $w && $h ) {
103
+ $sizes[ $key ]['options'][ $_size ] .= " ($w x $h)";
104
+ }
105
+ }
106
+ }
107
+
108
+ $sizes['default']['options']['full'] = __( 'Full Size', 'codepress-admin-columns' );
109
+
110
+ $sizes['custom'] = array(
111
+ 'title' => __( 'Custom', 'codepress-admin-columns' ),
112
+ 'options' => array( 'cpac-custom' => __( 'Custom Size', 'codepress-admin-columns' ) . '&hellip;' ),
113
+ );
114
+
115
+ return $sizes;
116
+ }
117
+
118
+ /**
119
+ * @return string
120
+ */
121
+ public function get_image_size() {
122
+ return $this->image_size;
123
+ }
124
+
125
+ /**
126
+ * @param string $image_size
127
+ *
128
+ * @return bool
129
+ */
130
+ public function set_image_size( $image_size ) {
131
+ $this->image_size = $image_size;
132
+
133
+ return true;
134
+ }
135
+
136
+ /**
137
+ * @return int
138
+ */
139
+ public function get_image_size_w() {
140
+ return $this->image_size_w;
141
+ }
142
+
143
+ /**
144
+ * @param int $image_size_w
145
+ *
146
+ * @return bool
147
+ */
148
+ public function set_image_size_w( $image_size_w ) {
149
+ if ( ! is_numeric( $image_size_w ) ) {
150
+ return false;
151
+ }
152
+
153
+ $this->image_size_w = $image_size_w;
154
+
155
+ return true;
156
+ }
157
+
158
+ /**
159
+ * @return int
160
+ */
161
+ public function get_image_size_h() {
162
+ return $this->image_size_h;
163
+ }
164
+
165
+ /**
166
+ * @param int $image_size_h
167
+ *
168
+ * @return bool
169
+ */
170
+ public function set_image_size_h( $image_size_h ) {
171
+ if ( ! is_numeric( $image_size_h ) ) {
172
+ return false;
173
+ }
174
+
175
+ $this->image_size_h = $image_size_h;
176
+
177
+ return true;
178
+ }
179
+
180
+ public function format( $value, $original_value ) {
181
+ $size = $this->get_image_size();
182
+
183
+ if ( 'cpac-custom' == $size ) {
184
+ $size = array( $this->get_image_size_w(), $this->get_image_size_h() );
185
+ }
186
+
187
+ // fallback size
188
+ if ( empty( $size ) ) {
189
+ $size = array( 80, 80 );
190
+ }
191
+
192
+ return ac_helper()->image->get_image( $value, $size );
193
+ }
194
+
195
+ }
classes/Settings/Column/Label.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Label extends AC_Settings_Column {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $label;
13
+
14
+ protected function define_options() {
15
+ return array(
16
+ 'label' => $this->column->get_label(),
17
+ );
18
+ }
19
+
20
+ public function create_view() {
21
+
22
+ $setting = $this
23
+ ->create_element( 'text' )
24
+ ->set_attribute( 'placeholder', $this->column->get_label() );
25
+
26
+ $view = new AC_View( array(
27
+ 'label' => __( 'Label', 'codepress-admin-columns' ),
28
+ 'tooltip' => __( 'This is the name which will appear as the column header.', 'codepress-admin-columns' ),
29
+ 'setting' => $setting,
30
+ ) );
31
+
32
+ return $view;
33
+ }
34
+
35
+ /**
36
+ * Convert site_url() to [cpac_site_url] and back for easy migration
37
+ *
38
+ * @param string $label
39
+ * @param string $action
40
+ *
41
+ * @return string
42
+ */
43
+ private function convert_site_url( $label, $action = 'encode' ) {
44
+ $input = array( site_url(), '[cpac_site_url]' );
45
+
46
+ if ( 'decode' == $action ) {
47
+ $input = array_reverse( $input );
48
+ }
49
+
50
+ return stripslashes( str_replace( $input[0], $input[1], trim( $label ) ) );
51
+ }
52
+
53
+ /**
54
+ * @return string
55
+ */
56
+ public function get_label() {
57
+ return $this->convert_site_url( $this->label, 'decode' );
58
+ }
59
+
60
+ /**
61
+ * @param string $label
62
+ */
63
+ public function set_label( $label ) {
64
+ $this->label = $label;
65
+ }
66
+
67
+ /**
68
+ * Encode label with site_url.
69
+ * Used when loading the setting from PHP or when a site is migrated to another domain.
70
+ *
71
+ * @return string
72
+ */
73
+ public function get_encoded_label() {
74
+ return $this->convert_site_url( $this->label );
75
+ }
76
+
77
+ }
classes/Settings/Column/LinkLabel.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_LinkLabel extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $link_label;
14
+
15
+ protected function define_options() {
16
+ return array( 'link_label' );
17
+ }
18
+
19
+ public function create_view() {
20
+ $view = new AC_View( array(
21
+ 'setting' => $this->create_element( 'text' ),
22
+ 'label' => __( 'Link Label', 'codepress-admin-columns' ),
23
+ 'tooltip' => __( 'Leave blank to display the url', 'codepress-admin-columns' ),
24
+ ) );
25
+
26
+ return $view;
27
+ }
28
+
29
+ /**
30
+ * @return string
31
+ */
32
+ public function get_link_label() {
33
+ return $this->link_label;
34
+ }
35
+
36
+ /**
37
+ * @param string $link_label
38
+ *
39
+ * @return bool
40
+ */
41
+ public function set_link_label( $link_label ) {
42
+ $this->link_label = $link_label;
43
+
44
+ return true;
45
+ }
46
+
47
+ public function format( $value, $original_value ) {
48
+ $url = $value;
49
+
50
+ if ( filter_var( $url, FILTER_VALIDATE_URL ) && preg_match( '/[^\w.-]/', $url ) ) {
51
+ $label = $this->get_value();
52
+
53
+ if ( ! $label ) {
54
+ $label = $url;
55
+ }
56
+
57
+ $value = ac_helper()->html->link( $url, $label );
58
+ }
59
+
60
+ return $value;
61
+ }
62
+
63
+ }
classes/Settings/Column/LinkToMenu.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_LinkToMenu extends AC_Settings_Column_Toggle
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $link_to_menu;
14
+
15
+ protected function define_options() {
16
+ return array(
17
+ 'link_to_menu' => 'on',
18
+ );
19
+ }
20
+
21
+ public function create_view() {
22
+ $view = parent::create_view();
23
+
24
+ $view->set_data( array(
25
+ 'label' => __( 'Link to menu', 'codepress-admin-columns' ),
26
+ 'tooltip' => __( 'This will make the title link to the menu.', 'codepress-admin-columns' ),
27
+ ) );
28
+
29
+ return $view;
30
+ }
31
+
32
+ /**
33
+ * @return string
34
+ */
35
+ public function get_link_to_menu() {
36
+ return $this->link_to_menu;
37
+ }
38
+
39
+ /**
40
+ * @param string $link_to_menu
41
+ *
42
+ * @return bool
43
+ */
44
+ public function set_link_to_menu( $link_to_menu ) {
45
+ $this->link_to_menu = $link_to_menu;
46
+
47
+ return true;
48
+ }
49
+
50
+ /**
51
+ * @param int[] $menu_ids
52
+ * @param mixed $original_value
53
+ *
54
+ * @return false|string
55
+ */
56
+ public function format( $menu_ids, $original_value ) {
57
+ if ( ! $menu_ids ) {
58
+ return $this->column->get_empty_char();
59
+ }
60
+
61
+ $values = array();
62
+
63
+ foreach ( $menu_ids as $menu_id ) {
64
+ $term = get_term_by( 'id', $menu_id, 'nav_menu' );
65
+
66
+ if ( 'on' === $this->get_link_to_menu() ) {
67
+ $term->name = ac_helper()->html->link( add_query_arg( array( 'menu' => $menu_id ), admin_url( 'nav-menus.php' ) ), $term->name );
68
+ }
69
+
70
+ $values[] = $term->name;
71
+ }
72
+
73
+ return implode( $this->column->get_separator(), $values );
74
+ }
75
+
76
+ }
classes/Settings/Column/Message.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Message extends AC_Settings_Column {
8
+
9
+ private $label;
10
+
11
+ private $message;
12
+
13
+ protected function set_name() {
14
+ $this->name = 'message';
15
+ }
16
+
17
+ protected function define_options() {
18
+ return array();
19
+ }
20
+
21
+ public function set_label( $label ) {
22
+ $this->label = $label;
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function set_message( $message ) {
28
+ $this->message = $message;
29
+
30
+ return $this;
31
+ }
32
+
33
+ public function create_view() {
34
+ $view = new AC_View( array(
35
+ 'label' => $this->label,
36
+ 'setting' => $this->message,
37
+ ) );
38
+
39
+ return $view;
40
+ }
41
+
42
+ }
classes/Settings/Column/Meta.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Settings_Column_Meta extends AC_Settings_Column {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $field;
13
+
14
+ abstract protected function get_meta_keys();
15
+
16
+ protected function define_options() {
17
+ return array( 'field' );
18
+ }
19
+
20
+ /**
21
+ * @return AC_Settings_Form_Element_Select
22
+ */
23
+ protected function get_setting_field() {
24
+ $setting = $this
25
+ ->create_element( 'select', 'field' )
26
+ ->set_options( $this->group_keys( $this->get_cached_keys() ) )
27
+ ->set_no_result( __( 'No fields available.', 'codepress-admin-columns' ) );
28
+
29
+ return $setting;
30
+ }
31
+
32
+ /**
33
+ * @return array|false
34
+ */
35
+ protected function get_cached_keys() {
36
+ $keys = $this->get_cache();
37
+
38
+ if ( ! $keys ) {
39
+ $keys = $this->get_meta_keys();
40
+
41
+ $this->set_cache( $keys );
42
+ }
43
+
44
+ return $keys;
45
+ }
46
+
47
+ /**
48
+ * @return string
49
+ */
50
+ protected function get_cache_key() {
51
+ return $this->column->get_list_screen()->get_storage_key();
52
+ }
53
+
54
+ protected function get_cache_group() {
55
+ return 'ac_settings_meta';
56
+ }
57
+
58
+ /**
59
+ * @return AC_View
60
+ */
61
+ public function create_view() {
62
+ $view = new AC_View( array(
63
+ 'label' => __( 'Field', 'codepress-admin-columns' ),
64
+ 'setting' => $this->get_setting_field(),
65
+ ) );
66
+
67
+ return $view;
68
+ }
69
+
70
+ /**
71
+ * @return string
72
+ */
73
+ public function get_field() {
74
+ return $this->field;
75
+ }
76
+
77
+ /**
78
+ * @param string $field
79
+ *
80
+ * @return bool
81
+ */
82
+ public function set_field( $field ) {
83
+ $this->field = $field;
84
+
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Get temp cache
90
+ */
91
+ private function get_cache() {
92
+ wp_cache_get( $this->get_cache_key(), $this->get_cache_group() );
93
+ }
94
+
95
+ /**
96
+ * @param array $data
97
+ * @param int $expire Seconds
98
+ */
99
+ private function set_cache( $data, $expire = 15 ) {
100
+ wp_cache_add( $this->get_cache_key(), $data, $this->get_cache_group(), $expire );
101
+ }
102
+
103
+ private function group_keys( $keys ) {
104
+ if ( ! $keys ) {
105
+ return array();
106
+ }
107
+
108
+ $options = array(
109
+ 'hidden' => array(
110
+ 'title' => __( 'Hidden Custom Fields', 'codepress-admin-columns' ),
111
+ 'options' => array(),
112
+ ),
113
+ 'public' => array(
114
+ 'title' => __( 'Custom Fields', 'codepress-admin-columns' ),
115
+ 'options' => array(),
116
+ ),
117
+ );
118
+
119
+ foreach ( $keys as $field ) {
120
+ $group = 0 === strpos( $field[0], '_' ) ? 'hidden' : 'public';
121
+
122
+ $options[ $group ]['options'][ $field ] = $field;
123
+ }
124
+
125
+ krsort( $options ); // public first
126
+
127
+ if ( empty( $options['hidden']['options'] ) ) {
128
+ unset( $options['hidden'] );
129
+ }
130
+
131
+ if ( empty( $options['public']['options'] ) ) {
132
+ unset( $options['public'] );
133
+ }
134
+
135
+ // Remove groups when there is only one group
136
+ if ( 1 === count( $options ) ) {
137
+ $options = array_pop( $options );
138
+
139
+ $options = $options['options'];
140
+ }
141
+
142
+ return $options;
143
+ }
144
+
145
+ }
classes/Settings/Column/Password.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Password extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $password;
14
+
15
+ protected function define_options() {
16
+ return array( 'password' );
17
+ }
18
+
19
+ public function create_view() {
20
+ $select = $this->create_element( 'select' )
21
+ ->set_options( array(
22
+ '' => __( 'Password', 'codepress-admin-column' ), // default
23
+ 'text' => __( 'Plain text', 'codepress-admin-column' ),
24
+ ) );
25
+
26
+ $view = new AC_View( array(
27
+ 'label' => __( 'Display format', 'codepress-admin-columns' ),
28
+ 'setting' => $select,
29
+ ) );
30
+
31
+ return $view;
32
+ }
33
+
34
+ /**
35
+ * @return string
36
+ */
37
+ public function get_password() {
38
+ return $this->password;
39
+ }
40
+
41
+ /**
42
+ * @param string $password
43
+ *
44
+ * @return true
45
+ */
46
+ public function set_password( $password ) {
47
+ $this->password = $password;
48
+
49
+ return true;
50
+ }
51
+
52
+ public function format( $value, $original_value ) {
53
+ if ( ! $this->get_password() ) {
54
+ $pwchar = '&#8226;';
55
+ $value = $value ? str_pad( '', strlen( $value ) * strlen( $pwchar ), $pwchar ) : '';
56
+ }
57
+
58
+ return $value;
59
+ }
60
+
61
+ }
classes/Settings/Column/PathScope.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_PathScope extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $path_scope;
14
+
15
+ protected function define_options() {
16
+ return array(
17
+ 'path_scope' => 'full',
18
+ );
19
+ }
20
+
21
+ public function create_view() {
22
+ $select = $this->create_element( 'select', 'path_scope' )
23
+ ->set_options( array(
24
+ 'full' => __( 'Full path', 'codepress-admin-columns' ),
25
+ 'relative-domain' => __( 'Relative to domain', 'codepress-admin-columns' ),
26
+ 'relative-uploads' => __( 'Relative to main uploads folder ', 'codepress-admin-columns' ),
27
+ ) );
28
+
29
+ $view = new AC_View( array(
30
+ 'label' => __( 'Path scope', 'codepress-admin-columns' ),
31
+ 'tooltip' => __( 'Part of the file path to display', 'codepress-admin-columns' ),
32
+ 'setting' => $select,
33
+ ) );
34
+
35
+ return $view;
36
+ }
37
+
38
+ /**
39
+ * @return string
40
+ */
41
+ public function get_path_scope() {
42
+ return $this->path_scope;
43
+ }
44
+
45
+ /**
46
+ * @param string $path_scope
47
+ *
48
+ * @return bool
49
+ */
50
+ public function set_path_scope( $path_scope ) {
51
+ $this->path_scope = $path_scope;
52
+
53
+ return true;
54
+ }
55
+
56
+ public function format( $value, $original_value ) {
57
+ $file = $value;
58
+ $value = '';
59
+
60
+ if ( $file ) {
61
+ $file = str_replace( 'https://', 'http://', $file );
62
+
63
+ switch ( $this->get_path_scope() ) {
64
+ case 'relative-domain' :
65
+ $url = str_replace( 'https://', 'http://', home_url( '/' ) );
66
+
67
+ if ( strpos( $file, $url ) === 0 ) {
68
+ $file = '/' . substr( $file, strlen( $url ) );
69
+ }
70
+
71
+ break;
72
+ case 'relative-uploads' :
73
+ $upload_dir = wp_upload_dir();
74
+ $url = str_replace( 'https://', 'http://', $upload_dir['baseurl'] );
75
+
76
+ if ( strpos( $file, $url ) === 0 ) {
77
+ $file = substr( $file, strlen( $url ) );
78
+ }
79
+
80
+ break;
81
+ }
82
+
83
+ $value = $file;
84
+ }
85
+
86
+ return $value;
87
+ }
88
+
89
+ }
classes/Settings/Column/Post.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Post extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $post_property;
14
+
15
+ protected function set_name() {
16
+ $this->name = 'post';
17
+ }
18
+
19
+ protected function define_options() {
20
+ return array(
21
+ 'post_property_display' => 'title',
22
+ );
23
+ }
24
+
25
+ public function get_dependent_settings() {
26
+ $setting = array();
27
+
28
+ switch ( $this->get_post_property_display() ) {
29
+ case 'thumbnail' :
30
+ $setting[] = new AC_Settings_Column_Image( $this->column );
31
+ break;
32
+ }
33
+
34
+ $setting[] = new AC_Settings_Column_PostLink( $this->column );
35
+
36
+ return $setting;
37
+ }
38
+
39
+ public function format( $value, $original_value ) {
40
+ $id = $original_value;
41
+ $value = false;
42
+
43
+ switch ( $this->get_post_property_display() ) {
44
+ case 'author' :
45
+ $value = ac_helper()->user->get_display_name( ac_helper()->post->get_raw_field( 'post_author', $id ) );
46
+
47
+ break;
48
+ case 'thumbnail' :
49
+ $value = get_post_thumbnail_id( $id );
50
+
51
+ break;
52
+ case 'title' :
53
+ $value = ac_helper()->post->get_title( $id );
54
+
55
+ break;
56
+ case 'id' :
57
+ $value = $id;
58
+
59
+ break;
60
+ }
61
+
62
+ return $value;
63
+ }
64
+
65
+ public function create_view() {
66
+ $select = $this->create_element( 'select' )
67
+ ->set_attribute( 'data-refresh', 'column' )
68
+ ->set_options( $this->get_display_options() );
69
+
70
+ $view = new AC_View( array(
71
+ 'label' => __( 'Field', 'codepress-admin-columns' ),
72
+ 'setting' => $select,
73
+ ) );
74
+
75
+ return $view;
76
+ }
77
+
78
+ protected function get_display_options() {
79
+ $options = array(
80
+ 'title' => __( 'Title' ),
81
+ 'id' => __( 'ID' ),
82
+ 'author' => __( 'Author' ),
83
+ 'thumbnail' => __( 'Featured Image' ),
84
+ );
85
+
86
+ asort( $options );
87
+
88
+ return $options;
89
+ }
90
+
91
+ /**
92
+ * @return string
93
+ */
94
+ public function get_post_property_display() {
95
+ return $this->post_property;
96
+ }
97
+
98
+ /**
99
+ * @param string $post_property
100
+ *
101
+ * @return bool
102
+ */
103
+ public function set_post_property_display( $post_property ) {
104
+ $this->post_property = $post_property;
105
+
106
+ return true;
107
+ }
108
+
109
+ }
classes/Settings/Column/PostLink.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_PostLink extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $post_link_to;
14
+
15
+ protected function define_options() {
16
+ return array(
17
+ 'post_link_to' => 'edit_post',
18
+ );
19
+ }
20
+
21
+ public function format( $value, $original_value ) {
22
+ $id = $original_value;
23
+
24
+ switch ( $this->get_post_link_to() ) {
25
+ case 'edit_post' :
26
+ $link = get_edit_post_link( $id );
27
+
28
+ break;
29
+ case 'view_post' :
30
+ $link = get_permalink( $id );
31
+
32
+ break;
33
+ case 'edit_author' :
34
+ $link = get_edit_user_link( ac_helper()->post->get_raw_field( 'post_author', $id ) );
35
+
36
+ break;
37
+ case 'view_author' :
38
+ $link = get_author_posts_url( ac_helper()->post->get_raw_field( 'post_author', $id ) );
39
+
40
+ break;
41
+ default :
42
+ $link = false;
43
+ }
44
+
45
+ if ( $link ) {
46
+ $value = ac_helper()->html->link( $link, $value );
47
+ }
48
+
49
+ return $value;
50
+ }
51
+
52
+ public function create_view() {
53
+ $select = $this->create_element( 'select' )->set_options( $this->get_display_options() );
54
+
55
+ $view = new AC_View( array(
56
+ 'label' => __( 'Link To', 'codepress-admin-columns' ),
57
+ 'setting' => $select,
58
+ ) );
59
+
60
+ return $view;
61
+ }
62
+
63
+ private function get_display_options() {
64
+ $options = array(
65
+ 'edit_post' => __( 'Edit Post' ),
66
+ 'view_post' => __( 'View Post' ),
67
+ 'edit_author' => __( 'Edit Post Author', 'codepress-admin-columns' ),
68
+ 'view_author' => __( 'View Public Post Author Page', 'codepress-admin-columns' ),
69
+ );
70
+
71
+ asort( $options );
72
+
73
+ $options = array_merge( array( '' => __( 'None' ) ), $options );
74
+
75
+ return $options;
76
+ }
77
+
78
+ /**
79
+ * @return string
80
+ */
81
+ public function get_post_link_to() {
82
+ return $this->post_link_to;
83
+ }
84
+
85
+ /**
86
+ * @param string $post_link_to
87
+ *
88
+ * @return bool
89
+ */
90
+ public function set_post_link_to( $post_link_to ) {
91
+ $this->post_link_to = $post_link_to;
92
+
93
+ return true;
94
+ }
95
+
96
+ }
classes/Settings/Column/PostType.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_PostType extends AC_Settings_Column {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $post_type;
13
+
14
+ protected function define_options() {
15
+ return array( 'post_type' );
16
+ }
17
+
18
+ public function create_view() {
19
+ $setting = $this->create_element( 'select' )
20
+ ->set_options( $this->get_post_type_labels() );
21
+
22
+ $view = new AC_View( array(
23
+ 'label' => __( 'Post Type', 'codepress-admin-columns' ),
24
+ 'setting' => $setting,
25
+ ) );
26
+
27
+ return $view;
28
+ }
29
+
30
+ private function get_post_type_labels() {
31
+ $options = array();
32
+ $post_types = AC()->get_post_types();
33
+
34
+ if ( ! is_array( $post_types ) ) {
35
+ return $options;
36
+ }
37
+
38
+ foreach ( $post_types as $post_type ) {
39
+ $post_type_object = get_post_type_object( $post_type );
40
+ $options[ $post_type ] = $post_type_object->labels->name;
41
+ }
42
+
43
+ return $options;
44
+ }
45
+
46
+ /**
47
+ * @return string
48
+ */
49
+ public function get_post_type() {
50
+ return $this->post_type;
51
+ }
52
+
53
+ /**
54
+ * @param string $post_type
55
+ *
56
+ * @return true
57
+ */
58
+ public function set_post_type( $post_type ) {
59
+ $this->post_type = $post_type;
60
+
61
+ return true;
62
+ }
63
+
64
+ }
classes/Settings/Column/Separator.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Separator extends AC_Settings_Column
8
+ implements AC_Settings_FormatCollectionInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $separator;
14
+
15
+ protected function define_options() {
16
+ return array( 'separator' => 'comma' );
17
+ }
18
+
19
+ public function create_view() {
20
+ $element = $this
21
+ ->create_element( 'select' )
22
+ ->set_options( array(
23
+ '' => __( 'Default', 'codepress-admin-columns' ),
24
+ 'comma' => __( 'Comma Separated', 'codepress-admin-columns' ),
25
+ 'newline' => __( 'New line', 'codepress-admin-columns' ),
26
+ 'none' => __( 'None', 'codepress-admin-columns' ),
27
+ 'white_space' => __( 'Whitespace', 'codepress-admin-columns' ),
28
+ ) );
29
+
30
+ $view = new AC_View( array(
31
+ 'label' => __( 'Separator', 'codepress-admin-columns' ),
32
+ 'tooltip' => __( 'Select a repeater sub field.', 'codepress-admin-columns' ),
33
+ 'setting' => $element,
34
+ ) );
35
+
36
+ return $view;
37
+ }
38
+
39
+ public function get_separator() {
40
+ return $this->separator;
41
+ }
42
+
43
+ public function set_separator( $separator ) {
44
+ $this->separator = $separator;
45
+
46
+ return $this;
47
+ }
48
+
49
+ public function format( AC_Collection $collection, $original_value ) {
50
+ switch ( $this->separator ) {
51
+ case 'comma' :
52
+ $separator = ', ';
53
+
54
+ break;
55
+ case 'newline' :
56
+ $separator = "<br/>";
57
+
58
+ break;
59
+ case 'none' :
60
+ $separator = '';
61
+
62
+ break;
63
+ case 'white_space' :
64
+ $separator = '&nbsp;';
65
+
66
+ break;
67
+ default :
68
+ $separator = $this->column->get_separator();
69
+ }
70
+
71
+ return $collection->filter()->implode( $separator );
72
+ }
73
+
74
+ }
classes/Settings/Column/Taxonomy.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Taxonomy extends AC_Settings_Column {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $taxonomy;
13
+
14
+ protected function define_options() {
15
+ return array( 'taxonomy' );
16
+ }
17
+
18
+ /**
19
+ * @return AC_View
20
+ */
21
+ public function create_view() {
22
+ $taxonomy = $this->create_element( 'select', 'taxonomy' );
23
+ $taxonomy->set_no_result( __( 'No taxonomies available.' ) )
24
+ ->set_options( ac_helper()->taxonomy->get_taxonomy_selection_options( $this->column->get_post_type() ) )
25
+ ->set_attribute( 'data-refresh', 'column' );
26
+
27
+ return new AC_View( array(
28
+ 'setting' => $taxonomy,
29
+ 'label' => __( 'Taxonomy', 'codepress-admin-columns' ),
30
+ ) );
31
+ }
32
+
33
+ /**
34
+ * @return string
35
+ */
36
+ public function get_taxonomy() {
37
+ return $this->taxonomy;
38
+ }
39
+
40
+ /**
41
+ * @param string $taxonomy
42
+ *
43
+ * @return bool
44
+ */
45
+ public function set_taxonomy( $taxonomy ) {
46
+ $this->taxonomy = $taxonomy;
47
+
48
+ return true;
49
+ }
50
+
51
+ }
classes/Settings/Column/Term.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Term extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $term_property;
14
+
15
+ protected function set_name() {
16
+ $this->name = 'term';
17
+ }
18
+
19
+ protected function define_options() {
20
+ return array( 'term_property' );
21
+ }
22
+
23
+ public function create_view() {
24
+ $setting = $this
25
+ ->create_element( 'select' )
26
+ ->set_options( array(
27
+ '' => __( 'Title' ),
28
+ 'slug' => __( 'Slug' ),
29
+ 'id' => __( 'ID' ),
30
+ ) );
31
+
32
+ $view = new AC_View( array(
33
+ 'label' => __( 'Display', 'codepress-admin-columns' ),
34
+ 'setting' => $setting,
35
+ ) );
36
+
37
+ return $view;
38
+ }
39
+
40
+ /**
41
+ * @return string
42
+ */
43
+ public function get_term_property() {
44
+ return $this->term_property;
45
+ }
46
+
47
+ /**
48
+ * @param string $term_property
49
+ *
50
+ * @return bool
51
+ */
52
+ public function set_term_property( $term_property ) {
53
+ $this->term_property = $term_property;
54
+
55
+ return true;
56
+ }
57
+
58
+ public function format( $value, $original_value ) {
59
+
60
+ // For ACP_Column_Taxonomy_Parent
61
+ $term_id = $value;
62
+
63
+ switch ( $this->get_term_property() ) {
64
+ case 'slug' :
65
+ $label = ac_helper()->taxonomy->get_term_field( 'slug', $term_id, $this->column->get_taxonomy() );
66
+
67
+ break;
68
+ case 'id' :
69
+ $label = $term_id;
70
+
71
+ break;
72
+ default :
73
+ $label = ac_helper()->taxonomy->get_term_field( 'name', $term_id, $this->column->get_taxonomy() );
74
+ }
75
+
76
+ if ( ! $label ) {
77
+ $label = false;
78
+ }
79
+
80
+ return ac_helper()->html->link( get_edit_term_link( $term_id, $this->column->get_taxonomy() ), $label );
81
+ }
82
+
83
+ }
classes/Settings/Column/Toggle.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Settings_Column_Toggle extends AC_Settings_Column {
8
+
9
+ public function create_view() {
10
+ $setting = $this
11
+ ->create_element( 'radio' )
12
+ ->set_options( array(
13
+ 'on' => __( 'Yes' ),
14
+ 'off' => __( 'No' ),
15
+ ) );
16
+
17
+ $view = new AC_View( array(
18
+ 'setting' => $setting,
19
+ ) );
20
+
21
+ return $view;
22
+ }
23
+
24
+ }
classes/Settings/Column/Type.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Type extends AC_Settings_Column {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $type;
13
+
14
+ protected function define_options() {
15
+ return array(
16
+ 'type' => $this->column->get_type(),
17
+ );
18
+ }
19
+
20
+ public function create_view() {
21
+ $type = $this
22
+ ->create_element( 'select' )
23
+ ->set_options( $this->get_grouped_columns() );
24
+
25
+ // Tooltip
26
+ $tooltip = __( 'Choose a column type.', 'codepress-admin-columns' ) . '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->column->get_type() . '</em>';
27
+
28
+ if ( $this->column->get_name() ) {
29
+ $tooltip .= '<em>' . __( 'Name', 'codepress-admin-columns' ) . ': ' . $this->column->get_name() . '</em>';
30
+ }
31
+
32
+ $view = new AC_View( array(
33
+ 'setting' => $type,
34
+ 'label' => __( 'Type', 'codepress-admin-columns' ),
35
+ 'tooltip' => $tooltip,
36
+ ) );
37
+
38
+ return $view;
39
+ }
40
+
41
+ /**
42
+ * Returns the type label as human readable: no tags, underscores and capitalized.
43
+ *
44
+ * @param AC_Column|null $column
45
+ *
46
+ * @return string
47
+ */
48
+ private function get_clean_label( AC_Column $column ) {
49
+ $label = $column->get_label();
50
+
51
+ if ( 0 === strlen( strip_tags( $label ) ) ) {
52
+ $label = ucfirst( str_replace( '_', ' ', $column->get_type() ) );
53
+ }
54
+
55
+ return strip_tags( $label );
56
+ }
57
+
58
+ /**
59
+ * @param AC_ListScreen $list_screen
60
+ *
61
+ * @return array
62
+ */
63
+ private function get_grouped_columns() {
64
+ $columns = array();
65
+
66
+ // get columns and sort them
67
+ foreach ( $this->column->get_list_screen()->get_column_types() as $column ) {
68
+
69
+ /**
70
+ * @param string $group Group slug
71
+ * @param AC_Column $column
72
+ */
73
+ $group = apply_filters( 'ac/column_group', $column->get_group(), $column );
74
+
75
+ // Labels with html will be replaced by it's name.
76
+ $columns[ $group ][ $column->get_type() ] = $this->get_clean_label( $column );
77
+
78
+ if ( ! $column->is_original() ) {
79
+ natcasesort( $columns[ $group ] );
80
+ }
81
+ }
82
+
83
+ $grouped = array();
84
+
85
+ // create select options
86
+ foreach ( AC()->column_groups()->get_groups_sorted() as $group ) {
87
+ $slug = $group['slug'];
88
+
89
+ // hide empty groups
90
+ if ( ! isset( $columns[ $slug ] ) ) {
91
+ continue;
92
+ }
93
+
94
+ if ( ! isset( $grouped[ $slug ] ) ) {
95
+ $grouped[ $slug ]['title'] = $group['label'];
96
+ }
97
+
98
+ $grouped[ $slug ]['options'] = $columns[ $slug ];
99
+
100
+ unset( $columns[ $slug ] );
101
+ }
102
+
103
+ // Add columns to a "default" group when it has an invalid group assigned
104
+ foreach ( $columns as $group => $_columns ) {
105
+ foreach ( $_columns as $name => $label ) {
106
+ $grouped['default']['options'][ $name ] = $label;
107
+ }
108
+ }
109
+
110
+ return $grouped;
111
+ }
112
+
113
+ /**
114
+ * @return string
115
+ */
116
+ public function get_type() {
117
+ return $this->type;
118
+ }
119
+
120
+ /**
121
+ * @param string $type
122
+ *
123
+ * @return bool
124
+ */
125
+ public function set_type( $type ) {
126
+ $this->type = $type;
127
+
128
+ return true;
129
+ }
130
+
131
+ }
classes/Settings/Column/User.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_User extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $display_author_as;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $user_link_to;
19
+
20
+ protected function set_name() {
21
+ $this->name = 'user';
22
+ }
23
+
24
+ protected function define_options() {
25
+ return array( 'display_author_as', 'user_link_to' );
26
+ }
27
+
28
+ /**
29
+ * @return AC_View
30
+ */
31
+ public function create_view() {
32
+ $select = $this->create_element( 'select', 'display_author_as' )
33
+ ->set_attribute( 'data-refresh', 'column' )
34
+ ->set_options( $this->get_display_options() );
35
+
36
+ $display_format = new AC_View( array(
37
+ 'label' => __( 'Display', 'codepress-admin-columns' ),
38
+ 'setting' => $select,
39
+ 'for' => $select->get_id(),
40
+ ) );
41
+
42
+ $select = $this->create_element( 'select', 'user_link_to' )
43
+ ->set_attribute( 'data-refresh', 'column' )
44
+ ->set_options( $this->get_link_options() );
45
+
46
+ $link_format = new AC_View( array(
47
+ 'label' => __( 'Link To', 'codepress-admin-columns' ),
48
+ 'setting' => $select,
49
+ 'for' => $select->get_id(),
50
+ ) );
51
+
52
+ $view = new AC_View( array(
53
+ 'label' => __( 'User', 'codepress-admin-columns' ),
54
+ 'sections' => array( $display_format, $link_format ),
55
+ ) );
56
+
57
+ return $view;
58
+ }
59
+
60
+ /**
61
+ * @param int $user_id
62
+ *
63
+ * @return false|string
64
+ */
65
+ public function get_user_name( $user_id ) {
66
+ return ac_helper()->user->get_display_name( $user_id, $this->get_display_author_as() );
67
+ }
68
+
69
+ /**
70
+ * @param $user_id
71
+ *
72
+ * @return bool|string
73
+ */
74
+ private function get_user_link( $user_id ) {
75
+ $link = false;
76
+
77
+ switch ( $this->get_user_link_to() ) {
78
+
79
+ case 'edit_user' :
80
+ $link = get_edit_user_link( $user_id );
81
+
82
+ break;
83
+ case 'view_user_posts' :
84
+ $link = add_query_arg( array(
85
+ 'post_type' => $this->column->get_post_type(),
86
+ 'author' => get_the_author_meta( 'ID' ),
87
+ ), 'edit.php' );
88
+
89
+ break;
90
+ case 'view_author' :
91
+ $link = get_author_posts_url( $user_id );
92
+
93
+ break;
94
+ case 'email_user' :
95
+ if ( $email = get_the_author_meta( 'email', $user_id ) ) {
96
+ $link = 'mailto:' . $email;
97
+ }
98
+
99
+ break;
100
+ }
101
+
102
+ return $link;
103
+ }
104
+
105
+ /**
106
+ * @return array
107
+ */
108
+ private function get_display_options() {
109
+ $options = array(
110
+ 'display_name' => __( 'Display Name', 'codepress-admin-columns' ),
111
+ 'first_name' => __( 'First Name', 'codepress-admin-columns' ),
112
+ 'last_name' => __( 'Last Name', 'codepress-admin-columns' ),
113
+ 'nickname' => __( 'Nickname', 'codepress-admin-columns' ),
114
+ 'user_login' => __( 'User Login', 'codepress-admin-columns' ),
115
+ 'user_email' => __( 'User Email', 'codepress-admin-columns' ),
116
+ 'ID' => __( 'User ID', 'codepress-admin-columns' ),
117
+ 'first_last_name' => __( 'First and Last Name', 'codepress-admin-columns' ),
118
+ );
119
+
120
+ // resort for possible translations
121
+ natcasesort( $options );
122
+
123
+ return $options;
124
+ }
125
+
126
+ /**
127
+ * @return array
128
+ */
129
+ private function get_link_options() {
130
+ $options = array(
131
+ 'edit_user' => __( 'Edit User Profile' ),
132
+ 'email_user' => __( 'User Email' ),
133
+ 'view_user_posts' => __( 'View User Posts' ),
134
+ 'view_author' => __( 'View Public Author Page', 'codepress-admin-columns' ),
135
+ );
136
+
137
+ // resort for possible translations
138
+ natcasesort( $options );
139
+
140
+ $options = array_merge( array( '' => __( 'None' ) ), $options );
141
+
142
+ return $options;
143
+ }
144
+
145
+ /**
146
+ * @return string
147
+ */
148
+ public function get_display_author_as() {
149
+ return $this->display_author_as;
150
+ }
151
+
152
+ /**
153
+ * @param string $display_author_as
154
+ *
155
+ * @return bool
156
+ */
157
+ public function set_display_author_as( $display_author_as ) {
158
+ $this->display_author_as = $display_author_as;
159
+
160
+ return true;
161
+ }
162
+
163
+ /**
164
+ * @return string
165
+ */
166
+ public function get_user_link_to() {
167
+ return $this->user_link_to;
168
+ }
169
+
170
+ /**
171
+ * @param string $user_link_to
172
+ *
173
+ * @return bool
174
+ */
175
+ public function set_user_link_to( $user_link_to ) {
176
+ $this->user_link_to = $user_link_to;
177
+
178
+ return true;
179
+ }
180
+
181
+ public function format( $value, $original_value ) {
182
+ return ac_helper()->html->link( $this->get_user_link( $value ), $this->get_user_name( $value ) );
183
+ }
184
+
185
+ }
classes/Settings/Column/Width.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_Width extends AC_Settings_Column
8
+ implements AC_Settings_HeaderInterface {
9
+
10
+ /**
11
+ * @var integer
12
+ */
13
+ private $width;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $width_unit;
19
+
20
+ protected function define_options() {
21
+ return array(
22
+ 'width',
23
+ 'width_unit' => '%',
24
+ );
25
+ }
26
+
27
+ private function get_valid_width_units() {
28
+ return array(
29
+ '%' => '%',
30
+ 'px' => 'px',
31
+ );
32
+ }
33
+
34
+ private function is_valid_width_unit( $width_unit ) {
35
+ return array_key_exists( $width_unit, $this->get_valid_width_units() );
36
+ }
37
+
38
+ public function create_view() {
39
+ $width = $this->create_element( 'text' )
40
+ ->set_attribute( 'placeholder', __( 'Auto', 'codepress-admin-columns' ) );
41
+
42
+ $unit = $this->create_element( 'radio', 'width_unit' )
43
+ ->set_options( $this->get_valid_width_units() );
44
+
45
+ $section = new AC_View( array(
46
+ 'width' => $width,
47
+ 'unit' => $unit,
48
+ ) );
49
+ $section->set_template( 'settings/setting-width' );
50
+
51
+ $view = new AC_View( array(
52
+ 'label' => __( 'Width', 'codepress-admin-columns' ),
53
+ 'sections' => array( $section ),
54
+ ) );
55
+
56
+ return $view;
57
+ }
58
+
59
+ public function create_header_view() {
60
+
61
+ $view = new AC_View( array(
62
+ 'title' => __( 'width', 'codepress-admin-columns' ),
63
+ 'content' => $this->get_display_width(),
64
+ ) );
65
+
66
+ return $view;
67
+ }
68
+
69
+ /**
70
+ * @return int
71
+ */
72
+ public function get_width() {
73
+ return $this->width;
74
+ }
75
+
76
+ /**
77
+ * @param int $width
78
+ *
79
+ * @return bool
80
+ */
81
+ public function set_width( $value ) {
82
+
83
+ // Backwards compatible for AC 2.9
84
+ if ( '' === $value ) {
85
+ $this->width = $value;
86
+
87
+ return true;
88
+ }
89
+
90
+ $value = absint( $value );
91
+
92
+ if ( $value > 0 ) {
93
+ $this->width = $value;
94
+
95
+ return true;
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ /**
102
+ * @return string
103
+ */
104
+ public function get_width_unit() {
105
+ return $this->width_unit;
106
+ }
107
+
108
+ /**
109
+ * @param string $width_unit
110
+ *
111
+ * @return bool
112
+ */
113
+ public function set_width_unit( $width_unit ) {
114
+ if ( ! $this->is_valid_width_unit( $width_unit ) ) {
115
+ return false;
116
+ }
117
+
118
+ $this->width_unit = $width_unit;
119
+
120
+ return true;
121
+ }
122
+
123
+ public function get_display_width() {
124
+ $value = false;
125
+
126
+ if ( $width = $this->get_width() ) {
127
+ $value = $width . $this->get_width_unit();
128
+ }
129
+
130
+ return $value;
131
+ }
132
+
133
+ }
classes/Settings/Column/WordLimit.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_WordLimit extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ private $excerpt_length;
14
+
15
+ protected function set_name() {
16
+ $this->name = 'word_limit';
17
+ }
18
+
19
+ protected function define_options() {
20
+ return array(
21
+ 'excerpt_length' => 20,
22
+ );
23
+ }
24
+
25
+ public function create_view() {
26
+ $setting = $this->create_element( 'number' )
27
+ ->set_attributes( array(
28
+ 'min' => 0,
29
+ 'step' => 1,
30
+ 'placeholder' => $this->get_default(),
31
+ ) );
32
+
33
+ $view = new AC_View( array(
34
+ 'label' => __( 'Word Limit', 'codepress-admin-columns' ),
35
+ 'tooltip' => __( 'Maximum number of words', 'codepress-admin-columns' ) . '<em>' . __( 'Leave empty for no limit', 'codepress-admin-columns' ) . '</em>',
36
+ 'setting' => $setting,
37
+ ) );
38
+
39
+ return $view;
40
+ }
41
+
42
+ /**
43
+ * @return int
44
+ */
45
+ public function get_excerpt_length() {
46
+ return $this->excerpt_length;
47
+ }
48
+
49
+ /**
50
+ * @param int $excerpt_length
51
+ *
52
+ * @return bool
53
+ */
54
+ public function set_excerpt_length( $excerpt_length ) {
55
+ $this->excerpt_length = $excerpt_length;
56
+
57
+ return true;
58
+ }
59
+
60
+ public function format( $value, $original_value ) {
61
+ $values = array();
62
+
63
+ foreach ( (array) $value as $_string ) {
64
+ $values[] = ac_helper()->string->trim_words( $_string, $this->get_excerpt_length() );
65
+ }
66
+
67
+ return ac_helper()->html->implode( $values );
68
+ }
69
+
70
+ }
classes/Settings/Column/WordsPerMinute.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Column_WordsPerMinute extends AC_Settings_Column
8
+ implements AC_Settings_FormatValueInterface {
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ private $words_per_minute;
14
+
15
+ protected function define_options() {
16
+ return array(
17
+ 'words_per_minute' => 200,
18
+ );
19
+ }
20
+
21
+ public function create_view() {
22
+ $setting = $this->create_element( 'number' );
23
+ $setting
24
+ ->set_attributes( array(
25
+ 'min' => 0,
26
+ 'step' => 1,
27
+ 'placeholder' => $this->get_words_per_minute(),
28
+ ) );
29
+
30
+ $view = new AC_View( array(
31
+ 'label' => __( 'Words per minute', 'codepress-admin-columns' ),
32
+ 'tooltip' => __( 'Estimated reading time in words per minute.', 'codepress-admin-columns' ) . ' ' . sprintf( __( 'By default: %s', 'codepress-admin-columns' ), $this->get_words_per_minute() ),
33
+ 'setting' => $setting,
34
+ ) );
35
+
36
+ return $view;
37
+ }
38
+
39
+ /**
40
+ * @return int
41
+ */
42
+ public function get_words_per_minute() {
43
+ return absint( $this->words_per_minute );
44
+ }
45
+
46
+ /**
47
+ * @param int $words_per_minute
48
+ *
49
+ * @return $this
50
+ */
51
+ public function set_words_per_minute( $words_per_minute ) {
52
+ $this->words_per_minute = $words_per_minute;
53
+
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Create a human readable time based on seconds
59
+ *
60
+ * @param int $seconds
61
+ *
62
+ * @since 3.0
63
+ * @return string
64
+ */
65
+ protected function make_human_readable( $seconds ) {
66
+ $time = false;
67
+
68
+ if ( is_numeric( $seconds ) ) {
69
+ $minutes = floor( $seconds / 60 );
70
+ $seconds = floor( $seconds % 60 );
71
+
72
+ $time = $minutes;
73
+
74
+ if ( $minutes && $seconds < 10 ) {
75
+ $seconds = '0' . $seconds;
76
+ }
77
+
78
+ if ( '00' != $seconds ) {
79
+ $time .= ':' . $seconds;
80
+ }
81
+
82
+ if ( $minutes < 1 ) {
83
+ $time = $seconds . ' ' . _n( 'second', 'seconds', $seconds, 'codepress-admin-columns' );
84
+ } else {
85
+ $time .= ' ' . _n( 'minute', 'minutes', $minutes, 'codepress-admin-columns' );
86
+ }
87
+ }
88
+
89
+ return $time;
90
+ }
91
+
92
+ /**
93
+ * Return the seconds required to read this string based on average words per minute
94
+ *
95
+ * @param string $content
96
+ *
97
+ * @return int
98
+ */
99
+ protected function get_estimated_reading_time_in_seconds( $string ) {
100
+ if ( $this->get_words_per_minute() <= 0 ) {
101
+ return false;
102
+ }
103
+
104
+ $word_count = ac_helper()->string->word_count( $string );
105
+
106
+ if ( ! $word_count ) {
107
+ return false;
108
+ }
109
+
110
+ $seconds = (int) floor( ( $word_count / $this->get_words_per_minute() ) * 60 );
111
+
112
+ // No one can read a word in 0 seconds ;)
113
+ if ( $seconds < 1 ) {
114
+ $seconds = 1;
115
+ }
116
+
117
+ return $seconds;
118
+ }
119
+
120
+ public function format( $value, $original_value ) {
121
+ return $this->make_human_readable( $this->get_estimated_reading_time_in_seconds( $value ) );
122
+ }
123
+
124
+ }
classes/Settings/Form/Element.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ abstract class AC_Settings_Form_Element {
8
+
9
+ /**
10
+ * @var array
11
+ */
12
+ protected $attributes = array();
13
+
14
+ /**
15
+ * Options for element like select
16
+ *
17
+ * @var array
18
+ */
19
+ protected $options = array();
20
+
21
+ /**
22
+ * The elements value
23
+ *
24
+ * @var mixed
25
+ */
26
+ protected $value;
27
+
28
+ /**
29
+ * Label
30
+ *
31
+ * @var string
32
+ */
33
+ protected $label;
34
+
35
+ /**
36
+ * Extra description
37
+ *
38
+ * @var string
39
+ */
40
+ protected $description;
41
+
42
+ /**
43
+ * Setup element with base name and id
44
+ *
45
+ * @param string $name
46
+ * @param array $options
47
+ */
48
+ public function __construct( $name, array $options = array() ) {
49
+ $this->set_name( $name );
50
+ $this->set_id( $name );
51
+ $this->set_options( $options );
52
+ }
53
+
54
+ /**
55
+ * @return string|false
56
+ */
57
+ protected function render_description() {
58
+ if ( ! $this->get_description() ) {
59
+ return false;
60
+ }
61
+
62
+ $template = '<p class="help-msg">%s</p>';
63
+
64
+ return sprintf( $template, $this->get_description() );
65
+ }
66
+
67
+ /**
68
+ * Render this element
69
+ *
70
+ * @return string
71
+ */
72
+ abstract public function render();
73
+
74
+ /**
75
+ * @param $key
76
+ *
77
+ * @return string|false
78
+ */
79
+ public function get_attribute( $key ) {
80
+ if ( ! isset( $this->attributes[ $key ] ) ) {
81
+ return false;
82
+ }
83
+
84
+ return trim( $this->attributes[ $key ] );
85
+ }
86
+
87
+ /**
88
+ * @param string $key
89
+ * @param string $value
90
+ *
91
+ * @return $this
92
+ */
93
+ public function set_attribute( $key, $value ) {
94
+ if ( 'value' === $key ) {
95
+ $this->set_value( $value );
96
+
97
+ return $this;
98
+ }
99
+
100
+ $this->attributes[ $key ] = $value;
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * @return array
107
+ */
108
+ public function get_attributes() {
109
+ return $this->attributes;
110
+ }
111
+
112
+ /**
113
+ * @param array $attributes
114
+ *
115
+ * @return $this
116
+ */
117
+ public function set_attributes( array $attributes ) {
118
+ foreach ( $attributes as $key => $value ) {
119
+ $this->set_attribute( $key, $value );
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Get attributes as string
127
+ *
128
+ * @param array $attributes
129
+ *
130
+ * @return string
131
+ */
132
+ protected function get_attributes_as_string( array $attributes ) {
133
+ $output = array();
134
+
135
+ foreach ( $attributes as $key => $value ) {
136
+ $output[] = $this->get_attribute_as_string( $key, $value );
137
+ }
138
+
139
+ return implode( ' ', $output );
140
+ }
141
+
142
+ /**
143
+ * Render an attribute
144
+ *
145
+ * @param string $key
146
+ * @param string $value
147
+ *
148
+ * @return string
149
+ */
150
+ protected function get_attribute_as_string( $key, $value = null ) {
151
+ if ( null === $value ) {
152
+ $value = $this->get_attribute( $key );
153
+ }
154
+
155
+ return ac_helper()->html->get_attribute_as_string( $key, $value );
156
+ }
157
+
158
+ public function get_name() {
159
+ return $this->get_attribute( 'name' );
160
+ }
161
+
162
+ /**
163
+ * @param string $name
164
+ *
165
+ * @return $this
166
+ */
167
+ public function set_name( $name ) {
168
+ return $this->set_attribute( 'name', $name );
169
+ }
170
+
171
+ /**
172
+ * @return false|string
173
+ */
174
+ public function get_id() {
175
+ return $this->get_attribute( 'id' );
176
+ }
177
+
178
+ /**
179
+ * @param string $id
180
+ *
181
+ * @return $this
182
+ */
183
+ public function set_id( $id ) {
184
+ return $this->set_attribute( 'id', $id );
185
+ }
186
+
187
+ /**
188
+ * @return mixed
189
+ */
190
+ public function get_value() {
191
+ return $this->value;
192
+ }
193
+
194
+ /**
195
+ * @param mixed $value
196
+ *
197
+ * @return $this
198
+ */
199
+ public function set_value( $value ) {
200
+ $this->value = $value;
201
+
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * @param string $class
207
+ *
208
+ * @return $this
209
+ */
210
+ public function set_class( $class ) {
211
+ $this->set_attribute( 'class', $class );
212
+
213
+ return $this;
214
+ }
215
+
216
+ /**
217
+ * @param string $class
218
+ *
219
+ * @return $this
220
+ */
221
+ public function add_class( $class ) {
222
+ $parts = explode( ' ', (string) $this->get_attribute( 'class' ) );
223
+ $parts[] = $class;
224
+
225
+ $this->set_class( implode( ' ', $parts ) );
226
+
227
+ return $this;
228
+ }
229
+
230
+ /**
231
+ * @return string
232
+ */
233
+ public function get_label() {
234
+ return $this->label;
235
+ }
236
+
237
+ /**
238
+ * @param string $label
239
+ *
240
+ * @return $this
241
+ */
242
+ public function set_label( $label ) {
243
+ $this->label = $label;
244
+
245
+ return $this;
246
+ }
247
+
248
+ /**
249
+ * @param array $options
250
+ *
251
+ * @return $this
252
+ */
253
+ public function set_options( array $options ) {
254
+ $this->options = $options;
255
+
256
+ return $this;
257
+ }
258
+
259
+ /**
260
+ * @return array
261
+ */
262
+ public function get_options() {
263
+ return $this->options;
264
+ }
265
+
266
+ /**
267
+ * @return string
268
+ */
269
+ public function get_description() {
270
+ return $this->description;
271
+ }
272
+
273
+ /**
274
+ * @return $this
275
+ */
276
+ public function set_description( $description ) {
277
+ $this->description = $description;
278
+
279
+ return $this;
280
+ }
281
+
282
+ /**
283
+ * @return string
284
+ */
285
+ public function __toString() {
286
+ return $this->render();
287
+ }
288
+
289
+ }
classes/Settings/Form/Element/Checkbox.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Form_Element_Checkbox extends AC_Settings_Form_Element {
8
+
9
+ /**
10
+ * @var bool
11
+ */
12
+ protected $vertical;
13
+
14
+ protected function get_type() {
15
+ return 'checkbox';
16
+ }
17
+
18
+ protected function get_classes() {
19
+ $classes = array(
20
+ $this->get_type() . '-labels',
21
+ );
22
+
23
+ if ( $this->is_vertical() ) {
24
+ $classes[] = 'vertical';
25
+ }
26
+
27
+ return $classes;
28
+ }
29
+
30
+ public function render() {
31
+ $elements = $this->get_elements();
32
+
33
+ if ( ! $elements ) {
34
+ return false;
35
+ }
36
+
37
+ $template = '<div class="%s-labels %s">%s</div>';
38
+
39
+ return sprintf( $template, $this->get_type(), implode( ' ', $this->get_classes() ), implode( "\n", $elements ) );
40
+ }
41
+
42
+ private function get_elements() {
43
+ $options = $this->get_options();
44
+
45
+ if ( empty( $options ) ) {
46
+ return null;
47
+ }
48
+
49
+ $elements = array();
50
+
51
+ $value = $this->get_value();
52
+
53
+ foreach ( $options as $key => $label ) {
54
+ $input = new AC_Settings_Form_Element_Input( $this->get_name() );
55
+
56
+ $input->set_value( $key )
57
+ ->set_type( $this->get_type() )
58
+ ->set_id( $this->get_id() . '-' . $key );
59
+
60
+ if ( checked( $key, $value, false ) ) {
61
+ $input->set_attribute( 'checked', 'checked' );
62
+ }
63
+
64
+ $attributes = $this->get_attributes();
65
+
66
+ $elements[] = sprintf( '<label %s>%s%s</label>', $this->get_attributes_as_string( $attributes ), $input->render(), esc_html( $label ) );
67
+ }
68
+
69
+ if ( $description = $this->render_description() ) {
70
+ $elements[] = $description;
71
+ }
72
+
73
+ return $elements;
74
+ }
75
+
76
+ public function set_vertical( $vertical ) {
77
+ $this->vertical = (bool) $vertical;
78
+ }
79
+
80
+ public function is_vertical() {
81
+ if ( empty( $this->vertical ) ) {
82
+ return false;
83
+ }
84
+
85
+ return $this->vertical;
86
+ }
87
+
88
+ }
classes/Settings/Form/Element/Input.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Form_Element_Input extends AC_Settings_Form_Element {
8
+
9
+ protected function is_valid_type( $type ) {
10
+ $valid_types = array(
11
+ 'hidden',
12
+ 'text',
13
+ 'number',
14
+ 'email',
15
+ 'radio',
16
+ 'checkbox',
17
+ );
18
+
19
+ return in_array( $type, $valid_types );
20
+ }
21
+
22
+ public function render() {
23
+ $template = '<input %s>%s';
24
+
25
+ $attributes = $this->get_attributes();
26
+ $attributes['name'] = $this->get_name();
27
+ $attributes['id'] = $this->get_id();
28
+ $attributes['value'] = $this->get_value();
29
+ $attributes['type'] = $this->get_type();
30
+
31
+ return sprintf( $template, $this->get_attributes_as_string( $attributes ), $this->render_description() );
32
+ }
33
+
34
+ public function get_type() {
35
+ $type = $this->get_attribute( 'type' );
36
+
37
+ if ( ! $type ) {
38
+ return 'text';
39
+ }
40
+
41
+ return strtolower( $type );
42
+ }
43
+
44
+ /**
45
+ * @param string $type
46
+ *
47
+ * @return $this
48
+ */
49
+ public function set_type( $type ) {
50
+ if ( $this->is_valid_type( $type ) ) {
51
+ $this->set_attribute( 'type', $type );
52
+ }
53
+
54
+ return $this;
55
+ }
56
+
57
+ }
classes/Settings/Form/Element/Radio.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Settings_Form_Element_Radio extends AC_Settings_Form_Element_Checkbox {
8
+
9
+ protected function get_type() {
10
+ return 'radio';
11
+ }
12
+
13
+ }
classes/Settings/Form/Element/Select.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ final class AC_Settings_Form_Element_Select extends AC_Settings_Form_Element {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $no_result = '';
13
+
14
+ protected function render_options( array $options ) {
15
+ $template = '<option %s>%s</option>';
16
+ $output = array();
17
+
18
+ foreach ( $options as $key => $option ) {
19
+ if ( isset( $option['options'] ) && is_array( $option['options'] ) ) {
20
+ $output[] = $this->render_optgroup( $option );
21
+
22
+ continue;
23
+ }
24
+
25
+ $attributes = array();
26
+ $attributes['value'] = $key;
27
+
28
+ if ( selected( $this->get_value(), $key, false ) ) {
29
+ $attributes['selected'] = 'selected';
30
+ }
31
+
32
+ $output[] = sprintf( $template, $this->get_attributes_as_string( $attributes ), esc_html( $option ) );
33
+ }
34
+
35
+ return implode( "\n", $output );
36
+ }
37
+
38
+ /**
39
+ * @param array $group
40
+ *
41
+ * @return string
42
+ */
43
+ protected function render_optgroup( array $group ) {
44
+ $template = '<optgroup %s>%s</optgroup>';
45
+ $attributes = array();
46
+
47
+ if ( isset( $group['title'] ) ) {
48
+ $attributes['label'] = esc_attr( $group['title'] );
49
+ }
50
+
51
+ return sprintf( $template, $this->get_attributes_as_string( $attributes ), $this->render_options( $group['options'] ) );
52
+ }
53
+
54
+ protected function render_ajax_message() {
55
+ return '<div class="msg"></div>';
56
+ }
57
+
58
+ public function render() {
59
+ if ( ! $this->get_options() ) {
60
+ return $this->get_no_result();
61
+ }
62
+
63
+ $template = '
64
+ <select %s>
65
+ %s
66
+ </select>
67
+ %s';
68
+
69
+ $attributes = $this->get_attributes();
70
+ $attributes['name'] = $this->get_name();
71
+ $attributes['id'] = $this->get_id();
72
+
73
+ return sprintf( $template, $this->get_attributes_as_string( $attributes ), $this->render_options( $this->get_options() ), $this->render_ajax_message() . $this->render_description() );
74
+ }
75
+
76
+ /**
77
+ * @return string
78
+ */
79
+ public function get_no_result() {
80
+ return $this->no_result;
81
+ }
82
+
83
+ /**
84
+ * @param string $no_result
85
+ *
86
+ * @return $this
87
+ */
88
+ public function set_no_result( $no_result ) {
89
+ $this->no_result = (string) $no_result;
90
+
91
+ return $this;
92
+ }
93
+
94
+ }
classes/Settings/FormatCollectionInterface.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ interface AC_Settings_FormatCollectionInterface {
8
+
9
+ /**
10
+ * @param AC_Collection $collection
11
+ * @param mixed $original_value
12
+ *
13
+ * @return mixed
14
+ */
15
+ public function format( AC_Collection $collection, $original_value );
16
+
17
+ }
classes/Settings/FormatValueInterface.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ interface AC_Settings_FormatValueInterface {
8
+
9
+ /**
10
+ * @param mixed $value
11
+ * @param mixed $original_value
12
+ *
13
+ * @return mixed
14
+ */
15
+ public function format( $value, $original_value );
16
+
17
+ }
classes/Settings/HeaderInterface.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ interface AC_Settings_HeaderInterface {
8
+
9
+ /**
10
+ * @return AC_View|false
11
+ */
12
+ public function create_header_view();
13
+
14
+ }
classes/TableScreen.php ADDED
@@ -0,0 +1,433 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ final class AC_TableScreen {
8
+
9
+ /**
10
+ * @var array $column_headings
11
+ */
12
+ private $column_headings = array();
13
+
14
+ /**
15
+ * @var AC_ListScreen $list_screen
16
+ */
17
+ private $current_list_screen;
18
+
19
+ public function __construct() {
20
+ add_action( 'current_screen', array( $this, 'load_list_screen' ) );
21
+ add_action( 'admin_init', array( $this, 'load_list_screen_doing_quick_edit' ) );
22
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
23
+ add_action( 'admin_footer', array( $this, 'admin_footer_scripts' ) );
24
+ add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
25
+ add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ), 20 );
26
+ add_action( 'wp_ajax_ac_get_column_value', array( $this, 'ajax_get_column_value' ) );
27
+ }
28
+
29
+ /**
30
+ * Get column value by ajax.
31
+ */
32
+ public function ajax_get_column_value() {
33
+ check_ajax_referer( 'ac-ajax' );
34
+
35
+ // Get ID of entry to edit
36
+ $id = intval( filter_input( INPUT_POST, 'pk' ) );
37
+
38
+ if ( ! $id ) {
39
+ $this->ajax_error( __( 'Invalid item ID.', 'codepress-admin-columns' ) );
40
+ }
41
+
42
+ $list_screen = AC()->get_list_screen( filter_input( INPUT_POST, 'list_screen' ) );
43
+
44
+ if ( ! $list_screen ) {
45
+ $this->ajax_error( __( 'Invalid list screen.', 'codepress-admin-columns' ) );
46
+ }
47
+
48
+ $list_screen->set_layout_id( filter_input( INPUT_POST, 'layout' ) );
49
+
50
+ $column = $list_screen->get_column_by_name( filter_input( INPUT_POST, 'column' ) );
51
+
52
+ if ( ! $column ) {
53
+ $this->ajax_error( __( 'Invalid column.', 'codepress-admin-columns' ) );
54
+ }
55
+
56
+ if ( ! $column instanceof AC_Column_AjaxValue ) {
57
+ $this->ajax_error( __( 'Invalid method.', 'codepress-admin-columns' ) );
58
+ }
59
+
60
+ // Trigger ajax callback
61
+ echo $column->get_ajax_value( $id );
62
+ exit;
63
+ }
64
+
65
+ private function ajax_error( $message ) {
66
+ wp_die( $message, null, 400 );
67
+ }
68
+
69
+ /**
70
+ * Set the primary columns for the Admin Columns columns. Used to place the actions bar.
71
+ *
72
+ * @since 2.5.5
73
+ */
74
+ public function set_primary_column( $default ) {
75
+ if ( $this->current_list_screen ) {
76
+
77
+ if ( ! $this->current_list_screen->get_column_by_name( $default ) ) {
78
+ $default = key( $this->current_list_screen->get_columns() );
79
+ }
80
+
81
+ // If actions column is present, set it as primary
82
+ foreach ( $this->current_list_screen->get_columns() as $column ) {
83
+ if ( 'column-actions' == $column->get_type() ) {
84
+ $default = $column->get_name();
85
+ }
86
+ };
87
+
88
+ // Set inline edit data if the default column (title) is not present
89
+ if ( $this->current_list_screen instanceof AC_ListScreen_Post && 'title' !== $default ) {
90
+ add_filter( 'page_row_actions', array( $this, 'set_inline_edit_data' ), 20, 2 );
91
+ add_filter( 'post_row_actions', array( $this, 'set_inline_edit_data' ), 20, 2 );
92
+ }
93
+
94
+ // Remove inline edit action if the default column (author) is not present
95
+ if ( $this->current_list_screen instanceof AC_ListScreen_Comment && 'comment' !== $default ) {
96
+ add_filter( 'comment_row_actions', array( $this, 'remove_quick_edit_from_actions' ), 20, 2 );
97
+ }
98
+
99
+ // Adds the default hidden bulk edit markup for the new primary column
100
+ if ( $this->current_list_screen instanceof ACP_ListScreen_Taxonomy && 'name' !== $default ) {
101
+ add_filter( 'tag_row_actions', array( $this, 'add_taxonomy_hidden_quick_edit_markup' ), 20, 2 );
102
+ }
103
+ }
104
+
105
+ return $default;
106
+ }
107
+
108
+ /**
109
+ * Sets the inline data when the title columns is not present on a AC_ListScreen_Post screen
110
+ *
111
+ * @param array $actions
112
+ * @param WP_Post $post
113
+ */
114
+ public function set_inline_edit_data( $actions, $post ) {
115
+ get_inline_data( $post );
116
+
117
+ return $actions;
118
+ }
119
+
120
+ /**
121
+ * Remove quick edit from actions
122
+ *
123
+ * @param array $actions
124
+ */
125
+ public function remove_quick_edit_from_actions( $actions ) {
126
+ unset( $actions['quickedit'] );
127
+
128
+ return $actions;
129
+ }
130
+
131
+ /**
132
+ * Add the default markup for the default primary column for the Taxonomy list screen which is necessary for bulk edit
133
+ *
134
+ * @param $actions
135
+ * @param $term
136
+ */
137
+ public function add_taxonomy_hidden_quick_edit_markup( $actions, $term ) {
138
+ $list_table = $this->get_current_list_screen()->get_list_table();
139
+
140
+ echo sprintf( '<div class="hidden">%s</div>', $list_table->column_name( $term ) );
141
+
142
+ return $actions;
143
+ }
144
+
145
+ /**
146
+ * Adds a body class which is used to set individual column widths
147
+ *
148
+ * @since 1.4.0
149
+ *
150
+ * @param string $classes body classes
151
+ *
152
+ * @return string
153
+ */
154
+ public function admin_class( $classes ) {
155
+ if ( ! $this->current_list_screen ) {
156
+ return $classes;
157
+ }
158
+
159
+ $classes .= " ac-" . $this->current_list_screen->get_key();
160
+
161
+ return apply_filters( 'ac/table/body_class', $classes, $this );
162
+ }
163
+
164
+ /**
165
+ * @since 2.2.4
166
+ *
167
+ * @param AC_ListScreen $list_screen
168
+ */
169
+ public function admin_scripts() {
170
+ if ( ! $this->current_list_screen ) {
171
+ return;
172
+ }
173
+
174
+ $list_screen = $this->current_list_screen;
175
+
176
+ // Tooltip
177
+ wp_register_script( 'jquery-qtip2', AC()->get_plugin_url() . "external/qtip2/jquery.qtip" . AC()->minified() . ".js", array( 'jquery' ), AC()->get_version() );
178
+ wp_enqueue_style( 'jquery-qtip2', AC()->get_plugin_url() . "external/qtip2/jquery.qtip" . AC()->minified() . ".css", array(), AC()->get_version() );
179
+
180
+ // Main
181
+ wp_enqueue_script( 'ac-table', AC()->get_plugin_url() . "assets/js/table" . AC()->minified() . ".js", array( 'jquery', 'jquery-qtip2' ), AC()->get_version() );
182
+ wp_enqueue_style( 'ac-table', AC()->get_plugin_url() . "assets/css/table" . AC()->minified() . ".css", array(), AC()->get_version() );
183
+
184
+ wp_localize_script( 'ac-table', 'AC', array(
185
+ 'list_screen' => $list_screen->get_key(),
186
+ 'layout' => $list_screen->get_layout_id(),
187
+ 'column_types' => $this->get_column_types_mapping( $list_screen ),
188
+ 'ajax_nonce' => wp_create_nonce( 'ac-ajax' ),
189
+ 'table_id' => $list_screen->get_table_attr_id(),
190
+ 'edit_link' => $this->get_edit_link( $list_screen ),
191
+ 'i18n' => array(
192
+ 'edit_columns' => esc_html( __( 'Edit columns', 'codepress-admin-columns' ) ),
193
+ ),
194
+ )
195
+ );
196
+
197
+ /**
198
+ * @param AC_ListScreen $list_screen
199
+ */
200
+ do_action( 'ac/table_scripts', $list_screen );
201
+
202
+ // Column specific scripts
203
+ foreach ( $list_screen->get_columns() as $column ) {
204
+ $column->scripts();
205
+ }
206
+ }
207
+
208
+ /**
209
+ * @param AC_ListScreen $list_screen
210
+ *
211
+ * @return array
212
+ */
213
+ private function get_column_types_mapping( AC_ListScreen $list_screen ) {
214
+ $types = array();
215
+ foreach ( $list_screen->get_columns() as $column ) {
216
+ $types[ $column->get_name() ] = $column->get_type();
217
+ }
218
+
219
+ return $types;
220
+ }
221
+
222
+ public function get_current_list_screen() {
223
+ return $this->current_list_screen;
224
+ }
225
+
226
+ /**
227
+ * Applies the width setting to the table headers
228
+ */
229
+ private function display_width_styles() {
230
+ if ( $this->current_list_screen->get_settings() ) {
231
+
232
+ // CSS: columns width
233
+ $css_column_width = false;
234
+
235
+ foreach ( $this->current_list_screen->get_columns() as $column ) {
236
+
237
+ /* @var AC_Settings_Column_Width $setting */
238
+ $setting = $column->get_setting( 'width' );
239
+
240
+ if ( $width = $setting->get_display_width() ) {
241
+ $css_column_width .= ".ac-" . $this->current_list_screen->get_key() . " .wrap table th.column-" . $column->get_name() . " { width: " . $width . " !important; }";
242
+ $css_column_width .= "body.acp-overflow-table.ac-" . $this->current_list_screen->get_key() . " .wrap th.column-" . $column->get_name() . " { min-width: " . $width . " !important; }";
243
+ }
244
+ }
245
+
246
+ if ( $css_column_width ) : ?>
247
+ <style>
248
+ <?php echo $css_column_width; ?>
249
+ </style>
250
+ <?php
251
+ endif;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * @param AC_ListScreen $list_screen
257
+ *
258
+ * @return string|false
259
+ */
260
+ private function get_edit_link( AC_ListScreen $list_screen ) {
261
+ if ( ! AC()->user_can_manage_admin_columns() ) {
262
+ return false;
263
+ }
264
+
265
+ /* @var AC_Admin_Page_Settings $settings */
266
+ $settings = AC()->admin()->get_page( 'settings' );
267
+
268
+ if ( ! $settings->show_edit_button() ) {
269
+ return false;
270
+ }
271
+
272
+ return $list_screen->get_edit_link();
273
+ }
274
+
275
+ /**
276
+ * Admin CSS for Column width and Settings Icon
277
+ *
278
+ * @since 1.4.0
279
+ */
280
+ public function admin_footer_scripts() {
281
+ if ( ! $this->current_list_screen ) {
282
+ return;
283
+ }
284
+
285
+ $this->display_width_styles();
286
+
287
+ /**
288
+ * Add header scripts that only apply to column screens.
289
+ * @since 2.3.5
290
+ *
291
+ * @param object CPAC Main Class
292
+ */
293
+ do_action( 'ac/admin_footer', $this->current_list_screen, $this );
294
+ }
295
+
296
+ /**
297
+ * Load current list screen
298
+ *
299
+ * @param WP_Screen $current_screen
300
+ */
301
+ public function load_list_screen( $current_screen ) {
302
+ if ( $list_screen = AC()->get_list_screen_by_wpscreen( $current_screen ) ) {
303
+ $this->set_current_list_screen( $list_screen );
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Runs when doing Quick Edit, a native WordPress ajax call
309
+ */
310
+ public function load_list_screen_doing_quick_edit() {
311
+ $this->set_current_list_screen( AC()->get_list_screen( $this->get_list_screen_when_doing_quick_edit() ) );
312
+ }
313
+
314
+ /**
315
+ * @param AC_ListScreen $list_screen
316
+ */
317
+ public function set_current_list_screen( $list_screen ) {
318
+ if ( ! $list_screen ) {
319
+ return;
320
+ }
321
+
322
+ $this->current_list_screen = $list_screen;
323
+
324
+ // Init Values
325
+ $list_screen->set_manage_value_callback();
326
+
327
+ /**
328
+ * Init Headings
329
+ * @see get_column_headers() for filter location
330
+ */
331
+ add_filter( "manage_" . $list_screen->get_screen_id() . "_columns", array( $this, 'add_headings' ), 200 );
332
+
333
+ // Stores the row actions for each table. Only used by the AC_Column_Actions column.
334
+ ac_action_column_helper();
335
+
336
+ /**
337
+ * @since 3.0
338
+ *
339
+ * @param AC_ListScreen
340
+ */
341
+ do_action( 'ac/table/list_screen', $list_screen );
342
+ }
343
+
344
+ /**
345
+ * Is WordPress doing ajax
346
+ *
347
+ * @since 2.5
348
+ * @return string List screen key
349
+ */
350
+ public function get_list_screen_when_doing_quick_edit() {
351
+ $list_screen = false;
352
+
353
+ if ( AC()->is_doing_ajax() ) {
354
+
355
+ switch ( filter_input( INPUT_POST, 'action' ) ) {
356
+
357
+ // Quick edit post
358
+ case 'inline-save' :
359
+ $list_screen = filter_input( INPUT_POST, 'post_type' );
360
+ break;
361
+
362
+ // Adding term & Quick edit term
363
+ case 'add-tag' :
364
+ case 'inline-save-tax' :
365
+ $list_screen = 'wp-taxonomy_' . filter_input( INPUT_POST, 'taxonomy' );
366
+ break;
367
+
368
+ // Quick edit comment & Inline reply on comment
369
+ case 'edit-comment' :
370
+ case 'replyto-comment' :
371
+ $list_screen = 'wp-comments';
372
+ break;
373
+ }
374
+ }
375
+
376
+ return $list_screen;
377
+ }
378
+
379
+ /**
380
+ * @since 2.0
381
+ */
382
+ public function add_headings( $columns ) {
383
+ if ( empty( $columns ) ) {
384
+ return $columns;
385
+ }
386
+
387
+ if ( ! $this->current_list_screen ) {
388
+ return $columns;
389
+ }
390
+
391
+ // On first visit when stored headings are empty, we force get_columns() to be re-populated
392
+ if ( ! $this->current_list_screen->get_stored_default_headings() ) {
393
+ $this->current_list_screen->reset();
394
+ $this->current_list_screen->set_original_columns( null );
395
+ }
396
+
397
+ // Store default headings
398
+ if ( ! AC()->is_doing_ajax() ) {
399
+ $this->current_list_screen->save_default_headings( $columns );
400
+ }
401
+
402
+ // Run once
403
+ if ( $this->column_headings ) {
404
+ return $this->column_headings;
405
+ }
406
+
407
+ // Nothing stored. Show default columns on screen.
408
+ if ( ! $this->current_list_screen->get_settings() ) {
409
+ return $columns;
410
+ }
411
+
412
+ // Add mandatory checkbox
413
+ if ( isset( $columns['cb'] ) ) {
414
+ $this->column_headings['cb'] = $columns['cb'];
415
+ }
416
+
417
+ foreach ( $this->current_list_screen->get_columns() as $column ) {
418
+
419
+ /**
420
+ * @since 3.0
421
+ *
422
+ * @param string $label
423
+ * @param AC_Column $column
424
+ */
425
+ $label = apply_filters( 'ac/headings/label', $column->get_setting( 'label' )->get_value(), $column );
426
+
427
+ $this->column_headings[ $column->get_name() ] = $label;
428
+ }
429
+
430
+ return apply_filters( 'ac/headings', $this->column_headings, $this->current_list_screen );
431
+ }
432
+
433
+ }
classes/ThirdParty/ACF.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ThirdParty_ACF {
8
+
9
+ public function __construct() {
10
+ add_filter( 'ac/post_types', array( $this, 'remove_acf_field_group' ) );
11
+ }
12
+
13
+ /**
14
+ * Fix which remove the Advanced Custom Fields Type (acf) from the admin columns settings page
15
+ *
16
+ * @since 2.0
17
+ *
18
+ * @return array Post Types
19
+ */
20
+ function remove_acf_field_group( $post_types ) {
21
+ if ( class_exists( 'Acf', false ) ) {
22
+ if ( isset( $post_types['acf'] ) ) {
23
+ unset( $post_types['acf'] );
24
+ }
25
+ if ( isset( $post_types['acf-field-group'] ) ) {
26
+ unset( $post_types['acf-field-group'] );
27
+ }
28
+ }
29
+
30
+ return $post_types;
31
+ }
32
+
33
+ }
classes/ThirdParty/NinjaForms.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ThirdParty_NinjaForms {
8
+
9
+ public function __construct() {
10
+ add_filter( 'ac/post_types', array( $this, 'remove_nf_sub' ) );
11
+ }
12
+
13
+ public function remove_nf_sub( $post_types ) {
14
+ if ( class_exists( 'Ninja_Forms', false ) ) {
15
+ if ( isset( $post_types['nf_sub'] ) ) {
16
+ unset( $post_types['nf_sub'] );
17
+ }
18
+ }
19
+
20
+ return $post_types;
21
+ }
22
+
23
+ }
classes/ThirdParty/WPML.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * WPML compatibility
9
+ */
10
+ class AC_ThirdParty_WPML {
11
+
12
+ function __construct() {
13
+
14
+ // display correct flags on the overview screens
15
+ add_action( 'ac/table/list_screen', array( $this, 'replace_flags' ) );
16
+
17
+ // enable the translation of the column labels
18
+ add_action( 'wp_loaded', array( $this, 'register_column_labels' ), 99 );
19
+
20
+ // enable the WPML translation of column headings
21
+ add_filter( 'ac/headings/label', array( $this, 'register_translated_label' ), 100 );
22
+ }
23
+
24
+ public function replace_flags( $list_screen ) {
25
+ if ( ! class_exists( 'SitePress', false ) ) {
26
+ return;
27
+ }
28
+
29
+ $settings = get_option( 'icl_sitepress_settings' );
30
+
31
+ if ( ! isset( $settings['custom_posts_sync_option'] ) ) {
32
+ return;
33
+ }
34
+ $post_types = (array) $settings['custom_posts_sync_option'];
35
+ $post_types['post'] = 1;
36
+ $post_types['page'] = 1;
37
+ foreach ( $post_types as $post_type => $value ) {
38
+ if ( $value ) {
39
+ new AC_ThirdParty_WPMLColumn( $post_type );
40
+ }
41
+ }
42
+ }
43
+
44
+ // Create translatable column labels
45
+ public function register_column_labels() {
46
+ // don't load this unless required by WPML
47
+ if ( ! isset( $_GET['page'] ) || 'wpml-string-translation/menu/string-translation.php' !== $_GET['page'] ) {
48
+ return;
49
+ }
50
+
51
+ foreach ( AC()->get_list_screens() as $list_screen ) {
52
+ foreach ( $list_screen->get_settings() as $column_name => $options ) {
53
+ do_action( 'wpml_register_single_string', 'Admin Columns', $options['label'], $options['label'] );
54
+ }
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @param string $label
60
+ * @param AC_Column $column
61
+ *
62
+ * @return string
63
+ */
64
+ public function register_translated_label( $label ) {
65
+ if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
66
+ $label = apply_filters( 'wpml_translate_single_string', $label, 'Admin Columns', $label, ICL_LANGUAGE_CODE );
67
+ }
68
+
69
+ return $label;
70
+ }
71
+
72
+ }
classes/ThirdParty/WPMLColumn.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * WPML: display correct flags on the overview screens
9
+ */
10
+ class AC_ThirdParty_WPMLColumn {
11
+
12
+ const COLUMN_NAME = 'icl_translations';
13
+
14
+ private $column;
15
+
16
+ function __construct( $post_type ) {
17
+ add_filter( "manage_{$post_type}_posts_columns", array( $this, 'store_wpml_column' ), 11 ); // priority just after WPML set's it's column
18
+ add_filter( "manage_edit-{$post_type}_columns", array( $this, 'replace_wpml_column' ), 201 ); // priority just after AC overwrite all columns
19
+ }
20
+
21
+ public function store_wpml_column( $columns ) {
22
+ if ( empty( $this->column ) && isset( $columns[ self::COLUMN_NAME ] ) ) {
23
+ $this->column = $columns[ self::COLUMN_NAME ];
24
+ }
25
+
26
+ return $columns;
27
+ }
28
+
29
+ public function replace_wpml_column( $columns ) {
30
+ if ( $this->column && isset( $columns[ self::COLUMN_NAME ] ) ) {
31
+ $columns[ self::COLUMN_NAME ] = $this->column;
32
+ }
33
+
34
+ return $columns;
35
+ }
36
+ }
classes/ThirdParty/WooCommerce.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_ThirdParty_WooCommerce {
8
+
9
+ public function __construct() {
10
+ add_filter( 'ac/post_types', array( $this, 'remove_webhook' ) );
11
+ }
12
+
13
+ public function remove_webhook( $post_types ) {
14
+ if ( class_exists( 'WooCommerce', false ) ) {
15
+ if ( isset( $post_types['shop_webhook'] ) ) {
16
+ unset( $post_types['shop_webhook'] );
17
+ }
18
+ }
19
+
20
+ return $post_types;
21
+ }
22
+
23
+ }
classes/View.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_View
8
+ implements AC_ViewInterface {
9
+
10
+ /**
11
+ * @var array
12
+ */
13
+ private $data = array();
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $template;
19
+
20
+ public function __construct( array $data = array() ) {
21
+ $this->set_data( $data );
22
+ }
23
+
24
+ public function get( $key ) {
25
+ if ( ! isset( $this->data[ $key ] ) ) {
26
+ return null;
27
+ }
28
+
29
+ return $this->data[ $key ];
30
+ }
31
+
32
+ public function __get( $key ) {
33
+ return $this->get( $key );
34
+ }
35
+
36
+ public function __set( $key, $value ) {
37
+ return $this->set( $key, $value );
38
+ }
39
+
40
+ /**
41
+ * @param $key
42
+ * @param $value
43
+ *
44
+ * @return $this
45
+ */
46
+ public function set( $key, $value ) {
47
+ $this->data[ $key ] = $value;
48
+
49
+ return $this;
50
+ }
51
+
52
+ public function get_data() {
53
+ return $this->data;
54
+ }
55
+
56
+ public function set_data( array $data ) {
57
+ foreach ( $data as $key => $value ) {
58
+ $this->set( $key, $value );
59
+ }
60
+
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Will try to resolve the current template to a file
66
+ *
67
+ * @return false|string
68
+ */
69
+ private function resolve_template() {
70
+
71
+ /**
72
+ * Returns the available template paths for column settings
73
+ *
74
+ * @param array $paths Template paths
75
+ * @param string $template Current template path
76
+ */
77
+ $paths = apply_filters( 'ac/view/templates', array( AC()->get_plugin_dir() . 'templates' ), $this->template );
78
+
79
+ foreach ( $paths as $path ) {
80
+ $file = $path . '/' . $this->template . '.php';
81
+
82
+ if ( is_readable( $file ) ) {
83
+ include $file;
84
+
85
+ return true;
86
+ }
87
+ }
88
+
89
+ return false;
90
+ }
91
+
92
+ public function render() {
93
+ ob_start();
94
+
95
+ $this->resolve_template();
96
+
97
+ return ob_get_clean();
98
+ }
99
+
100
+ /**
101
+ * @return string
102
+ */
103
+ public function get_template() {
104
+ return $this->template;
105
+ }
106
+
107
+ /**
108
+ * @param string $template
109
+ *
110
+ * @return $this
111
+ */
112
+ public function set_template( $template ) {
113
+ $this->template = $template;
114
+
115
+ return $this;
116
+ }
117
+
118
+ public function __toString() {
119
+ return $this->render();
120
+ }
121
+
122
+ }
classes/ViewInterface.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ interface AC_ViewInterface {
8
+
9
+ /**
10
+ * Get a string representation of this object
11
+ *
12
+ * @return string
13
+ */
14
+ public function render();
15
+
16
+ /**
17
+ * Should call self::render when treated as a string
18
+ *
19
+ * @return string
20
+ */
21
+ public function __toString();
22
+
23
+ }
classes/addons.php DELETED
@@ -1,416 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Addons {
4
-
5
- /**
6
- * CPAC class
7
- *
8
- * @since 2.2
9
- */
10
- private $cpac;
11
-
12
- /**
13
- * User meta key for hiding "Install addons" notice
14
- *
15
- * @since 2.4.9
16
- */
17
- const OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY = 'cpac-hide-install-addons-notice';
18
-
19
- /**
20
- * @since 2.2
21
- *
22
- * @param CPAC
23
- */
24
- function __construct( $cpac ) {
25
-
26
- $this->cpac = $cpac;
27
-
28
- // Redirect to addons settings tab on activation & deactivation
29
- if ( is_admin() ) {
30
- add_filter( 'wp_redirect', array( $this, 'addon_plugin_statuschange_redirect' ) );
31
- }
32
-
33
- // Handle install request
34
- add_action( 'admin_init', array( $this, 'handle_install_request' ) );
35
- add_action( 'admin_notices', array( $this, 'missing_addon_notices' ) );
36
- add_action( 'wp_ajax_cpac_hide_install_addons_notice', array( $this, 'ajax_hide_install_addons_notice' ) );
37
- }
38
-
39
- /**
40
- * Possibly adds an admin notice when a third party plugin supported by an addon is installed, but the addon isn't
41
- *
42
- * @since 2.4.9
43
- */
44
- public function missing_addon_notices() {
45
-
46
- if ( cpac()->suppress_site_wide_notices() ) {
47
- return;
48
- }
49
-
50
- if ( get_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY, true ) ) {
51
- return;
52
- }
53
-
54
- $plugins = array();
55
-
56
- if ( $this->cpac->is_plugin_acf_active() && ! class_exists( 'CPAC_Addon_ACF' ) ) {
57
- $plugins[] = __( 'Advanced Custom Fields', 'codepress-admin-columns' );
58
- }
59
-
60
- if ( $this->cpac->is_plugin_woocommerce_active() && ! class_exists( 'CPAC_Addon_WC' ) ) {
61
- $plugins[] = __( 'WooCommerce', 'codepress-admin-columns' );
62
- }
63
-
64
- if ( $plugins ) {
65
- $num_plugins = count( $plugins );
66
-
67
- foreach ( $plugins as $index => $plugin ) {
68
- $plugins[ $index ] = '<strong>' . $plugin . '</strong>';
69
- }
70
-
71
- $plugins_list = $plugins[0];
72
-
73
- if ( $num_plugins > 1 ) {
74
- if ( $num_plugins > 2 ) {
75
- $plugins_list = implode( ', ', array_slice( $plugins, 0, $num_plugins - 1 ) );
76
- $plugins = array( $plugins_list, $plugins[ $num_plugins - 1 ] );
77
- }
78
-
79
- $plugins_list = sprintf( __( '%s and %s', 'codepress-admin-columns' ), $plugins[0], $plugins[1] );
80
- }
81
- ?>
82
- <div class="cpac_message updated">
83
- <a href="#" class="hide-notice hide-install-addons-notice"></a>
84
- <p><?php printf(
85
- __( "Did you know Admin Columns Pro has an integration addon for %s? With the proper Admin Columns Pro license, you can download them from %s!", 'codepress-admin-columns' ),
86
- $plugins_list,
87
- '<a href="' . $this->cpac->settings()->get_settings_url( 'addons' ) . '">' . __( 'the addons page', 'codepress-admin-columns' ) . '</a>'
88
- ); ?>
89
- </div>
90
- <style type="text/css">
91
- body .wrap .cpac_message {
92
- position: relative;
93
- padding-right: 40px;
94
- }
95
- .cpac_message .spinner.right {
96
- visibility: visible;
97
- display: block;
98
- right: 8px;
99
- text-decoration: none;
100
- text-align: right;
101
- position: absolute;
102
- top: 50%;
103
- margin-top: -10px;
104
- }
105
- .cpac_message .hide-notice {
106
- right: 8px;
107
- text-decoration: none;
108
- width: 32px;
109
- text-align: right;
110
- position: absolute;
111
- top: 50%;
112
- height: 32px;
113
- margin-top: -16px;
114
- }
115
- .cpac_message .hide-notice:before {
116
- display: block;
117
- content: '\f335';
118
- font-family: 'Dashicons';
119
- margin: .5em 0;
120
- padding: 2px;
121
- }
122
- </style>
123
- <script type="text/javascript">
124
- jQuery( function( $ ) {
125
- $( document ).ready( function() {
126
- $( '.updated a.hide-install-addons-notice' ).click( function( e ) {
127
- e.preventDefault();
128
-
129
- var el = $( this ).parents( '.cpac_message' );
130
- var el_close = el.find( '.hide-notice' );
131
-
132
- el_close.hide();
133
- el_close.after( '<div class="spinner right"></div>' );
134
- el.find( '.spinner' ).show();
135
-
136
- $.post( ajaxurl, {
137
- 'action': 'cpac_hide_install_addons_notice'
138
- }, function( data ) {
139
- el.find( '.spinner' ).remove();
140
- el.slideUp();
141
- } );
142
-
143
- return false;
144
- } );
145
- } );
146
- } );
147
- </script>
148
- <?php
149
- }
150
- }
151
-
152
- /**
153
- * Ajax callback for hiding the "Missing addons" notice used for notifying users of available integration addons for plugins they have installed
154
- *
155
- * @since 2.4.9
156
- */
157
- public function ajax_hide_install_addons_notice() {
158
-
159
- update_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_INSTALL_ADDONS_KEY, '1', true );
160
- }
161
-
162
- /**
163
- * Handles the installation of the add-on
164
- *
165
- * @since 2.2
166
- */
167
- public function handle_install_request() {
168
-
169
- if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'install-cac-addon' ) || ! isset( $_GET['plugin'] ) ) {
170
- return;
171
- }
172
-
173
- if ( ! $this->get_addon( $_GET['plugin'] ) ) {
174
- cpac_admin_message( __( 'Addon does not exist.', 'codepress-admin-columns' ), 'error' );
175
-
176
- return;
177
- }
178
-
179
- if ( ! class_exists( 'CAC_Addon_Pro', false ) ) {
180
- cpac_admin_message( __( 'You need Admin Columns Pro.', 'codepress-admin-columns' ), 'error' );
181
-
182
- return;
183
- }
184
-
185
- // Hook: trigger possible warning message before running WP installer ( api errors etc. )
186
- if ( $error = apply_filters( 'cac/addons/install_request/maybe_error', false, $_GET['plugin'] ) ) {
187
- cpac_admin_message( $error, 'error' );
188
-
189
- return;
190
- }
191
-
192
- $install_url = add_query_arg( array(
193
- 'action' => 'install-plugin',
194
- 'plugin' => $_GET['plugin'],
195
- 'cpac-redirect' => true
196
- ), wp_nonce_url( network_admin_url( 'update.php' ), 'install-plugin_' . $_GET['plugin'] ) );
197
-
198
- wp_redirect( $install_url );
199
- exit;
200
- }
201
-
202
- /**
203
- * Redirect the user to the Admin Columns add-ons page after activation/deactivation of an add-on from the add-ons page
204
- *
205
- * @since 2.2
206
- *
207
- * @see filter:wp_redirect
208
- */
209
- public function addon_plugin_statuschange_redirect( $location ) {
210
-
211
- if ( ! isset( $_GET['cpac-redirect'] ) ) {
212
- return $location;
213
- }
214
-
215
- $urlparts = parse_url( $location );
216
-
217
- if ( ! $urlparts ) {
218
- return $location;
219
- }
220
-
221
- if ( ! empty( $urlparts['query'] ) ) {
222
- $admin_url = $urlparts['scheme'] . '://' . $urlparts['host'] . $urlparts['path'];
223
-
224
- // activate or deactivae plugin
225
- if ( admin_url( 'plugins.php' ) == $admin_url ) {
226
- parse_str( $urlparts['query'], $request );
227
-
228
- if ( empty( $request['error'] ) ) {
229
- $location = add_query_arg( empty( $request['activate'] ) ? 'deactivate' : 'activate', true, $this->cpac->settings()->get_settings_url( 'addons' ) );
230
- }
231
- }
232
- }
233
-
234
- return $location;
235
- }
236
-
237
- /**
238
- * Addons are grouped into addon groups by providing the group an addon belongs to (see CPAC_Addons::get_available_addons()).
239
- *
240
- * @since 2.2
241
- *
242
- * @return array Available addon groups ([group_name] => [label])
243
- */
244
- public function get_addon_groups() {
245
-
246
- $addon_groups = array(
247
- 'integration' => __( 'Plugins', 'codepress-admin-columns' )
248
- );
249
-
250
- /**
251
- * Filter the addon groups
252
- *
253
- * @since 2.2
254
- *
255
- * @param array $addon_groups Available addon groups ([group_name] => [label])
256
- */
257
- $addon_groups = apply_filters( 'cpac/addons/addon_groups', $addon_groups );
258
-
259
- return $addon_groups;
260
- }
261
-
262
- /**
263
- * @since 2.2
264
- *
265
- * @param bool $grouped Whether to group the plugins by addon group ()
266
- *
267
- * @return array Available addons ([addon_basename] => (array) [addon_details] if not grouped, a list of these key-value pairs per group otherwise ([group_name] => (array) [group_addons]))
268
- */
269
- public function get_available_addons( $grouped = false ) {
270
-
271
- $addons = array(
272
- 'cac-addon-acf' => array(
273
- 'title' => __( 'Advanced Custom Fields', 'codepress-admin-columns' ),
274
- 'description' => __( 'Display and edit Advanced Custom Fields fields in the posts overview in seconds!', 'codepress-admin-columns' ),
275
- 'group' => 'integration',
276
- 'image' => CPAC_URL . 'assets/images/addons/acf.png'
277
- ),
278
- 'cac-addon-woocommerce' => array(
279
- 'title' => __( 'WooCommerce', 'codepress-admin-columns' ),
280
- 'description' => __( 'Enhance the products, orders and coupons overviews with new columns and inline editing.', 'codepress-admin-columns' ),
281
- 'group' => 'integration',
282
- 'image' => CPAC_URL . 'assets/images/addons/woocommerce.png'
283
- )
284
- );
285
-
286
- /**
287
- * Filter the available addons
288
- *
289
- * @since 2.2
290
- *
291
- * @param array $addons Available addons ([addon_name] => (array) [addon_details])
292
- */
293
- $addons = apply_filters( 'cpac/addons/available_addons', $addons );
294
-
295
- foreach ( $addons as $addon_name => $addon ) {
296
- $addons[ $addon_name ] = wp_parse_args( $addon, array(
297
- 'title' => '',
298
- 'group' => '',
299
- 'image' => ''
300
- ) );
301
- }
302
-
303
- // Maybe group add-ons
304
- if ( $grouped ) {
305
- $addons = $this->group_addons( $addons );
306
- }
307
-
308
- return $addons;
309
- }
310
-
311
- /**
312
- * Get add-on details from the available add-ons list
313
- *
314
- * @since 2.2
315
- *
316
- * @param string $id Unique addon ID
317
- *
318
- * @return bool|array Returns addon details if the add-on exists, false otherwise
319
- */
320
- public function get_addon( $id ) {
321
-
322
- $addons = $this->get_available_addons();
323
-
324
- if ( isset( $addons[ $id ] ) ) {
325
- return $addons[ $id ];
326
- }
327
-
328
- return false;
329
- }
330
-
331
- /**
332
- * Group a list of add-ons
333
- *
334
- * @since 2.2
335
- * @uses CPAC_Addons::group_addons()
336
- *
337
- * @param array $addons List of addons ([addon_name] => (array) [addon_details])
338
- *
339
- * @return array A list of addons per group: [group_name] => (array) [group_addons], where [group_addons] is an array ([addon_name] => (array) [addon_details])
340
- */
341
- public function group_addons( $addons ) {
342
-
343
- $groups = $this->get_addon_groups();
344
- $grouped_addons = array();
345
-
346
- foreach ( $addons as $addon_name => $addon ) {
347
- if ( ! isset( $groups[ $addon['group'] ] ) ) {
348
- continue;
349
- }
350
-
351
- if ( ! isset( $grouped_addons[ $addon['group'] ] ) ) {
352
- $grouped_addons[ $addon['group'] ] = array();
353
- }
354
-
355
- $grouped_addons[ $addon['group'] ][ $addon_name ] = $addon;
356
- }
357
-
358
- return $grouped_addons;
359
- }
360
-
361
- /**
362
- * Get whether an add-on is installed (i.e. the plugin is available in the plugin directory)
363
- *
364
- * @since 2.2
365
- *
366
- * @param string $slug Plugin dirname/slug
367
- *
368
- * @return bool Returns true if there is no add-on installed with the passed ID, false otherwise
369
- */
370
- public function is_addon_installed( $slug ) {
371
-
372
- return $this->get_installed_addon_plugin_basename( $slug ) ? true : false;
373
- }
374
-
375
- /**
376
- * Get the plugin basename (see plugin_basename()) from a plugin, for example "my-plugin/my-plugin.php"
377
- *
378
- * @since 2.2
379
- *
380
- * @param string $slug Plugin dirname/slug
381
- *
382
- * @return string|bool Returns the plugin basename if the plugin is installed, false otherwise
383
- */
384
- public function get_installed_addon_plugin_basename( $slug ) {
385
-
386
- $plugins = get_plugins();
387
-
388
- foreach ( $plugins as $plugin_basename => $plugin ) {
389
- if ( $slug == dirname( $plugin_basename ) ) {
390
- return $plugin_basename;
391
- }
392
- }
393
-
394
- return false;
395
- }
396
-
397
- /**
398
- * @since 2.2
399
- *
400
- * @param string $slug Plugin dirname/slug
401
- *
402
- * @return string|bool Returns the plugin version if the plugin is installed, false otherwise
403
- */
404
- public function get_installed_addon_plugin_version( $slug ) {
405
-
406
- $plugins = get_plugins();
407
-
408
- foreach ( $plugins as $plugin_basename => $plugin ) {
409
- if ( $slug == dirname( $plugin_basename ) ) {
410
- return $plugin['Version'];
411
- }
412
- }
413
-
414
- return false;
415
- }
416
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column.php DELETED
@@ -1,1661 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column class
5
- *
6
- * @since 2.0
7
- *
8
- * @param object $storage_model CPAC_Storage_Model
9
- */
10
- class CPAC_Column {
11
-
12
- /**
13
- * A Storage Model can be a Posttype, User, Comment, Link or Media storage type.
14
- *
15
- * @since 2.0
16
- * @var CPAC_Storage_Model $storage_model contains a CPAC_Storage_Model object which the column belongs too.
17
- */
18
- private $storage_model;
19
-
20
- /**
21
- * @since 2.0
22
- * @var array $options contains the user set options for the CPAC_Column object.
23
- */
24
- public $options = array();
25
-
26
- /**
27
- * @since 2.0
28
- * @var array $properties describes the fixed properties for the CPAC_Column object.
29
- */
30
- public $properties = array();
31
-
32
- /**
33
- * @since 2.4.7
34
- */
35
- protected $filtering_model;
36
-
37
- /**
38
- * @since 2.4.8
39
- */
40
- protected $editable_model;
41
-
42
- /**
43
- * @since 2.0
44
- *
45
- * @param int $id ID
46
- *
47
- * @return string Value
48
- */
49
- public function get_value( $id ) {
50
- }
51
-
52
- /**
53
- * Get the raw, underlying value for the column
54
- * Not suitable for direct display, use get_value() for that
55
- *
56
- * @since 2.0.3
57
- *
58
- * @param int $id ID
59
- *
60
- * @return mixed Value
61
- */
62
- public function get_raw_value( $id ) {
63
- }
64
-
65
- /**
66
- * @since 2.0
67
- */
68
- protected function display_settings() {
69
- }
70
-
71
- /**
72
- * Overwrite this function in child class to sanitize
73
- * user submitted values.
74
- *
75
- * @since 2.0
76
- *
77
- * @param $options array User submitted column options
78
- *
79
- * @return array Options
80
- */
81
- protected function sanitize_options( $options ) {
82
-
83
- if ( isset( $options['date_format'] ) ) {
84
- $options['date_format'] = trim( $options['date_format'] );
85
- }
86
-
87
- if ( isset( $options['width'] ) ) {
88
- $options['width'] = trim( $options['width'] );
89
- if ( ! is_numeric( $options['width'] ) ) {
90
- $options['width'] = '';
91
- }
92
- }
93
-
94
- return $options;
95
- }
96
-
97
- /**
98
- * Overwrite this function in child class.
99
- * Determine whether this column type should be available
100
- *
101
- * @since 2.2
102
- *
103
- * @return bool Whether the column type should be available
104
- */
105
- public function apply_conditional() {
106
- return true;
107
- }
108
-
109
- public function is_default() {
110
- return isset( $this->properties->default ) && $this->properties->default;
111
- }
112
-
113
- public function is_original() {
114
- return isset( $this->properties->original ) && $this->properties->original;
115
- }
116
-
117
- /**
118
- * Overwrite this function in child class.
119
- * Adds (optional) scripts to the listings screen.
120
- *
121
- * @since 2.3.4
122
- */
123
- public function scripts() {
124
- }
125
-
126
- /**
127
- * An object copy (clone) is created for creating multiple column instances.
128
- *
129
- * @since 2.0
130
- */
131
- public function __clone() {
132
-
133
- // Force a copy of this->object, otherwise it will point to same object.
134
- $this->options = clone $this->options;
135
- $this->properties = clone $this->properties;
136
- }
137
-
138
- /**
139
- * @since 2.5
140
- */
141
- public function __get( $key ) {
142
- if ( 'storage_model' == $key ) {
143
- return $this->{"get_$key"}();
144
- }
145
- }
146
-
147
- /**
148
- * @since 2.0
149
- *
150
- * @param object $storage_model CPAC_Storage_Model
151
- */
152
- public function __construct( $storage_model ) {
153
-
154
- $this->storage_model = $storage_model;
155
-
156
- $this->init();
157
- $this->after_setup();
158
- }
159
-
160
- /**
161
- * @since 2.2
162
- */
163
- public function init() {
164
-
165
- // Default properties
166
- $default_properties = array(
167
- 'clone' => null, // Unique clone ID
168
- 'type' => null, // Unique type
169
- 'name' => null, // Unique name
170
- 'label' => null, // Label which describes this column.
171
- 'classes' => null, // Custom CSS classes for this column.
172
- 'hide_label' => false, // Should the Label be hidden?
173
- 'is_registered' => true, // Should the column be registered based on conditional logic, example usage see: 'post/page-template.php'
174
- 'is_cloneable' => true, // Should the column be cloneable
175
- 'default' => false, // Is this a WP default column, used for displaying values
176
- 'original' => false, // When a default column has been replaced by custom column we mark it as 'original'
177
- 'use_before_after' => false, // Should the column use before and after fields
178
- 'group' => __( 'Custom', 'codepress-admin-columns' ) // Group name
179
- );
180
-
181
- // @since 2.4.7
182
- $default_properties = apply_filters( 'cac/column/default_properties', $default_properties );
183
-
184
- foreach ( $default_properties as $property => $value ) {
185
- $this->properties[ $property ] = $value;
186
- }
187
-
188
- // Default options
189
- $default_options = array(
190
- 'before' => '', // Before field
191
- 'after' => '', // After field
192
- 'width' => null, // Width for this column.
193
- 'width_unit' => '%', // Unit for width; percentage (%) or pixels (px).
194
- 'state' => 'off' // Active state for this column.
195
- );
196
-
197
- /**
198
- * Filter the default options for a column instance, such as label and width
199
- *
200
- * @since 2.2
201
- *
202
- * @param array $default_options Default column options
203
- * @param CPAC_Storage_Model $storage_model Storage Model class instance
204
- */
205
- $default_options = apply_filters( 'cac/column/default_options', $default_options ); // do not pass $this because object is not ready
206
-
207
- foreach ( $default_options as $option => $value ) {
208
- $this->options[ $option ] = $value;
209
- }
210
- }
211
-
212
- /**
213
- * After Setup
214
- *
215
- */
216
- public function after_setup() {
217
-
218
- // Column name defaults to column type
219
- if ( ! isset( $this->properties['name'] ) ) {
220
- $this->properties['name'] = $this->properties['type'];
221
- }
222
-
223
- // Check whether the column should be available
224
- $this->properties['is_registered'] = $this->apply_conditional();
225
-
226
- /**
227
- * Filter the properties of a column type, such as type and is_cloneable
228
- * Property $column_instance added in Admin Columns 2.2
229
- *
230
- * @since 2.0
231
- *
232
- * @param array $properties Column properties
233
- * @param CPAC_Storage_Model $storage_model Storage Model class instance
234
- */
235
- $this->properties = apply_filters( 'cac/column/properties', $this->properties, $this ); // do not pass $this because object is not ready
236
-
237
- /**
238
- * Filter the properties of a column type for a specific storage model
239
- * Property $column_instance added in Admin Columns 2.2
240
- *
241
- * @since 2.0
242
- * @see Filter cac/column/properties
243
- */
244
- $this->properties = apply_filters( "cac/column/properties/storage_key={$this->get_storage_model()->key}", $this->properties, $this ); // do not pass $this because object is not ready
245
-
246
- // Column label defaults to column type label
247
- if ( ! isset( $this->options['label'] ) ) {
248
- $this->options['label'] = $this->properties['label'];
249
- }
250
-
251
- // Convert properties and options arrays to object
252
- $this->options = (object) $this->options;
253
- $this->properties = (object) $this->properties;
254
-
255
- // Filters
256
- foreach ( $this->properties as $name => $value ) {
257
- $this->properties->{$name} = apply_filters( "cac/column/properties/{$name}", $value, $this );
258
- }
259
- }
260
-
261
- /**
262
- * @param string $property
263
- *
264
- * @return mixed $value
265
- */
266
- public function set_properties( $property, $value ) {
267
- $this->properties->{$property} = $value;
268
-
269
- return $this;
270
- }
271
-
272
- /**
273
- * @param string $option
274
- *
275
- * @return mixed $value
276
- */
277
- public function set_options( $option, $value ) {
278
- $this->options->{$option} = $value;
279
-
280
- return $this;
281
- }
282
-
283
- /**
284
- * @since 2.4.7
285
- */
286
- public function set_filter( CAC_Filtering_Model $filtering_model ) {
287
- $this->filtering_model = $filtering_model;
288
-
289
- return $this;
290
- }
291
-
292
- /**
293
- * @since 2.4.7
294
- */
295
- public function get_filter() {
296
- return $this->filtering_model;
297
- }
298
-
299
- /**
300
- * @since 2.4.8
301
- */
302
- public function set_editable( CACIE_Editable_Model $editable_model ) {
303
- $this->editable_model = $editable_model;
304
-
305
- return $this;
306
- }
307
-
308
- /**
309
- * @since 2.4.8
310
- */
311
- public function get_editable() {
312
- return $this->editable_model;
313
- }
314
-
315
- /**
316
- * @param int $id
317
- *
318
- * @return object
319
- */
320
- public function set_clone( $id = null ) {
321
-
322
- if ( $id !== null && $id > 0 ) {
323
- $this->properties->name = "{$this->properties->type}-{$id}";
324
- $this->properties->clone = $id;
325
- }
326
-
327
- return $this;
328
- }
329
-
330
- /**
331
- * @since 2.4.9
332
- */
333
- public function get_display_value( $id ) {
334
- $value = $this->get_value( $id );
335
-
336
- // add before and after string
337
- if ( $value ) {
338
- $value = $this->get_before() . $value . $this->get_after();
339
- }
340
-
341
- return $value;
342
- }
343
-
344
- /**
345
- * @since 1.0
346
- */
347
- public function get_before() {
348
- return isset( $this->options->before ) ? stripslashes( $this->options->before ) : false;
349
- }
350
-
351
- /**
352
- * @since 1.0
353
- */
354
- public function get_after() {
355
- return isset( $this->options->after ) ? stripslashes( $this->options->after ) : false;
356
- }
357
-
358
- /**
359
- * Get the type of the column.
360
- *
361
- * @since 2.3.4
362
- */
363
- public function get_type() {
364
- return $this->properties->type;
365
- }
366
-
367
- /**
368
- * Get the name of the column.
369
- *
370
- * @since 2.3.4
371
- */
372
- public function get_name() {
373
- return $this->properties->name;
374
- }
375
-
376
- /**
377
- * Get the type of the column.
378
- *
379
- * @since 2.4.9
380
- */
381
- public function get_type_label() {
382
- return $this->properties->label;
383
- }
384
-
385
- /**
386
- * Get the type of the column.
387
- *
388
- * @since 2.5
389
- */
390
- public function is_registered() {
391
- return $this->properties->is_registered;
392
- }
393
-
394
- /**
395
- * Get the column options set by the user
396
- *
397
- * @since 2.3.4
398
- * @return object Column options set by user
399
- */
400
- public function get_options() {
401
- return $this->options;
402
- }
403
-
404
- /**
405
- * Get a single column option
406
- *
407
- * @since 2.3.4
408
- * @return array Column options set by user
409
- */
410
- public function get_option( $name ) {
411
- return isset( $this->options->{$name} ) ? $this->options->{$name} : false;
412
- }
413
-
414
- /**
415
- * Get a single column option
416
- *
417
- * @since 2.4.8
418
- * @return array Column options set by user
419
- */
420
- public function get_property( $name ) {
421
- return isset( $this->properties->{$name} ) ? $this->properties->{$name} : false;
422
- }
423
-
424
- /**
425
- * Checks column type
426
- *
427
- * @since 2.3.4
428
- *
429
- * @param string $type Column type. Also work without the 'column-' prefix. Example 'column-meta' or 'meta'.
430
- *
431
- * @return bool Matches column type
432
- */
433
- public function is_type( $type ) {
434
- return ( $type === $this->get_type() ) || ( 'column-' . $type === $this->get_type() );
435
- }
436
-
437
- /**
438
- * @since 2.1.1
439
- */
440
- public function get_post_type() {
441
- return $this->get_storage_model()->get_post_type();
442
- }
443
-
444
- /**
445
- * @since 2.5.4
446
- */
447
- public function get_storage_model_key() {
448
- return $this->storage_model;
449
- }
450
-
451
- /**
452
- * @since 2.3.4
453
- */
454
- public function get_storage_model() {
455
- return cpac()->get_storage_model( $this->storage_model );
456
- }
457
-
458
- /**
459
- * @since 2.3.4
460
- */
461
- public function get_storage_model_type() {
462
- return $this->get_storage_model()->get_type();
463
- }
464
-
465
- /**
466
- * @since 2.3.4
467
- */
468
- public function get_meta_type() {
469
- return $this->get_storage_model()->get_meta_type();
470
- }
471
-
472
- /**
473
- * @param string $field_key
474
- *
475
- * @return void
476
- */
477
- public function attr_name( $field_name ) {
478
- echo $this->get_attr_name( $field_name );
479
- }
480
-
481
- public function get_attr_name( $field_name ) {
482
- return "{$this->get_storage_model()->key}[{$this->properties->name}][{$field_name}]";
483
- }
484
-
485
- /**
486
- * @param string $field_key
487
- *
488
- * @return string Attribute Name
489
- */
490
- public function get_attr_id( $field_name ) {
491
- return "cpac-{$this->get_storage_model()->key}-{$this->properties->name}-{$field_name}";
492
- }
493
-
494
- public function attr_id( $field_name ) {
495
- echo $this->get_attr_id( $field_name );
496
- }
497
-
498
- /**
499
- * @since 2.0
500
- */
501
- public function sanitize_label() {
502
- // check if original label has changed. Example WPML adds a language column, the column heading will have to display the added flag.
503
- if ( $this->properties->hide_label && $this->properties->label !== $this->options->label ) {
504
- $this->options->label = $this->properties->label;
505
- }
506
-
507
- // replace urls, so export will not have to deal with them
508
- $this->options->label = stripslashes( str_replace( '[cpac_site_url]', site_url(), $this->options->label ) );
509
- }
510
-
511
- /**
512
- * @since 2.0
513
- *
514
- * @param $options array User submitted column options
515
- *
516
- * @return array Options
517
- */
518
- public function sanitize_storage( $options ) {
519
-
520
- // excerpt length must be numeric, else we will return it's default
521
- if ( isset( $options['excerpt_length'] ) ) {
522
- $options['excerpt_length'] = trim( $options['excerpt_length'] );
523
- if ( empty( $options['excerpt_length'] ) || ! is_numeric( $options['excerpt_length'] ) ) {
524
- $options['excerpt_length'] = 30;
525
- }
526
- }
527
-
528
- if ( ! empty( $options['label'] ) ) {
529
-
530
- // Label can not contains the character ":"" and "'", because
531
- // CPAC_Column::get_sanitized_label() will return an empty string
532
- // and make an exception for site_url()
533
- // Enable data:image url's
534
- if ( false === strpos( $options['label'], site_url() ) && false === strpos( $options['label'], 'data:' ) ) {
535
- $options['label'] = str_replace( ':', '', $options['label'] );
536
- $options['label'] = str_replace( "'", '', $options['label'] );
537
- }
538
- }
539
-
540
- // used by child classes for additional sanitizing
541
- $options = $this->sanitize_options( $options );
542
-
543
- return $options;
544
- }
545
-
546
- /**
547
- * @since 2.0
548
- */
549
- public function get_label() {
550
-
551
- /**
552
- * Filter the column instance label
553
- *
554
- * @since 2.0
555
- *
556
- * @param string $label Column instance label
557
- * @param CPAC_Column $column_instance Column class instance
558
- */
559
- return apply_filters( 'cac/column/settings_label', stripslashes( str_replace( '[cpac_site_url]', site_url(), $this->get_option( 'label' ) ) ), $this );
560
- }
561
-
562
- /**
563
- * Sanitizes label using intern wordpress function esc_url so it matches the label sorting url.
564
- *
565
- * @since 1.0
566
- *
567
- * @param string $string
568
- *
569
- * @return string Sanitized string
570
- */
571
- public function get_sanitized_label() {
572
- if ( $this->properties->default ) {
573
- $string = $this->properties->name;
574
- }
575
-
576
- else {
577
- $string = $this->get_option( 'label' );
578
- $string = strip_tags( $string );
579
- $string = preg_replace( "/[^a-zA-Z0-9]+/", "", $string );
580
- $string = str_replace( 'http://', '', $string );
581
- $string = str_replace( 'https://', '', $string );
582
- }
583
-
584
- return $string;
585
- }
586
-
587
- /**
588
- * @since 1.3.1
589
- */
590
- protected function get_shorten_url( $url = '' ) {
591
- if ( ! $url ) {
592
- return false;
593
- }
594
-
595
- return "<a title='{$url}' href='{$url}'>" . url_shorten( $url ) . "</a>";
596
- }
597
-
598
- /**
599
- * @since 1.3
600
- */
601
- public function strip_trim( $string ) {
602
- return trim( strip_tags( $string ) );
603
- }
604
-
605
- /**
606
- * @since 2.2.1
607
- */
608
- protected function get_term_field( $field, $term_id, $taxonomy ) {
609
- $term_field = get_term_field( $field, $term_id, $taxonomy, 'display' );
610
- if ( is_wp_error( $term_field ) ) {
611
- return false;
612
- }
613
-
614
- return $term_field;
615
- }
616
-
617
- // since 2.4.8
618
- public function get_raw_post_field( $field, $id ) {
619
- global $wpdb;
620
-
621
- return $id && is_numeric( $id ) ? $wpdb->get_var( $wpdb->prepare( "SELECT " . $wpdb->_real_escape( $field ) . " FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $id ) ) : false;
622
- }
623
-
624
- // since 2.4.8
625
- public function get_post_title( $id ) {
626
- return esc_html( $this->get_raw_post_field( 'post_title', $id ) );
627
- }
628
-
629
- /**
630
- * @since 1.0
631
- *
632
- * @param int $post_id Post ID
633
- *
634
- * @return string Post Excerpt.
635
- */
636
- protected function get_post_excerpt( $post_id, $words ) {
637
- global $post;
638
-
639
- $save_post = $post;
640
- $post = get_post( $post_id );
641
-
642
- setup_postdata( $post );
643
-
644
- $excerpt = get_the_excerpt();
645
- $post = $save_post;
646
-
647
- if ( $post ) {
648
- setup_postdata( $post );
649
- }
650
-
651
- $output = $this->get_shortened_string( $excerpt, $words );
652
-
653
- return $output;
654
- }
655
-
656
- /**
657
- * @see wp_trim_words();
658
- * @since 1.0
659
- * @return string Trimmed text.
660
- */
661
- public function get_shortened_string( $text = '', $num_words = 30, $more = null ) {
662
- if ( ! $text ) {
663
- return false;
664
- }
665
-
666
- return wp_trim_words( $text, $num_words, $more );
667
- }
668
-
669
- /**
670
- * @since 1.3.1
671
- *
672
- * @param string $name
673
- * @param string $title
674
- *
675
- * @return string HTML img element
676
- */
677
- public function get_asset_image( $name = '', $title = '' ) {
678
-
679
- if ( ! $name ) {
680
- return false;
681
- }
682
-
683
- return sprintf( "<img alt='' src='%s' title='%s'/>", CPAC_URL . "assets/images/{$name}", esc_attr( $title ) );
684
- }
685
-
686
- /**
687
- * @since 3.4.4
688
- */
689
- public function get_user_postcount( $user_id, $post_type ) {
690
- global $wpdb;
691
- $sql = "
692
- SELECT COUNT(ID)
693
- FROM {$wpdb->posts}
694
- WHERE post_status = 'publish'
695
- AND post_author = %d
696
- AND post_type = %s
697
- ";
698
-
699
- return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $post_type ) );
700
- }
701
-
702
- /**
703
- * @since 1.2.0
704
- *
705
- * @param string $url
706
- *
707
- * @return bool
708
- */
709
- protected function is_image_url( $url ) {
710
-
711
- if ( ! is_string( $url ) ) {
712
- return false;
713
- }
714
-
715
- $validExt = array( '.jpg', '.jpeg', '.gif', '.png', '.bmp' );
716
- $ext = strrchr( $url, '.' );
717
-
718
- return in_array( $ext, $validExt );
719
- }
720
-
721
- /**
722
- * @since 1.0
723
- * @return array Image Sizes.
724
- */
725
- public function get_all_image_sizes() {
726
- $image_sizes = array(
727
- 'thumbnail' => __( "Thumbnail", 'codepress-admin-columns' ),
728
- 'medium' => __( "Medium", 'codepress-admin-columns' ),
729
- 'large' => __( "Large", 'codepress-admin-columns' ),
730
- 'full' => __( "Full", 'codepress-admin-columns' )
731
- );
732
-
733
- foreach ( get_intermediate_image_sizes() as $size ) {
734
- if ( ! isset( $image_sizes[ $size ] ) ) {
735
- $image_sizes[ $size ] = ucwords( str_replace( '-', ' ', $size ) );
736
- }
737
- }
738
-
739
- return $image_sizes;
740
- }
741
-
742
- /**
743
- * @since 2.2.6
744
- */
745
- public function get_terms_for_display( $term_ids, $taxonomy ) {
746
- if ( empty( $term_ids ) ) {
747
- return false;
748
- }
749
-
750
- $values = array();
751
- $term_ids = (array) $term_ids;
752
- if ( $term_ids && ! is_wp_error( $term_ids ) ) {
753
- $post_type = $this->get_post_type();
754
- foreach ( $term_ids as $term_id ) {
755
- $term = get_term( $term_id, $taxonomy );
756
- $title = esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, $term->taxonomy, 'edit' ) );
757
-
758
- $filter_key = $term->taxonomy;
759
- if ( 'category' === $term->taxonomy ) {
760
- $filter_key = 'category_name';
761
- }
762
-
763
- $link = "<a href='edit.php?post_type={$post_type}&{$filter_key}={$term->slug}'>{$title}</a>";
764
- if ( $post_type == 'attachment' ) {
765
- $link = "<a href='upload.php?taxonomy={$filter_key}&term={$term->slug}'>{$title}</a>";
766
- }
767
-
768
- $values[] = $link;
769
- }
770
- }
771
- if ( ! $values ) {
772
- return false;
773
- }
774
-
775
- return implode( ', ', $values );
776
- }
777
-
778
- /**
779
- * @since 2.0
780
- *
781
- * @param string $name
782
- *
783
- * @return array Image Sizes
784
- */
785
- public function get_image_size_by_name( $name = '' ) {
786
-
787
- if ( ! $name || is_array( $name ) ) {
788
- return false;
789
- }
790
-
791
- global $_wp_additional_image_sizes;
792
-
793
- if ( ! isset( $_wp_additional_image_sizes[ $name ] ) ) {
794
- return false;
795
- }
796
-
797
- return $_wp_additional_image_sizes[ $name ];
798
- }
799
-
800
- /**
801
- * @see image_resize()
802
- * @since 2.0
803
- * @return string Image URL
804
- */
805
- public function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
806
- $resized = false;
807
- $editor = wp_get_image_editor( $file );
808
-
809
- if ( is_wp_error( $editor ) ) {
810
- return false;
811
- }
812
-
813
- $editor->set_quality( $jpeg_quality );
814
-
815
- $resized = $editor->resize( $max_w, $max_h, $crop );
816
- if ( is_wp_error( $resized ) ) {
817
- return false;
818
- }
819
-
820
- $dest_file = $editor->generate_filename( $suffix, $dest_path );
821
-
822
- $saved = $editor->save( $dest_file );
823
-
824
- if ( is_wp_error( $saved ) ) {
825
- return false;
826
- }
827
-
828
- $resized = $dest_file;
829
-
830
- return $resized;
831
- }
832
-
833
- /**
834
- * @since: 2.2.6
835
- *
836
- */
837
- public function get_color_for_display( $color_hex ) {
838
- if ( ! $color_hex ) {
839
- return false;
840
- }
841
- $text_color = $this->get_text_color( $color_hex );
842
-
843
- return "<div class='cpac-color'><span style='background-color:{$color_hex};color:{$text_color}'>{$color_hex}</span></div>";
844
- }
845
-
846
- /**
847
- * Determines text color absed on bakground coloring.
848
- *
849
- * @since 1.0
850
- */
851
- public function get_text_color( $bg_color ) {
852
-
853
- $rgb = $this->hex2rgb( $bg_color );
854
-
855
- return $rgb && ( ( $rgb[0] * 0.299 + $rgb[1] * 0.587 + $rgb[2] * 0.114 ) < 186 ) ? '#ffffff' : '#333333';
856
- }
857
-
858
- /**
859
- * Convert hex to rgb
860
- *
861
- * @since 1.0
862
- */
863
- public function hex2rgb( $hex ) {
864
- $hex = str_replace( "#", "", $hex );
865
-
866
- if ( strlen( $hex ) == 3 ) {
867
- $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
868
- $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
869
- $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
870
- }
871
- else {
872
- $r = hexdec( substr( $hex, 0, 2 ) );
873
- $g = hexdec( substr( $hex, 2, 2 ) );
874
- $b = hexdec( substr( $hex, 4, 2 ) );
875
- }
876
- $rgb = array( $r, $g, $b );
877
-
878
- return $rgb;
879
- }
880
-
881
- /**
882
- * Count the number of words in a string (multibyte-compatible)
883
- *
884
- * @since 2.3
885
- *
886
- * @param string $input Input string
887
- *
888
- * @return int Number of words
889
- */
890
- public function str_count_words( $input ) {
891
-
892
- $patterns = array(
893
- 'strip' => '/<[a-zA-Z\/][^<>]*>/',
894
- 'clean' => '/[0-9.(),;:!?%#$¿\'"_+=\\/-]+/',
895
- 'w' => '/\S\s+/',
896
- 'c' => '/\S/'
897
- );
898
-
899
- $type = 'w';
900
-
901
- $input = preg_replace( $patterns['strip'], ' ', $input );
902
- $input = preg_replace( '/&nbsp;|&#160;/i', ' ', $input );
903
- $input = preg_replace( $patterns['clean'], '', $input );
904
-
905
- if ( ! strlen( preg_replace( '/\s/', '', $input ) ) ) {
906
- return 0;
907
- }
908
-
909
- return preg_match_all( $patterns[ $type ], $input, $matches ) + 1;
910
- }
911
-
912
- /**
913
- * @since 2.5
914
- */
915
- public function get_empty_char() {
916
- return '&ndash;'; // dash
917
- }
918
-
919
- /**
920
- * @since 1.0
921
- *
922
- * @param mixed $meta Image files or Image ID's
923
- * @param array $args
924
- *
925
- * @return array HTML img elements
926
- */
927
- public function get_thumbnails( $images, $args = array() ) {
928
-
929
- if ( empty( $images ) || 'false' == $images ) {
930
- return array();
931
- }
932
-
933
- // turn string to array
934
- if ( is_string( $images ) || is_numeric( $images ) ) {
935
- if ( strpos( $images, ',' ) !== false ) {
936
- $images = array_filter( explode( ',', $this->strip_trim( str_replace( ' ', '', $images ) ) ) );
937
- }
938
- else {
939
- $images = array( $images );
940
- }
941
- }
942
-
943
- // Image size
944
- $defaults = array(
945
- 'image_size' => 'cpac-custom',
946
- 'image_size_w' => 80,
947
- 'image_size_h' => 80,
948
- );
949
- $args = wp_parse_args( $args, $defaults );
950
-
951
- $image_size = $args['image_size'];
952
- $image_size_w = $args['image_size_w'];
953
- $image_size_h = $args['image_size_h'];
954
-
955
- $thumbnails = array();
956
- foreach ( $images as $value ) {
957
-
958
- if ( $this->is_image_url( $value ) ) {
959
-
960
- // get dimensions from image_size
961
- if ( $sizes = $this->get_image_size_by_name( $image_size ) ) {
962
- $image_size_w = $sizes['width'];
963
- $image_size_h = $sizes['height'];
964
- }
965
-
966
- $image_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $value );
967
-
968
- if ( is_file( $image_path ) ) {
969
-
970
- // try to resize image
971
- if ( $resized = $this->image_resize( $image_path, $image_size_w, $image_size_h, true ) ) {
972
- $thumbnails[] = "<img src='" . str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $resized ) . "' alt='' width='{$image_size_w}' height='{$image_size_h}' />";
973
- } // return full image with maxed dimensions
974
- else {
975
- $thumbnails[] = "<img src='{$value}' alt='' style='max-width:{$image_size_w}px;max-height:{$image_size_h}px' />";
976
- }
977
- }
978
- } // Media Attachment
979
- elseif ( is_numeric( $value ) && wp_get_attachment_url( $value ) ) {
980
-
981
- $src = '';
982
- $width = '';
983
- $height = '';
984
-
985
- if ( ! $image_size || 'cpac-custom' == $image_size ) {
986
- $width = $image_size_w;
987
- $height = $image_size_h;
988
-
989
- // to make sure wp_get_attachment_image_src() get the image with matching dimensions.
990
- $image_size = array( $width, $height );
991
- }
992
-
993
- // Is Image
994
- if ( $attributes = wp_get_attachment_image_src( $value, $image_size ) ) {
995
-
996
- $src = $attributes[0];
997
- $width = $attributes[1];
998
- $height = $attributes[2];
999
-
1000
- // image size by name
1001
- if ( $sizes = $this->get_image_size_by_name( $image_size ) ) {
1002
- $width = $sizes['width'];
1003
- $height = $sizes['height'];
1004
- }
1005
- } // Is File, use icon
1006
- elseif ( $attributes = wp_get_attachment_image_src( $value, $image_size, true ) ) {
1007
- $src = $attributes[0];
1008
-
1009
- if ( $sizes = $this->get_image_size_by_name( $image_size ) ) {
1010
- $width = $sizes['width'];
1011
- $height = $sizes['height'];
1012
- }
1013
- }
1014
- if ( is_array( $image_size ) ) {
1015
- $width = $image_size_w;
1016
- $height = $image_size_h;
1017
-
1018
- $thumbnails[] = "<span class='cpac-column-value-image' style='width:{$width}px;height:{$height}px; background-size: cover; background-image: url({$src}); background-position: center;'></span>";
1019
-
1020
- }
1021
- else {
1022
- $max = max( array( $width, $height ) );
1023
- $thumbnails[] = "<span class='cpac-column-value-image' style='width:{$width}px;height:{$height}px;'><img style='max-width:{$max}px;max-height:{$max}px;' src='{$src}' alt=''/></span>";
1024
- }
1025
-
1026
- }
1027
- }
1028
-
1029
- return $thumbnails;
1030
- }
1031
-
1032
- /**
1033
- * Implode for multi dimensional array
1034
- *
1035
- * @since 1.0
1036
- *
1037
- * @param string $glue
1038
- * @param array $pieces
1039
- *
1040
- * @return string Imploded array
1041
- */
1042
- public function recursive_implode( $glue, $pieces ) {
1043
- if ( is_array( $pieces ) ) {
1044
- foreach ( $pieces as $r_pieces ) {
1045
- if ( is_array( $r_pieces ) ) {
1046
- $retVal[] = $this->recursive_implode( $glue, $r_pieces );
1047
- }
1048
- else {
1049
- $retVal[] = $r_pieces;
1050
- }
1051
- }
1052
- if ( isset( $retVal ) && is_array( $retVal ) ) {
1053
- return implode( $glue, $retVal );
1054
- }
1055
- }
1056
-
1057
- if ( is_scalar( $pieces ) ) {
1058
- return $pieces;
1059
- }
1060
-
1061
- return false;
1062
- }
1063
-
1064
- /**
1065
- * Get timestamp
1066
- *
1067
- * @since 2.0
1068
- *
1069
- * @param string $date
1070
- *
1071
- * @return string Formatted date
1072
- */
1073
- public function get_timestamp( $date ) {
1074
-
1075
- if ( empty( $date ) || in_array( $date, array( '0000-00-00 00:00:00', '0000-00-00', '00:00:00' ) ) ) {
1076
- return false;
1077
- }
1078
-
1079
- // some plugins store dates in a jquery timestamp format, format is in ms since The Epoch.
1080
- // See http://api.jqueryui.com/datepicker/#utility-formatDate
1081
- // credits: nmarks
1082
- if ( is_numeric( $date ) ) {
1083
- $length = strlen( trim( $date ) );
1084
-
1085
- // Dates before / around September 8th, 2001 are saved as 9 numbers * 1000 resulting in 12 numbers to store the time.
1086
- // Dates after September 8th are saved as 10 numbers * 1000, resulting in 13 numbers.
1087
- // For example the ACF Date and Time Picker uses this format.
1088
- // credits: Ben C
1089
- if ( 12 === $length || 13 === $length ) {
1090
- $date = round( $date / 1000 ); // remove the ms
1091
- }
1092
-
1093
- // Date format: yyyymmdd ( often used by ACF ) must start with 19xx or 20xx and is 8 long
1094
- // @todo: in theory a numeric string of 8 can also be a unixtimestamp; no conversion would be needed
1095
- if ( 8 === $length && ( strpos( $date, '20' ) === 0 || strpos( $date, '19' ) === 0 ) ) {
1096
- $date = strtotime( $date );
1097
- }
1098
- } // Parse with strtotime if it's not numeric
1099
- else {
1100
- $date = strtotime( $date );
1101
- }
1102
-
1103
- return $date;
1104
- }
1105
-
1106
- /**
1107
- * @since 1.3.1
1108
- *
1109
- * @param string $date
1110
- *
1111
- * @return string Formatted date
1112
- */
1113
- public function get_date( $date, $format = '' ) {
1114
- if ( ! $timestamp = $this->get_timestamp( $date ) ) {
1115
- return false;
1116
- }
1117
-
1118
- // get general date format
1119
- if ( ! $format ) {
1120
- $format = get_option( 'date_format' );
1121
- }
1122
-
1123
- return date_i18n( $format, $timestamp );
1124
- }
1125
-
1126
- /**
1127
- * @since 1.3.1
1128
- *
1129
- * @param string $date
1130
- *
1131
- * @return string Formatted time
1132
- */
1133
- protected function get_time( $date, $format = '' ) {
1134
-
1135
- if ( ! $date = $this->get_timestamp( $date ) ) {
1136
- return false;
1137
- }
1138
- if ( ! $format ) {
1139
- $format = get_option( 'time_format' );
1140
- }
1141
-
1142
- return date_i18n( $format, $date );
1143
- }
1144
-
1145
- /**
1146
- * Get display name.
1147
- *
1148
- * Can also be used by addons.
1149
- *
1150
- * @since 2.0
1151
- */
1152
- public function get_display_name( $user_id ) {
1153
-
1154
- if ( ! $userdata = get_userdata( $user_id ) ) {
1155
- return false;
1156
- }
1157
-
1158
- $name = '';
1159
-
1160
- if ( $display_as = $this->get_option( 'display_author_as' ) ) {
1161
-
1162
- if ( 'first_last_name' == $display_as ) {
1163
- $first = ! empty( $userdata->first_name ) ? $userdata->first_name : '';
1164
- $last = ! empty( $userdata->last_name ) ? " {$userdata->last_name}" : '';
1165
- $name = $first . $last;
1166
- }
1167
- elseif ( ! empty( $userdata->{$display_as} ) ) {
1168
- $name = $userdata->{$display_as};
1169
- }
1170
- }
1171
-
1172
- // default to display_name
1173
- if ( ! $name ) {
1174
- $name = $userdata->display_name;
1175
- }
1176
-
1177
- return $name;
1178
- }
1179
-
1180
- /**
1181
- * @since 2.0
1182
- *
1183
- * @param string $field_key
1184
- *
1185
- * @return string Attribute Name
1186
- */
1187
- public function label_view( $label, $description = '', $pointer = '' ) {
1188
- ?>
1189
- <td class="label">
1190
- <label for="<?php $this->attr_id( $pointer ); ?>">
1191
- <?php echo stripslashes( $label ); ?>
1192
- <?php if ( $description ) : ?><p class="description"><?php echo $description; ?></p><?php endif; ?>
1193
- </label>
1194
- </td>
1195
- <?php
1196
- }
1197
-
1198
- /**
1199
- * @since 2.0
1200
- */
1201
- public function display_field_date_format() {
1202
-
1203
- $field_key = 'date_format';
1204
- $label = __( 'Date Format', 'codepress-admin-columns' );
1205
- $description = __( 'This will determine how the date will be displayed.', 'codepress-admin-columns' );
1206
- ?>
1207
- <tr class="column_<?php echo $field_key; ?>">
1208
- <?php $this->label_view( $label, $description, $field_key ); ?>
1209
- <td class="input">
1210
- <input type="text" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>" value="<?php echo $this->get_option( 'date_format' ); ?>" placeholder="<?php _e( 'Example:', 'codepress-admin-columns' ); ?> d M Y H:i"/>
1211
-
1212
- <p class="description">
1213
- <?php printf( __( "Leave empty for WordPress date format, change your <a href='%s'>default date format here</a>.", 'codepress-admin-columns' ), admin_url( 'options-general.php' ) . '#date_format_custom_radio' ); ?>
1214
- <a target='_blank' href='http://codex.wordpress.org/Formatting_Date_and_Time'><?php _e( 'Documentation on date and time formatting.', 'codepress-admin-columns' ); ?></a>
1215
- </p>
1216
- </td>
1217
- </tr>
1218
-
1219
- <?php
1220
- }
1221
-
1222
- /**
1223
- * @since 2.0
1224
- */
1225
- public function display_field_excerpt_length() {
1226
-
1227
- $field_key = 'excerpt_length';
1228
- $label = __( 'Excerpt length', 'codepress-admin-columns' );
1229
- $description = __( 'Number of words', 'codepress-admin-columns' );
1230
-
1231
- ?>
1232
- <tr class="column_<?php echo $field_key; ?>">
1233
- <?php $this->label_view( $label, $description, $field_key ); ?>
1234
- <td class="input">
1235
- <input type="text" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>" value="<?php echo $this->get_option( 'excerpt_length' ); ?>"/>
1236
- </td>
1237
- </tr>
1238
- <?php
1239
- }
1240
-
1241
- /**
1242
- * @since 2.4.9
1243
- */
1244
- public function display_field_link_label() {
1245
- $field_key = 'link_label';
1246
- $label = __( 'Link label', 'codepress-admin-columns' );
1247
- $description = __( 'Leave blank to display the url', 'codepress-admin-columns' );
1248
-
1249
- ?>
1250
- <tr class="column_<?php echo $field_key; ?>">
1251
- <?php $this->label_view( $label, $description, $field_key ); ?>
1252
- <td class="input">
1253
- <input type="text" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>" value="<?php echo $this->get_option( 'link_label' ); ?>"/>
1254
- </td>
1255
- </tr>
1256
- <?php
1257
- }
1258
-
1259
- /**
1260
- * @since 2.0
1261
- */
1262
- public function display_field_preview_size() {
1263
-
1264
- $field_key = 'image_size';
1265
- $label = __( 'Preview size', 'codepress-admin-columns' );
1266
-
1267
- $image_size = $this->get_option( 'image_size' );
1268
- ?>
1269
- <tr class="column_<?php echo $field_key; ?>">
1270
-
1271
- <?php $this->label_view( $label, '', $field_key ); ?>
1272
-
1273
- <td class="input">
1274
- <?php foreach ( $sizes = $this->get_all_image_sizes() as $id => $image_label ) : $_sizes = array_keys( $sizes ); ?>
1275
- <?php $selected = $image_size ? $image_size : $_sizes[0]; ?>
1276
- <label for="<?php $this->attr_id( $field_key ); ?>-<?php echo $id ?>" class="custom-size">
1277
- <input type="radio" value="<?php echo $id; ?>" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-<?php echo $id ?>"<?php checked( $selected, $id ); ?>>
1278
- <?php echo $image_label; ?>
1279
- </label>
1280
- <?php endforeach; ?>
1281
-
1282
- <div class="custom_image_size">
1283
- <label for="<?php $this->attr_id( $field_key ); ?>-custom" class="custom-size image-size-custom">
1284
- <input type="radio" value="cpac-custom" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-custom"<?php checked( $image_size, 'cpac-custom' ); ?>><?php _e( 'Custom', 'codepress-admin-columns' ); ?>
1285
- </label>
1286
- <label for="<?php $this->attr_id( $field_key ); ?>-w"
1287
- class="custom-size-w<?php echo $image_size != 'cpac-custom' ? ' hidden' : ''; ?>">
1288
- <input type="text" name="<?php $this->attr_name( 'image_size_w' ); ?>" id="<?php $this->attr_id( $field_key ); ?>-w" value="<?php echo $this->get_option( 'image_size_w' ); ?>"/><?php _e( 'width', 'codepress-admin-columns' ); ?>
1289
- </label>
1290
- <label for="<?php $this->attr_id( $field_key ); ?>-h"
1291
- class="custom-size-h<?php echo $image_size != 'cpac-custom' ? ' hidden' : ''; ?>">
1292
- <input type="text" name="<?php $this->attr_name( 'image_size_h' ); ?>" id="<?php $this->attr_id( $field_key ); ?>-h" value="<?php echo $this->get_option( 'image_size_h' );; ?>"/><?php _e( 'height', 'codepress-admin-columns' ); ?>
1293
- </label>
1294
- </div>
1295
- </td>
1296
- </tr>
1297
- <?php
1298
- }
1299
-
1300
- /**
1301
- * @since 2.1.1
1302
- */
1303
- public function display_field_before_after() {
1304
- $this->display_field_text( 'before', __( "Before", 'codepress-admin-columns' ), __( 'This text will appear before the custom field value.', 'codepress-admin-columns' ) );
1305
- $this->display_field_text( 'after', __( "After", 'codepress-admin-columns' ), __( 'This text will appear after the custom field value.', 'codepress-admin-columns' ) );
1306
- }
1307
-
1308
- /**
1309
- * @since 2.3.2
1310
- */
1311
- public function display_field_user_format() {
1312
-
1313
- $nametypes = array(
1314
- 'display_name' => __( 'Display Name', 'codepress-admin-columns' ),
1315
- 'first_name' => __( 'First Name', 'codepress-admin-columns' ),
1316
- 'last_name' => __( 'Last Name', 'codepress-admin-columns' ),
1317
- 'nickname' => __( 'Nickname', 'codepress-admin-columns' ),
1318
- 'user_login' => __( 'User Login', 'codepress-admin-columns' ),
1319
- 'user_email' => __( 'User Email', 'codepress-admin-columns' ),
1320
- 'ID' => __( 'User ID', 'codepress-admin-columns' ),
1321
- 'first_last_name' => __( 'First and Last Name', 'codepress-admin-columns' ),
1322
- );
1323
-
1324
- asort( $nametypes ); // sorts also when translated
1325
-
1326
- $this->display_field_select( 'display_author_as', __( 'Display format', 'codepress-admin-columns' ), $nametypes, __( 'This is the format of the author name.', 'codepress-admin-columns' ) );
1327
- }
1328
-
1329
- /**
1330
- * @since 2.3.4
1331
- *
1332
- * @param string $name Name of the column option
1333
- * @param string $label Label
1334
- * @param array $options Select options
1335
- * @param strong $description (optional) Description below the label
1336
- * @param string $optional_toggle_id (optional) Toggle ID will hide the row untill the toggle is triggered
1337
- * @param boolean $refresh This will JS refresh the column on change.
1338
- */
1339
- public function display_field_select( $name, $label, $options = array(), $description = '', $optional_toggle_id = '', $js_refresh = false ) {
1340
- $current = $this->get_option( $name );
1341
- $data_optional = $optional_toggle_id ? ' data-additional-option-id="' . $this->get_attr_id( $optional_toggle_id ) . '"' : '';
1342
- $data_refresh = $js_refresh ? ' data-refresh="1"' : '';
1343
- ?>
1344
- <tr class="column-<?php echo $name; ?>"<?php echo $data_optional; ?><?php echo $data_refresh; ?>>
1345
- <?php $this->label_view( $label, $description, $name ); ?>
1346
- <td class="input">
1347
- <select name="<?php $this->attr_name( $name ); ?>" id="<?php $this->attr_id( $name ); ?>">
1348
- <?php foreach ( $options as $key => $label ) : ?>
1349
- <option value="<?php echo $key; ?>"<?php selected( $key, $current ); ?>><?php echo $label; ?></option>
1350
- <?php endforeach; ?>
1351
- </select>
1352
- </td>
1353
- </tr>
1354
- <?php
1355
- }
1356
-
1357
- /**
1358
- * @since 2.3.4
1359
- *
1360
- * @param string $name Name of the column option
1361
- * @param string $label Label
1362
- * @param array $options Select options
1363
- * @param strong $description (optional) Description below the label
1364
- */
1365
- public function display_field_text( $name, $label, $description = '', $placeholder = '', $optional_toggle_id = '' ) {
1366
- $data_optional = $optional_toggle_id ? ' data-additional-option-id="' . $this->get_attr_id( $optional_toggle_id ) . '"' : '';
1367
- ?>
1368
- <tr class="column-<?php echo $name; ?>"<?php echo $data_optional; ?>>
1369
- <?php $this->label_view( $label, $description, $name ); ?>
1370
- <td class="input">
1371
- <input type="text" name="<?php $this->attr_name( $name ); ?>" id="<?php $this->attr_id( $name ); ?>" value="<?php echo esc_attr( stripslashes( $this->get_option( $name ) ) ); ?>"<?php echo $placeholder ? ' placeholder="' . esc_attr( $placeholder ) . '"' : ''; ?>/>
1372
- </td>
1373
- </tr>
1374
- <?php
1375
- }
1376
-
1377
- /**
1378
- * @since 2.4.8
1379
- *
1380
- * @param string $name Name of the column option
1381
- * @param string $value
1382
- */
1383
- public function display_field_hidden( $name, $value = '' ) {
1384
- ?>
1385
- <tr class="column-<?php echo $name; ?> hidden">
1386
- <td class="input">
1387
- <input type="hidden" name="<?php $this->attr_name( $name ); ?>" value="<?php echo esc_attr( $value ); ?>"/>
1388
- </td>
1389
- </tr>
1390
- <?php
1391
- }
1392
-
1393
- /**
1394
- * @since 2.4.7
1395
- *
1396
- * @param string $name Name of the column option
1397
- * @param string $label Label
1398
- * @param array $options Select options
1399
- * @param strong $description (optional) Description below the label
1400
- * @param string $optional_toggle_id (optional) Toggle ID will hide the row untill the toggle is triggered
1401
- */
1402
- public function display_field_radio( $name, $label, $options = array(), $description = '', $optional_toggle_id = '' ) {
1403
- $current = $this->get_option( $name );
1404
- $data_optional = $optional_toggle_id ? ' data-additional-option-id="' . $this->get_attr_id( $optional_toggle_id ) . '"' : '';
1405
- ?>
1406
- <tr class="column-<?php echo $name; ?>" <?php echo $data_optional; ?>>
1407
- <?php $this->label_view( $label, $description, $name ); ?>
1408
- <td class="input">
1409
- <?php foreach ( $options as $key => $label ) : ?>
1410
- <label>
1411
- <input type="radio" name="<?php $this->attr_name( $name ); ?>" id="<?php $this->attr_id( $name . '-' . $key ); ?>" value="<?php echo $key; ?>"<?php checked( $key, $current ); ?>>
1412
- <?php echo $label; ?>
1413
- </label>
1414
- <?php endforeach; ?>
1415
- </select>
1416
- </td>
1417
- </tr>
1418
- <?php
1419
- }
1420
-
1421
- /**
1422
- * @since 2.0
1423
- */
1424
- public function display() {
1425
-
1426
- $classes = implode( ' ', array_filter( array( "cpac-box-{$this->properties->type}", $this->properties->classes ) ) );
1427
-
1428
- // Selector
1429
- $column_list = '';
1430
- if ( $grouped_columns = $this->get_storage_model()->get_grouped_columns() ) {
1431
- foreach ( $grouped_columns as $group => $columns ) {
1432
- $column_list .= '<optgroup label="' . $group . '">';
1433
- foreach ( $columns as $type => $label ) {
1434
- $column_list .= '<option value="' . $type . '"' . selected( $this->properties->type, $type, false ) . '>' . $label . '</option>';
1435
- }
1436
- $column_list .= '</optgroup>';
1437
- }
1438
- }
1439
-
1440
- // clone attribute
1441
- $data_clone = $this->properties->is_cloneable ? " data-clone='{$this->properties->clone}'" : '';
1442
-
1443
- ?>
1444
- <div class="cpac-column <?php echo $classes; ?>" data-type="<?php echo $this->properties->type; ?>"<?php echo $data_clone; ?> data-default="<?php echo $this->is_default(); ?>">
1445
- <input type="hidden" class="column-name" name="<?php echo $this->attr_name( 'column-name' ); ?>" value="<?php echo esc_attr( $this->properties->name ); ?>"/>
1446
- <input type="hidden" class="type" name="<?php echo $this->attr_name( 'type' ); ?>" value="<?php echo $this->properties->type; ?>"/>
1447
- <input type="hidden" class="clone" name="<?php echo $this->attr_name( 'clone' ); ?>" value="<?php echo $this->properties->clone; ?>"/>
1448
-
1449
- <div class="column-meta">
1450
- <table class="widefat">
1451
- <tbody>
1452
- <tr>
1453
- <td class="column_sort"></td>
1454
- <td class="column_label">
1455
- <div class="inner">
1456
- <div class="meta">
1457
-
1458
- <span title="<?php echo esc_attr( __( 'width', 'codepress-admin-columns' ) ); ?>" class="width" data-indicator-id="">
1459
- <?php echo $this->get_option( 'width' ) ? $this->get_option( 'width' ) . $this->get_option( 'width_unit' ) : ''; ?>
1460
- </span>
1461
-
1462
- <?php
1463
- /**
1464
- * Fires in the meta-element for column options, which is displayed right after the column label
1465
- *
1466
- * @since 2.0
1467
- *
1468
- * @param CPAC_Column $column_instance Column class instance
1469
- */
1470
- do_action( 'cac/column/settings_meta', $this );
1471
-
1472
- /**
1473
- * @deprecated 2.2 Use cac/column/settings_meta instead
1474
- */
1475
- do_action( 'cac/column/label', $this );
1476
- ?>
1477
-
1478
- </div>
1479
- <a class="toggle" href="javascript:;"><?php echo stripslashes( $this->get_label() ); ?></a>
1480
- <a class="edit-button" href="javascript:;"><?php _e( 'Edit', 'codepress-admin-columns' ); ?></a>
1481
- <?php if ( $this->properties->is_cloneable ) : ?>
1482
- <a class="clone-button" href="#"><?php _e( 'Clone', 'codepress-admin-columns' ); ?></a>
1483
- <?php endif; ?>
1484
- <a class="remove-button" href="javascript:;"><?php _e( 'Remove', 'codepress-admin-columns' ); ?></a>
1485
- </div>
1486
- </td>
1487
- <td class="column_type">
1488
- <div class="inner">
1489
- <a href="#"><?php echo stripslashes( $this->properties->label ); ?></a>
1490
- </div>
1491
- </td>
1492
- <td class="column_edit"></td>
1493
- </tr>
1494
- </tbody>
1495
- </table>
1496
- </div><!--.column-meta-->
1497
-
1498
- <div class="column-form">
1499
- <table class="widefat">
1500
- <tbody>
1501
- <tr class="column_type">
1502
- <?php $this->label_view( __( 'Type', 'codepress-admin-columns' ), __( 'Choose a column type.', 'codepress-admin-columns' ) . '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->properties->type . '</em><em>' . __( 'Name', 'codepress-admin-columns' ) . ': ' . $this->properties->name . '</em>', 'type' ); ?>
1503
- <td class="input">
1504
- <select name="<?php $this->attr_name( 'type' ); ?>" id="<?php $this->attr_id( 'type' ); ?>">
1505
- <?php echo $column_list; ?>
1506
- </select>
1507
-
1508
- <div class="msg"></div>
1509
- </td>
1510
- </tr><!--.column_label-->
1511
-
1512
- <tr class="column_label<?php echo $this->properties->hide_label ? ' hidden' : ''; ?>">
1513
- <?php $this->label_view( __( 'Label', 'codepress-admin-columns' ), __( 'This is the name which will appear as the column header.', 'codepress-admin-columns' ), 'label' ); ?>
1514
- <td class="input">
1515
- <input class="text" type="text" name="<?php $this->attr_name( 'label' ); ?>" id="<?php $this->attr_id( 'label' ); ?>" value="<?php echo esc_attr( $this->get_option( 'label' ) ); ?>"/>
1516
- </td>
1517
- </tr><!--.column_label-->
1518
-
1519
- <tr class="column_width">
1520
- <?php $this->label_view( __( 'Width', 'codepress-admin-columns' ), '', 'width' ); ?>
1521
- <td class="input">
1522
- <div class="description" title="<?php _e( 'default', 'codepress-admin-columns' ); ?>">
1523
- <input class="width" type="text" placeholder="<?php _e( 'auto', 'codepress-admin-columns' ); ?>" name="<?php $this->attr_name( 'width' ); ?>" id="<?php $this->attr_id( 'width' ); ?>" value="<?php echo $this->get_option( 'width' ); ?>"/>
1524
- <span class="unit"><?php echo $this->get_option( 'width_unit' ); ?></span>
1525
- </div>
1526
- <div class="width-slider"></div>
1527
-
1528
- <div class="unit-select">
1529
- <label for="<?php $this->attr_id( 'width_unit_px' ); ?>">
1530
- <input type="radio" class="unit" name="<?php $this->attr_name( 'width_unit' ); ?>" id="<?php $this->attr_id( 'width_unit_px' ); ?>" value="px"<?php checked( $this->get_option( 'width_unit' ), 'px' ); ?>/>px
1531
- </label>
1532
- <label for="<?php $this->attr_id( 'width_unit_perc' ); ?>">
1533
- <input type="radio" class="unit" name="<?php $this->attr_name( 'width_unit' ); ?>" id="<?php $this->attr_id( 'width_unit_perc' ); ?>" value="%"<?php checked( $this->get_option( 'width_unit' ), '%' ); ?>/>%
1534
- </label>
1535
- </div>
1536
-
1537
- </td>
1538
- </tr><!--.column_width-->
1539
-
1540
- <?php
1541
- /**
1542
- * Fires directly before the custom options for a column are displayed in the column form
1543
- *
1544
- * @since 2.0
1545
- *
1546
- * @param CPAC_Column $column_instance Column class instance
1547
- */
1548
- do_action( 'cac/column/settings_before', $this );
1549
- ?>
1550
-
1551
- <?php
1552
- /**
1553
- * Load specific column settings.
1554
- *
1555
- */
1556
- $this->display_settings();
1557
-
1558
- ?>
1559
-
1560
- <?php
1561
- /**
1562
- * Load before and after fields for custom columns.
1563
- *
1564
- */
1565
- if ( $this->properties->use_before_after && ! $this->properties->default ) {
1566
- $this->display_field_before_after();
1567
- }
1568
- ?>
1569
-
1570
- <?php
1571
- /**
1572
- * Fires directly after the custom options for a column are displayed in the column form
1573
- *
1574
- * @since 2.0
1575
- *
1576
- * @param CPAC_Column $column_instance Column class instance
1577
- */
1578
- do_action( 'cac/column/settings_after', $this );
1579
- ?>
1580
-
1581
- <tr class="column_action">
1582
- <td colspan="2">
1583
- <p>
1584
- <?php if ( $this->properties->is_cloneable ) : ?>
1585
- <a class="clone-button" href="#"><?php _e( 'Clone', 'codepress-admin-columns' ); ?></a>
1586
- <?php endif; ?>
1587
- <a href="javascript:;" class="remove-button"><?php _e( 'Remove' ); ?></a>
1588
- </p>
1589
- </td>
1590
- </tr>
1591
-
1592
- </tbody>
1593
- </table>
1594
- </div><!--.column-form-->
1595
- </div><!--.cpac-column-->
1596
- <?php
1597
- }
1598
-
1599
- /**
1600
- * Display settings field for post property to display
1601
- *
1602
- * @since 2.4.7
1603
- */
1604
- public function display_field_post_property_display() {
1605
- $this->display_field_select(
1606
- 'post_property_display',
1607
- __( 'Property To Display', 'codepress-admin-columns' ),
1608
- array(
1609
- 'title' => __( 'Title' ), // default
1610
- 'id' => __( 'ID' ),
1611
- 'author' => __( 'Author' )
1612
- ),
1613
- __( 'Post property to display for related post(s).', 'codepress-admin-columns' )
1614
- );
1615
- }
1616
-
1617
- /**
1618
- * Display settings field for the page the posts should link to
1619
- *
1620
- * @since 2.4.7
1621
- */
1622
- public function display_field_post_link_to() {
1623
- $this->display_field_select(
1624
- 'post_link_to',
1625
- __( 'Link To', 'codepress-admin-columns' ),
1626
- array(
1627
- '' => __( 'None' ),
1628
- 'edit_post' => __( 'Edit Post' ),
1629
- 'view_post' => __( 'View Post' ),
1630
- 'edit_author' => __( 'Edit Post Author', 'codepress-admin-columns' ),
1631
- 'view_author' => __( 'View Public Post Author Page', 'codepress-admin-columns' )
1632
- ),
1633
- __( 'Page the posts should link to.', 'codepress-admin-columns' )
1634
- );
1635
- }
1636
-
1637
- /**
1638
- * @since 2.4.7
1639
- */
1640
- function display_settings_placeholder( $url ) { ?>
1641
- <div class="is-disabled">
1642
- <p>
1643
- <strong><?php printf( __( "The %s column is only available in Admin Columns Pro - Business or Developer.", 'codepress-admin-columns' ), $this->get_label() ); ?></strong>
1644
- </p>
1645
-
1646
- <p>
1647
- <?php printf( __( "If you have a business or developer licence please download & install your %s add-on from the <a href='%s'>add-ons tab</a>.", 'codepress-admin-columns' ), $this->get_label(), admin_url( 'options-general.php?page=codepress-admin-columns&tab=addons' ) ); ?>
1648
- </p>
1649
-
1650
- <p>
1651
- <?php printf( __( "Admin Columns Pro offers full %s integration, allowing you to easily display and edit %s fields from within your overview.", 'codepress-admin-columns' ), $this->get_label(), $this->get_label() ); ?>
1652
- </p>
1653
- <a href="<?php echo add_query_arg( array(
1654
- 'utm_source' => 'plugin-installation',
1655
- 'utm_medium' => $this->get_type(),
1656
- 'utm_campaign' => 'plugin-installation'
1657
- ), $url ); ?>" class="button button-primary"><?php _e( 'Find out more', 'codepress-admin-columns' ); ?></a>
1658
- </div>
1659
- <?php
1660
- }
1661
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/acf-placeholder.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * ACF Placeholder column, holding a CTA for Admin Columns Pro.
4
- *
5
- * @since 2.2
6
- */
7
- class CPAC_Column_ACF_Placeholder extends CPAC_Column {
8
-
9
- public function init() {
10
-
11
- parent::init();
12
-
13
- // Properties
14
- $this->properties['type'] = 'column-acf_placeholder';
15
- $this->properties['label'] = __( 'Advanced Custom Field', 'codepress-admin-columns' );
16
- $this->properties['is_pro_only'] = true;
17
- $this->properties['group'] = 'acf';
18
- }
19
-
20
- public function display_settings() {
21
- $this->display_settings_placeholder( ac_get_site_url( 'advanced-custom-fields-columns' ) );
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/actions.php DELETED
@@ -1,192 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Base class for columns containing action links for items.
5
- *
6
- * @since 2.2.6
7
- */
8
- abstract class CPAC_Column_Actions extends CPAC_Column {
9
-
10
- /**
11
- * Get a list of action links for an item (e.g. post) ID.
12
- *
13
- * @since 2.2.6
14
- *
15
- * @param int $id Item ID to get the list of actions for.
16
- *
17
- * @return array List of actions ([action name] => [action link]).
18
- */
19
- abstract public function get_actions( $id );
20
-
21
- /**
22
- * @see CPAC_Column::init()
23
- * @since 2.2.6
24
- */
25
- public function init() {
26
- parent::init();
27
-
28
- // Properties
29
- $this->properties['type'] = 'column-actions';
30
- $this->properties['label'] = __( 'Actions', 'codepress-admin-columns' );
31
-
32
- // Options
33
- $this->options['use_icons'] = false;
34
- }
35
-
36
- /**
37
- * @see CPAC_Column::get_value()
38
- * @since 2.2.6
39
- */
40
- public function get_value( $id ) {
41
- $actions = $this->get_raw_value( $id );
42
-
43
- if ( ! $actions ) {
44
- return false;
45
- }
46
-
47
- if ( $this->get_option( 'use_icons' ) ) {
48
- return implode( '', $this->convert_actions_to_icons( $actions ) );
49
- }
50
-
51
- $i = 0;
52
- $num_actions = count( $actions );
53
-
54
- foreach ( $actions as $class => $action ) {
55
- $actions[ $class ] = '<span class="' . esc_attr( $class ) . '">' . $action . ( $i < $num_actions - 1 ? ' | ' : '' ) . '</span>';
56
- $i ++;
57
- }
58
-
59
- return implode( '', $actions );
60
- }
61
-
62
- /**
63
- * @see CPAC_Column::get_value()
64
- * @since 2.2.6
65
- */
66
- public function get_raw_value( $id ) {
67
-
68
- /**
69
- * Filter the action links for the actions column
70
- *
71
- * @since 2.2.9
72
- *
73
- * @param array $actions List of actions ([action name] => [action link]).
74
- * @param CPAC_Column_Actions $column_instance Column object.
75
- * @param int $id Post/User/Comment ID
76
- */
77
- return apply_filters( 'cac/column/actions/action_links', $this->get_actions( $id ), $this, $id );
78
- }
79
-
80
- /**
81
- * @see CPAC_Column::display_settings()
82
- * @since 2.2.6
83
- */
84
- public function display_settings() {
85
- parent::display_settings();
86
-
87
- $this->display_field_use_icons();
88
- }
89
-
90
- /**
91
- * Display the settings field for using icons instead of text links.
92
- *
93
- * @since 2.2.6
94
- */
95
- public function display_field_use_icons() {
96
- ?>
97
- <tr class="column_editing">
98
- <?php $this->label_view( __( 'Use icons?', 'codepress-admin-columns' ), __( 'Use icons instead of text for displaying the actions.', 'codepress-admin-columns' ), 'use_icons' ); ?>
99
- <td class="input">
100
- <label for="<?php $this->attr_id( 'use_icons' ); ?>-yes">
101
- <input type="radio" value="1" name="<?php $this->attr_name( 'use_icons' ); ?>" id="<?php $this->attr_id( 'use_icons' ); ?>-yes"<?php checked( $this->get_option( 'use_icons' ), '1' ); ?> />
102
- <?php _e( 'Yes' ); ?>
103
- </label>
104
- <label for="<?php $this->attr_id( 'use_icons' ); ?>-no">
105
- <input type="radio" value="" name="<?php $this->attr_name( 'use_icons' ); ?>" id="<?php $this->attr_id( 'use_icons' ); ?>-no"<?php checked( $this->get_option( 'use_icons' ), '' ); ?> />
106
- <?php _e( 'No' ); ?>
107
- </label>
108
- </td>
109
- </tr>
110
- <?php
111
- }
112
-
113
- /**
114
- * Convert items from a list of action links to icons (if they have an icon).
115
- *
116
- * @since 2.2.6
117
- *
118
- * @param array $actions List of actions ([action name] => [action link]).
119
- *
120
- * @return array List of actions ([action name] => [action icon link]).
121
- */
122
- public function convert_actions_to_icons( $actions ) {
123
-
124
- $icons = $this->get_actions_icons();
125
-
126
- foreach ( $actions as $action => $link ) {
127
- $action1 = $action;
128
- $spacepos = $spacepos = strpos( $action1, ' ' );
129
-
130
- if ( $spacepos !== false ) {
131
- $action1 = substr( $action1, 0, $spacepos );
132
- }
133
-
134
- if ( isset( $icons[ $action1 ] ) ) {
135
- // Add mandatory "class" HTML attribute
136
- if ( strpos( $link, 'class=' ) === false ) {
137
- $link = str_replace( '<a ', '<a class="" ', $link );
138
- }
139
-
140
- // Add icon and tooltip classes
141
- $link = preg_replace( '/class=["\'](.*?)["\']/', 'class="$1 cpac-tip button cpac-button-action dashicons hide-content dashicons-' . $icons[ $action1 ] . '"', $link, 1 );
142
-
143
- // Add tooltip title
144
- $link = preg_replace_callback( '/>(.*?)<\/a>/', array( $this, 'add_link_tooltip' ), $link );
145
-
146
- $actions[ $action ] = $link;
147
- }
148
- }
149
-
150
- return $actions;
151
- }
152
-
153
- /**
154
- * Add the tooltip data attribute to the link
155
- * Callback for preg_replace_callback
156
- *
157
- * @since 2.2.6.1
158
- *
159
- * @param array $matches Matches information from preg_replace_callback
160
- *
161
- * @return string Link part with tooltip attribute
162
- */
163
- public function add_link_tooltip( $matches ) {
164
- return ' data-tip="' . esc_attr( $matches[1] ) . '">' . $matches[1] . '</a>';
165
- }
166
-
167
- /**
168
- * Get a list of action names and their corresponding dashicons.
169
- *
170
- * @since 2.2.6
171
- *
172
- * @return array List of actions and icons ([action] => [dashicon]).
173
- */
174
- public function get_actions_icons() {
175
-
176
- return array(
177
- 'edit' => 'edit',
178
- 'trash' => 'trash',
179
- 'delete' => 'trash',
180
- 'untrash' => 'undo',
181
- 'unspam' => 'undo',
182
- 'view' => 'visibility',
183
- 'inline' => 'welcome-write-blog',
184
- 'quickedit' => 'welcome-write-blog',
185
- 'approve' => 'yes',
186
- 'unapprove' => 'no',
187
- 'reply' => 'testimonial',
188
- 'trash' => 'trash',
189
- 'spam' => 'welcome-comments'
190
- );
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/ID.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_ID
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_ID extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-comment_id';
19
- $this->properties['label'] = __( 'ID', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- return $id;
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/actions.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Actions
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Actions extends CPAC_Column_Actions {
8
-
9
- /**
10
- * @see CPAC_Column_Actions::get_actions()
11
- * @since 2.3.4
12
- */
13
- public function get_actions( $id ) {
14
-
15
- global $post, $comment_status;
16
-
17
- $comment = get_comment( $id );
18
-
19
- // set uased vars
20
- $user_can = current_user_can( 'edit_comment', $comment->comment_ID );
21
- $the_comment_status = wp_get_comment_status( $comment->comment_ID );
22
-
23
- if ( $user_can ) {
24
- $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
25
- $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
26
-
27
- $url = "comment.php?c=$comment->comment_ID";
28
-
29
- $approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
30
- $unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
31
- $spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
32
- $unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
33
- $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
34
- $untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
35
- $delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
36
- }
37
-
38
- /** begin - copied from class-wp-comments-list-table */
39
- if ( $user_can ) {
40
- // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
41
- $actions = array(
42
- 'approve' => '', 'unapprove' => '',
43
- 'reply' => '',
44
- 'quickedit' => '',
45
- 'edit' => '',
46
- 'spam' => '', 'unspam' => '',
47
- 'trash' => '', 'untrash' => '', 'delete' => ''
48
- );
49
-
50
- if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
51
- if ( 'approved' == $the_comment_status )
52
- $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
53
- else if ( 'unapproved' == $the_comment_status )
54
- $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
55
- } else {
56
- $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
57
- $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
58
- }
59
-
60
- if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
61
- $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
62
- } elseif ( 'spam' == $the_comment_status ) {
63
- $actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
64
- } elseif ( 'trash' == $the_comment_status ) {
65
- $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
66
- }
67
-
68
- if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
69
- $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
70
- } else {
71
- $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
72
- }
73
-
74
- if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
75
- $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
76
- $actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
77
- $actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
78
- }
79
-
80
- $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
81
- $actions_copy = $actions;
82
- $actions = array();
83
-
84
- foreach ( $actions_copy as $action => $link ) {
85
- $action_append = '';
86
-
87
- // Reply and quickedit need a hide-if-no-js span when not added with ajax
88
- if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') ) {
89
- $action_append .= ' hide-if-no-js';
90
- }
91
- elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
92
- if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
93
- $action_append .= ' approve';
94
- }
95
- else {
96
- $action_append .= ' unapprove';
97
- }
98
- }
99
-
100
- $action .= $action_append;
101
- $actions[ $action ] = $link;
102
- }
103
- }
104
-
105
- return $actions;
106
- }
107
-
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/agent.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Agent
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Agent extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-agent';
19
- $this->properties['label'] = __( 'Agent', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- return $this->get_raw_value( $id );
28
- }
29
-
30
- /**
31
- * @since 2.4.2
32
- */
33
- public function get_raw_value( $id ) {
34
- $comment = get_comment( $id );
35
- return $comment->comment_agent;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/approved.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Comment_Approved
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Comment_Approved extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-approved';
20
- $this->properties['label'] = __( 'Approved', 'codepress-admin-columns' );
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.0
26
- */
27
- public function get_value( $id ) {
28
- return $this->get_raw_value( $id ) ? '<span class="dashicons dashicons-yes cpac_status_yes"></span>' : '<span class="dashicons dashicons-no cpac_status_no"></span>';;
29
- }
30
-
31
- /**
32
- * @since 2.4.2
33
- */
34
- public function get_raw_value( $id ) {
35
- $comment = get_comment( $id );
36
-
37
- return $comment->comment_approved;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author-avatar.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Author_Avatar
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Author_Avatar extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-author_avatar';
19
- $this->properties['label'] = __( 'Avatar', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- $comment = get_comment( $id );
29
- return get_avatar( $comment, 80 );
30
- }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author-email.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Author_Email
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Author_Email extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-author_email';
19
- $this->properties['label'] = __( 'Author email', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- $email = $this->get_raw_value( $id );
28
- return '<a href="' . $email . '">' . $email . '</a>';
29
- }
30
-
31
- /**
32
- * @since 2.4.2
33
- */
34
- public function get_raw_value( $id ) {
35
- $comment = get_comment( $id );
36
- return $comment->comment_author_email;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author-ip.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Author_Ip
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Author_Ip extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-author_ip';
19
- $this->properties['label'] = __( 'Author IP', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- return $this->get_raw_value( $id );
28
- }
29
-
30
- /**
31
- * @since 2.4.2
32
- */
33
- public function get_raw_value( $id ) {
34
- $comment = get_comment( $id );
35
- return $comment->comment_author_IP;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author-name.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- /**
3
- * @since 2.4.2
4
- */
5
- class CPAC_Column_Comment_Author_Name extends CPAC_Column {
6
-
7
- public function init() {
8
- parent::init();
9
-
10
- // Properties
11
- $this->properties['type'] = 'column-author_name';
12
- $this->properties['label'] = __( 'Author name', 'codepress-admin-columns' );
13
- }
14
-
15
- public function get_value( $id ) {
16
- return $this->get_raw_value( $id );
17
- }
18
-
19
- public function get_raw_value( $id ) {
20
- $comment = get_comment( $id );
21
- return $comment->comment_author;
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author-url.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Author_Url
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Author_Url extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-author_url';
19
- $this->properties['label'] = __( 'Author url', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- return $this->get_shorten_url( $this->get_raw_value( $id ) );
28
- }
29
-
30
- /**
31
- * @since 2.4.2
32
- */
33
- public function get_raw_value( $id ) {
34
- $comment = get_comment( $id );
35
- return $comment->comment_author_url;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/author.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Author
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Author extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-author';
19
- $this->properties['label'] = __( 'Author', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- return $this->get_raw_value( $id );
28
- }
29
-
30
- /**
31
- * @since 2.4.2
32
- */
33
- public function get_raw_value( $id ) {
34
- $comment = get_comment( $id );
35
- return $comment->comment_author;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/date-gmt.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Date_Gmt
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Date_Gmt extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-date_gmt';
19
- $this->properties['label'] = __( 'Date GMT', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- $date_gmt = $this->get_raw_value( $id );
29
-
30
- $value = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
31
- esc_url( get_comment_link( $id ) ),
32
- $this->get_date( $date_gmt ),
33
- $this->get_time( $date_gmt )
34
- );
35
-
36
- return "<div class='submitted-on'>{$value}</div>";
37
- }
38
-
39
- /**
40
- * @since 2.4.2
41
- */
42
- public function get_raw_value( $id ) {
43
- $comment = get_comment( $id );
44
- return $comment->comment_date_gmt;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/date.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Date
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Date extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-date';
19
- $this->properties['label'] = __( 'Date', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- $date = $this->get_raw_value( $id );
29
-
30
- $value = sprintf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ),
31
- esc_url( get_comment_link( $id ) ),
32
- $this->get_date( $date ),
33
- $this->get_time( $date )
34
- );
35
-
36
- return "<div class='submitted-on'>{$value}</div>";
37
- }
38
-
39
- /**
40
- * @since 2.4.2
41
- */
42
- public function get_raw_value( $id ) {
43
- $comment = get_comment( $id );
44
- return $comment->comment_date;
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/excerpt.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Excerpt
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Excerpt extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-excerpt';
19
- $this->properties['label'] = __( 'Content', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['excerpt_length'] = 15;
23
- }
24
-
25
- /**
26
- * @see CPAC_Column::get_value()
27
- * @since 2.0
28
- */
29
- public function get_value( $id ) {
30
- return $this->get_shortened_string( $this->get_raw_value( $id ), $this->get_option( 'excerpt_length' ) );
31
- }
32
-
33
- /**
34
- * @since 2.4.2
35
- */
36
- public function get_raw_value( $id ) {
37
- $comment = get_comment( $id );
38
- return $comment->comment_content;
39
- }
40
-
41
- /**
42
- * @see CPAC_Column::display_settings()
43
- * @since 2.0
44
- */
45
- public function display_settings() {
46
- $this->display_field_excerpt_length();
47
- }
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/post.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Post
4
- *
5
- * @since 2.4.7
6
- */
7
- class CPAC_Column_Comment_Post extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.4.7
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-post';
19
- $this->properties['label'] = __( 'Post', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['post_property_display'] = 'title';
23
- $this->options['post_link_to'] = 'edit_post';
24
- }
25
-
26
- /**
27
- * @see CPAC_Column::get_value()
28
- * @since 2.4.7
29
- */
30
- public function get_value( $id ) {
31
-
32
- $raw_value = $this->get_raw_value( $id );
33
-
34
- // Get page to link to
35
- switch ( $this->get_option( 'post_link_to' ) ) {
36
- case 'edit_post':
37
- $link = get_edit_post_link( $raw_value );
38
- break;
39
- case 'view_post':
40
- $link = get_permalink( $raw_value );
41
- break;
42
- case 'edit_author':
43
- $link = get_edit_user_link( get_post_field( 'post_author', $raw_value ) );
44
- break;
45
- case 'view_author':
46
- $link = get_author_posts_url( get_post_field( 'post_author', $raw_value ) );
47
- break;
48
- }
49
-
50
- // Get property of post to display
51
- switch ( $this->get_option( 'post_property_display' ) ) {
52
- case 'author':
53
- $label = get_the_author_meta( 'display_name', get_post_field( 'post_author', $raw_value ) );
54
- break;
55
- case 'id':
56
- $label = $raw_value;
57
- break;
58
- default:
59
- $label = get_the_title( $raw_value );
60
- break;
61
- }
62
-
63
- $value = $link ? "<a href='{$link}'>{$label}</a>" : $label;
64
-
65
- return $value;
66
- }
67
-
68
- /**
69
- * @see CPAC_Column::get_raw_value()
70
- * @since 2.4.7
71
- */
72
- public function get_raw_value( $id ) {
73
-
74
- $comment = get_comment( $id );
75
-
76
- return $comment->comment_post_ID;
77
- }
78
-
79
- /**
80
- * @see CPAC_Column::display_settings()
81
- * @since 2.4.7
82
- */
83
- public function display_settings() {
84
-
85
- $this->display_field_post_property_display();
86
- $this->display_field_post_link_to();
87
- }
88
-
89
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/reply-to.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Reply_To
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Reply_To extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-reply_to';
19
- $this->properties['label'] = __( 'In Reply To', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- $value = '';
28
- $parent = $this->get_raw_value( $id );
29
- if ( $parent ) {
30
- $parent = get_comment( $parent );
31
- $value = sprintf( '<a href="%1$s">%2$s</a>', esc_url( get_comment_link( $parent ) ), get_comment_author( $parent->comment_ID ) );
32
- }
33
-
34
- return $value;
35
- }
36
-
37
- /**
38
- * @since 2.4.2
39
- */
40
- public function get_raw_value( $id ) {
41
- $comment = get_comment( $id );
42
- return $comment->comment_parent;
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/type.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @since 2.4.2
5
- */
6
- class CPAC_Column_Comment_Type extends CPAC_Column {
7
-
8
- public function init() {
9
-
10
- parent::init();
11
-
12
- // Properties
13
- $this->properties['type'] = 'column-type';
14
- $this->properties['label'] = __( 'Type', 'codepress-admin-columns' );
15
- }
16
-
17
- public function get_value( $id ) {
18
- return $this->get_raw_value( $id );
19
- }
20
-
21
- public function get_raw_value( $id ) {
22
- $comment = get_comment( $id );
23
-
24
- return $comment->comment_type;
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/user.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * @since 2.4.2
4
- */
5
- class CPAC_Column_Comment_User extends CPAC_Column {
6
-
7
- public function init() {
8
- parent::init();
9
-
10
- $this->properties['type'] = 'column-user';
11
- $this->properties['label'] = __( 'User', 'codepress-admin-columns' );
12
- }
13
-
14
- public function get_value( $id ) {
15
- $user_id = $this->get_raw_value( $id );
16
-
17
- if ( ! $user_id ) {
18
- return false;
19
- }
20
-
21
- $display_name = $this->get_display_name( $user_id );
22
- if ( $edit_link = get_edit_profile_url( $user_id ) ) {
23
- $display_name = '<a href="' . $edit_link . ' ">' . $display_name . '</a>';
24
- }
25
- return $display_name;
26
- }
27
-
28
- public function get_raw_value( $id ) {
29
- $comment = get_comment( $id );
30
- return $comment->user_id;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/comment/word-count.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Comment_Wordcount
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Comment_Word_Count extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-word_count';
19
- $this->properties['label'] = __( 'Word count', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- $comment = get_comment( $id );
29
-
30
- return str_word_count( $this->strip_trim( $comment->comment_content ) );
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/custom-field.php DELETED
@@ -1,410 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Custom field column, displaying the contents of meta fields.
5
- * Suited for all storage models supporting WordPress' default way of handling meta data.
6
- *
7
- * Supports different types of meta fields, including dates, serialized data, linked content,
8
- * and boolean values.
9
- *
10
- * @since 1.0
11
- */
12
- class CPAC_Column_Custom_Field extends CPAC_Column {
13
-
14
- /**
15
- * @see CPAC_Column::init()
16
- * @since 2.2.1
17
- */
18
- public function init() {
19
-
20
- parent::init();
21
-
22
- // Properties
23
- $this->properties['type'] = 'column-meta';
24
- $this->properties['label'] = __( 'Custom Field', 'codepress-admin-columns' );
25
- $this->properties['classes'] = 'cpac-box-metafield';
26
- $this->properties['group'] = __( 'Custom Field', 'codepress-admin-columns' );
27
- $this->properties['use_before_after'] = true;
28
-
29
- // Options
30
- $this->options['field'] = '';
31
- $this->options['field_type'] = '';
32
- $this->options['before'] = '';
33
- $this->options['after'] = '';
34
-
35
- $this->options['image_size'] = '';
36
- $this->options['image_size_w'] = 80;
37
- $this->options['image_size_h'] = 80;
38
-
39
- $this->options['excerpt_length'] = 15;
40
-
41
- $this->options['link_label'] = '';
42
-
43
- $this->options['date_format'] = '';
44
- }
45
-
46
- /**
47
- * @since 3.2.1
48
- */
49
- public function is_field_type( $type ) {
50
- return $type === $this->get_field_type();
51
- }
52
-
53
- /**
54
- * @since 3.2.1
55
- */
56
- public function is_field( $field ) {
57
- return $field === $this->get_field();
58
- }
59
-
60
- /**
61
- * @since 3.2.1
62
- */
63
- public function get_field_type() {
64
- return $this->get_option( 'field_type' );
65
- }
66
-
67
- /**
68
- * @since 3.2.1
69
- */
70
- public function get_field() {
71
- return $this->get_field_key();
72
- }
73
-
74
- /**
75
- * @see CPAC_Column::sanitize_options()
76
- * @since 1.0
77
- */
78
- public function sanitize_options( $options ) {
79
-
80
- if ( empty( $options['date_format'] ) ) {
81
- $options['date_format'] = get_option( 'date_format' );
82
- }
83
-
84
- return $options;
85
- }
86
-
87
- /**
88
- * Get Custom FieldType Options - Value method
89
- *
90
- * @since 1.0
91
- *
92
- * @return array Customfield types.
93
- */
94
- public function get_custom_field_types() {
95
-
96
- $custom_field_types = array(
97
- '' => __( 'Default', 'codepress-admin-columns' ),
98
- 'checkmark' => __( 'Checkmark (true/false)', 'codepress-admin-columns' ),
99
- 'color' => __( 'Color', 'codepress-admin-columns' ),
100
- 'count' => __( 'Counter', 'codepress-admin-columns' ),
101
- 'date' => __( 'Date', 'codepress-admin-columns' ),
102
- 'excerpt' => __( 'Excerpt' ),
103
- 'image' => __( 'Image', 'codepress-admin-columns' ),
104
- 'library_id' => __( 'Media Library', 'codepress-admin-columns' ),
105
- 'link' => __( 'Url', 'codepress-admin-columns' ),
106
- 'array' => __( 'Multiple Values', 'codepress-admin-columns' ),
107
- 'numeric' => __( 'Numeric', 'codepress-admin-columns' ),
108
- 'title_by_id' => __( 'Post Title (Post ID\'s)', 'codepress-admin-columns' ),
109
- 'user_by_id' => __( 'Username (User ID\'s)', 'codepress-admin-columns' ),
110
- 'term_by_id' => __( 'Term Name (Term ID\'s)', 'codepress-admin-columns' ),
111
- );
112
-
113
- // deprecated. do not use, will be removed.
114
- $custom_field_types = apply_filters( 'cpac_custom_field_types', $custom_field_types );
115
-
116
- /**
117
- * Filter the available custom field types for the meta (custom field) field
118
- *
119
- * @since 2.0
120
- *
121
- * @param array $custom_field_types Available custom field types ([type] => [label])
122
- */
123
- $custom_field_types = apply_filters( 'cac/column/meta/types', $custom_field_types );
124
-
125
- asort( $custom_field_types );
126
-
127
- return $custom_field_types;
128
- }
129
-
130
- /**
131
- * Get First ID from array
132
- *
133
- * @since 1.0
134
- *
135
- * @param string $meta
136
- *
137
- * @return string Titles
138
- */
139
- public function get_ids_from_meta( $meta ) {
140
-
141
- //remove white spaces and strip tags
142
- $meta = $this->strip_trim( str_replace( ' ', '', $meta ) );
143
-
144
- $ids = array();
145
-
146
- // check for multiple id's
147
- if ( strpos( $meta, ',' ) !== false ) {
148
- $ids = explode( ',', $meta );
149
- }
150
- elseif ( is_numeric( $meta ) ) {
151
- $ids[] = $meta;
152
- }
153
-
154
- return $ids;
155
- }
156
-
157
- /**
158
- * Get Field key
159
- *
160
- * @since 2.0.3
161
- *
162
- * @param string Custom Field Key
163
- */
164
- public function get_field_key() {
165
- $field = $this->get_option( 'field' );
166
-
167
- return substr( $field, 0, 10 ) == "cpachidden" ? str_replace( 'cpachidden', '', $field ) : $field;
168
- }
169
-
170
- /**
171
- * Get meta by ID
172
- *
173
- * @since 1.0
174
- *
175
- * @param int $id ID
176
- *
177
- * @deprecated
178
- * @return string Meta Value
179
- */
180
- public function get_meta_by_id( $id ) {
181
- _deprecated_function( __CLASS__ . '::' . __FUNCTION__ . '()', '2.5.6', __CLASS__ . '::' . 'recursive_implode()' );
182
-
183
- return $this->recursive_implode( ', ', $this->get_raw_value( $id ) );
184
- }
185
-
186
- /**
187
- * @see CPAC_Column::get_raw_value()
188
- * @since 2.0.3
189
- */
190
- public function get_raw_value( $id, $single = true ) {
191
- $raw_value = '';
192
-
193
- if ( $field_key = $this->get_field_key() ) {
194
- $raw_value = get_metadata( $this->get_meta_type(), $id, $field_key, $single );
195
- }
196
-
197
- return apply_filters( 'cac/column/meta/raw_value', $raw_value, $id, $field_key, $this );
198
- }
199
-
200
- /**
201
- * @since 2.5.6
202
- */
203
- public function get_username_by_id( $user_id ) {
204
- $username = false;
205
- if ( $user_id && is_numeric( $user_id ) && ( $userdata = get_userdata( $user_id ) ) ) {
206
- $username = $userdata->display_name;
207
- }
208
-
209
- return $username;
210
- }
211
-
212
- /**
213
- * @since 2.5.6
214
- */
215
- public function get_date_by_string( $date_string ) {
216
- return $this->get_date( $date_string, $this->get_option( 'date_format' ) );
217
- }
218
-
219
- /**
220
- * @see CPAC_Column::get_value()
221
- * @since 1.0
222
- */
223
- public function get_value( $id ) {
224
-
225
- $value = '';
226
-
227
- $raw_value = $this->get_raw_value( $id );
228
- $raw_string = $this->recursive_implode( ', ', $raw_value );
229
-
230
- switch ( $this->get_option( 'field_type' ) ) :
231
- case "image" :
232
- case "library_id" :
233
- $value = implode( $this->get_thumbnails( $raw_string, array(
234
- 'image_size' => $this->get_option( 'image_size' ),
235
- 'image_size_w' => $this->get_option( 'image_size_w' ),
236
- 'image_size_h' => $this->get_option( 'image_size_h' ),
237
- ) ) );
238
- break;
239
-
240
- case "excerpt" :
241
- $value = $this->get_shortened_string( $raw_value, $this->get_option( 'excerpt_length' ) );
242
- break;
243
-
244
- case "date" :
245
- $value = $this->get_date_by_string( $raw_value );
246
- break;
247
-
248
- case "link" :
249
- if ( filter_var( $raw_value, FILTER_VALIDATE_URL ) || preg_match( '/[^\w.-]/', $raw_value ) ) {
250
- $label = $this->get_option( 'link_label' );
251
- if ( ! $label ) {
252
- $label = $raw_value;
253
- }
254
- $value = '<a href="' . $raw_value . '">' . $label . '</a>';
255
- }
256
- break;
257
-
258
- case "title_by_id" :
259
- $titles = array();
260
- if ( $ids = $this->get_ids_from_meta( $raw_string ) ) {
261
- foreach ( (array) $ids as $id ) {
262
- if ( $title = $this->get_post_title( $id ) ) {
263
- $link = get_edit_post_link( $id );
264
- $titles[] = $link ? "<a href='{$link}'>{$title}</a>" : $title;
265
- }
266
- }
267
- }
268
- $value = implode( '<span class="cpac-divider"></span>', $titles );
269
- break;
270
-
271
- case "user_by_id" :
272
- $names = array();
273
- if ( $ids = $this->get_ids_from_meta( $raw_string ) ) {
274
- foreach ( (array) $ids as $id ) {
275
- if ( $username = $this->get_username_by_id( $id ) ) {
276
- $link = get_edit_user_link( $id );
277
- $names[] = $link ? "<a href='{$link}'>{$username}</a>" : $username;
278
- }
279
- }
280
- }
281
- $value = implode( '<span class="cpac-divider"></span>', $names );
282
- break;
283
-
284
- case "term_by_id" :
285
- if ( is_array( $raw_value ) && isset( $raw_value['term_id'] ) && isset( $raw_value['taxonomy'] ) ) {
286
- $value = $this->get_terms_for_display( $raw_value['term_id'], $raw_value['taxonomy'] );
287
- }
288
- break;
289
-
290
- case "checkmark" :
291
- $value = ( empty( $raw_value ) || 'false' === $raw_value || '0' === $raw_value ) ? '<span class="dashicons dashicons-no cpac_status_no"></span>' : '<span class="dashicons dashicons-yes cpac_status_yes"></span>';
292
- break;
293
-
294
- case "color" :
295
- $value = $raw_value && is_scalar( $raw_value ) ? $this->get_color_for_display( $raw_value ) : $this->get_empty_char();
296
- break;
297
-
298
- case "count" :
299
- $value = $raw_value ? count( $raw_value ) : $this->get_empty_char();
300
- break;
301
-
302
- default :
303
- $value = $raw_string;
304
-
305
- endswitch;
306
-
307
- /**
308
- * Filter the display value for Custom Field columns
309
- *
310
- * @param mixed $value Custom field value
311
- * @param int $id Object ID
312
- * @param object $this Column instance
313
- */
314
- $value = apply_filters( 'cac/column/meta/value', $value, $id, $this );
315
-
316
- return $value;
317
- }
318
-
319
- /**
320
- * @since 2.4.7
321
- */
322
- public function get_meta_keys() {
323
- return $this->get_storage_model()->get_meta_keys();
324
- }
325
-
326
- public function get_meta_keys_list() {
327
- $list = false;
328
-
329
- if ( $keys = $this->get_meta_keys() ) {
330
- $lists = array();
331
- foreach ( $keys as $field ) {
332
- if ( substr( $field, 0, 10 ) == "cpachidden" ) {
333
- $lists['hidden'][] = $field;
334
- }
335
- else {
336
- $lists['public'][] = $field;
337
- }
338
- }
339
- krsort( $lists ); // public first
340
-
341
- $list = '<select name="' . $this->get_attr_name( 'field' ) . '" id="' . $this->get_attr_id( 'field' ) . '">';
342
- foreach ( $lists as $type => $fields ) {
343
- $list .= "<optgroup label='" . ( 'hidden' == $type ? __( 'Hidden Custom Fields', 'codepress-admin-columns' ) : __( 'Custom Fields', 'codepress-admin-columns' ) ) . "'>";
344
- foreach ( $fields as $field ) {
345
- $list .= "<option value='{$field}'" . selected( $field, $this->get_option( 'field' ), false ) . ">" . str_replace( 'cpachidden', '', $field ) . "</option>";
346
- }
347
- $list .= "</optgroup>";
348
- }
349
- $list .= '</select>';
350
- }
351
-
352
- return $list;
353
- }
354
-
355
- /**
356
- * @see CPAC_Column::display_settings()
357
- * @since 1.0
358
- */
359
- public function display_settings() {
360
-
361
- // DOM can get overloaded when dropdown contains to many custom fields. Use this filter to replace the dropdown with a text input.
362
- if ( apply_filters( 'cac/column/meta/use_text_input', false ) ) :
363
- $this->display_field_text( 'field', __( "Custom Field", 'codepress-admin-columns' ), __( "Enter your custom field key.", 'codepress-admin-columns' ) );
364
- else :
365
- ?>
366
- <tr class="column_field">
367
- <?php $this->label_view( __( "Custom Field", 'codepress-admin-columns' ), __( "Select your custom field.", 'codepress-admin-columns' ), 'field' ); ?>
368
- <td class="input">
369
- <?php
370
- if ( $list = $this->get_meta_keys_list() ) {
371
- echo $list;
372
- }
373
- else {
374
- _e( 'No custom fields available.', 'codepress-admin-columns' ); ?><?php printf( __( 'Please create a %s item first.', 'codepress-admin-columns' ), '<strong>' . $this->get_storage_model()->singular_label . '</strong>' );
375
- }
376
- ?>
377
- </td>
378
- </tr>
379
- <?php endif; ?>
380
-
381
- <tr class="column_field_type" data-refresh="1">
382
- <?php $this->label_view( __( "Field Type", 'codepress-admin-columns' ), __( 'This will determine how the value will be displayed.', 'codepress-admin-columns' ) . '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->get_option( 'field_type' ) . '</em>', 'field_type' ); ?>
383
- <td class="input">
384
- <select name="<?php $this->attr_name( 'field_type' ); ?>" id="<?php $this->attr_id( 'field_type' ); ?>">
385
- <?php foreach ( $this->get_custom_field_types() as $fieldkey => $fieldtype ) : ?>
386
- <option
387
- value="<?php echo $fieldkey ?>"<?php selected( $fieldkey, $this->get_option( 'field_type' ) ) ?>><?php echo $fieldtype; ?></option>
388
- <?php endforeach; ?>
389
- </select>
390
- </td>
391
- </tr>
392
-
393
- <?php
394
- switch ( $this->get_option( 'field_type' ) ) {
395
- case 'date':
396
- $this->display_field_date_format();
397
- break;
398
- case 'image':
399
- case 'library_id':
400
- $this->display_field_preview_size();
401
- break;
402
- case 'excerpt':
403
- $this->display_field_excerpt_length();
404
- break;
405
- case 'link':
406
- $this->display_field_link_label();
407
- break;
408
- }
409
- }
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/default.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Column class for default columns (i.e. columns not added by Admin Columns).
4
- * Allows additional properties, such as editability and filterability, to be
5
- * added to default column types.
6
- *
7
- * @since 2.2.1
8
- */
9
- class CPAC_Column_Default extends CPAC_Column {
10
-
11
- /**
12
- * @see CPAC_Column::init()
13
- * @since 2.2.1
14
- */
15
- public function init() {
16
-
17
- parent::init();
18
-
19
- // Properties
20
- $this->properties['type'] = 'column-default';
21
- $this->properties['handle'] = NULL;
22
- $this->properties['group'] = __( 'Default', 'codepress-admin-columns' );
23
- $this->properties['original'] = true;
24
- }
25
-
26
- /**
27
- * @since 2.2.1
28
- * @see CPAC_Column::get_value()
29
- */
30
- public function get_value( $post_id ) {
31
- if ( ! empty( $this->properties->handle ) ) {
32
- return $this->get_storage_model()->get_original_column_value( $this->properties->handle, $post_id );
33
- }
34
-
35
- return '';
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/ID.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_ID
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_ID extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-link_id';
19
- $this->properties['label'] = __( 'ID', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- return $id;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/description.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Description
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Description extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-description';
19
- $this->properties['label'] = __( 'Description', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- return $bookmark->link_description;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/image.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Image
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Image extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-image';
19
- $this->properties['label'] = __( 'Image', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['image_size'] = '';
23
- $this->options['image_size_w'] = 80;
24
- $this->options['image_size_h'] = 80;
25
- }
26
-
27
- /**
28
- * @see CPAC_Column::get_value()
29
- * @since 2.0
30
- */
31
- function get_value( $id ) {
32
-
33
- $bookmark = get_bookmark( $id );
34
-
35
- return implode( $this->get_thumbnails( $bookmark->link_image ) );
36
- }
37
-
38
- /**
39
- * @see CPAC_Column::display_settings()
40
- * @since 2.0
41
- */
42
- function display_settings() {
43
-
44
- $this->display_field_preview_size();
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/length.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Length
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Length extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-length';
19
- $this->properties['label'] = __( 'Length', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- return strlen( $bookmark->link_name );
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/notes.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Notes
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Notes extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-notes';
19
- $this->properties['label'] = __( 'Notes', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['excerpt_length'] = 30;
23
- }
24
-
25
- /**
26
- * @see CPAC_Column::get_value()
27
- * @since 2.0
28
- */
29
- function get_value( $id ) {
30
-
31
- $bookmark = get_bookmark( $id );
32
-
33
- return $this->get_shortened_string( $bookmark->link_notes, $this->get_option( 'excerpt_length' ) );
34
- }
35
-
36
- /**
37
- * @see CPAC_Column::display_settings()
38
- * @since 2.0
39
- */
40
- function display_settings() {
41
-
42
- $this->display_field_excerpt_length();
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/owner.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Owner
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Owner extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-owner';
19
- $this->properties['label'] = __( 'Owner', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- $value = $bookmark->link_owner;
31
-
32
- // add user link
33
- $userdata = get_userdata( $bookmark->link_owner );
34
- if ( ! empty( $userdata->data ) ) {
35
- $value = $userdata->data->user_nicename;
36
- }
37
-
38
- return $value;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/rss.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Rss
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Rss extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-rss';
19
- $this->properties['label'] = __( 'Rss', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- return $this->get_shorten_url( $bookmark->link_rss );
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/link/target.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Link_Target
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Link_Target extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-target';
19
- $this->properties['label'] = __( 'Target', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $bookmark = get_bookmark( $id );
29
-
30
- return $bookmark->link_target;
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/ID.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_ID
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_ID extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-mediaid';
19
- $this->properties['label'] = __( 'ID', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $media_id ) {
27
-
28
- return $media_id;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/actions.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Actions
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Actions extends CPAC_Column_Actions {
9
-
10
- /**
11
- * @see CPAC_Column_Actions::get_actions()
12
- * @since 2.3.4
13
- */
14
- public function get_actions( $id ) {
15
-
16
- global $wp_list_table;
17
-
18
- if ( ! $wp_list_table ) {
19
- return;
20
- }
21
-
22
- $post = get_post( $id );
23
- $att_title = _draft_or_post_title( $id );
24
-
25
- $actions = array();
26
-
27
- if ( $wp_list_table->detached ) {
28
- if ( current_user_can( 'edit_post', $post->ID ) )
29
- $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
30
- if ( current_user_can( 'delete_post', $post->ID ) )
31
- if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
32
- $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
33
- } else {
34
- $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
35
- $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
36
- }
37
- $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
38
- if ( current_user_can( 'edit_post', $post->ID ) )
39
- $actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>';
40
- }
41
- else {
42
- if ( current_user_can( 'edit_post', $post->ID ) && !$wp_list_table->is_trash )
43
- $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
44
- if ( current_user_can( 'delete_post', $post->ID ) ) {
45
- if ( $wp_list_table->is_trash )
46
- $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
47
- elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
48
- $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
49
- if ( $wp_list_table->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
50
- $delete_ays = ( !$wp_list_table->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
51
- $actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
52
- }
53
- }
54
- if ( !$wp_list_table->is_trash ) {
55
- $title =_draft_or_post_title( $post->post_parent );
56
- $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
57
- }
58
- }
59
-
60
- /**
61
- * Filter the action links for each attachment in the Media list table.
62
- *
63
- * @since 2.8.0
64
- *
65
- * @param array $actions An array of action links for each attachment.
66
- * Default 'Edit', 'Delete Permanently', 'View'.
67
- * @param WP_Post $post WP_Post object for the current attachment.
68
- * @param bool $detached Whether the list table contains media not attached
69
- * to any posts. Default true.
70
- */
71
- $actions = apply_filters( 'media_row_actions', $actions, $post, $wp_list_table->detached );
72
-
73
- return $actions;
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/alternate-text.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_Alternate_Text
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_Alternate_Text extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-alternate_text';
19
- $this->properties['label'] = __( 'Alt', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- return $this->strip_trim( $this->get_raw_value( $id ) );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.3.2
34
- */
35
- public function get_raw_value( $id ) {
36
-
37
- return get_post_meta( $id, '_wp_attachment_image_alt', true );
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/attached-to.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Attached_To
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Attached_To extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-attached_to';
19
- $this->properties['label'] = __( 'Attached to post', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
- $value = false;
28
- if ( $attached_to = $this->get_raw_value() ) {
29
- $value = get_the_title( $attached_to );
30
- if ( $edit_link = get_edit_post_link( $id ) ) {
31
- $value = '<a href="' . $edit_link . '">' . $value . '</a>';
32
- }
33
- }
34
- return $value;
35
- }
36
-
37
- /**
38
- * @see CPAC_Column::get_value()
39
- * @since 2.0
40
- */
41
- public function get_raw_value( $id ) {
42
- return get_post_field( $id, 'post_parent' );
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/available-sizes.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Available_Sizes
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Available_Sizes extends CPAC_Column {
9
-
10
- public function init() {
11
- parent::init();
12
-
13
- $this->properties['type'] = 'column-available_sizes';
14
- $this->properties['label'] = __( 'Available Sizes', 'codepress-admin-columns' );
15
- }
16
-
17
- function get_value( $id ) {
18
- $paths = array();
19
-
20
- $meta = get_post_meta( $id, '_wp_attachment_metadata', true );
21
-
22
- if ( ! isset( $meta['sizes'] ) ) {
23
- return $this->get_empty_char();
24
- }
25
-
26
- // available sizes
27
- if ( $intersect = array_intersect( array_keys( $meta['sizes'] ), get_intermediate_image_sizes() ) ) {
28
-
29
- $url = wp_get_attachment_url( $id );
30
- $filename = basename( $url );
31
- $paths[] = "<a title='{$filename}' href='{$url}'>" . __( 'full size', 'codepress-admin-columns' ) . "</a>";
32
-
33
- foreach ( $intersect as $size ) {
34
- $src = wp_get_attachment_image_src( $id, $size );
35
-
36
- if ( ! empty( $src[0] ) ) {
37
- $filename = basename( $src[0] );
38
- $paths[] = "<a title='{$filename}' href='{$src[0]}' class='available'>{$size}</a>";
39
- }
40
- }
41
- }
42
-
43
- global $_wp_additional_image_sizes;
44
-
45
- if ( ! empty( $_wp_additional_image_sizes ) ) {
46
- if ( isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) {
47
- unset( $_wp_additional_image_sizes['post-thumbnail'] );
48
- }
49
-
50
- // image does not have these additional sizes rendered yet
51
- if ( $missing = array_diff( array_keys( $_wp_additional_image_sizes ), array_keys( $meta['sizes'] ) ) ) {
52
- foreach ( $missing as $size ) {
53
- $paths[] = "<span title='Missing size: Try regenerate thumbnails with the plugin: Force Regenerate Thumbnails' href='javascript:;' class='not-available'>{$size}</span>";
54
- }
55
- }
56
- }
57
-
58
- return "<div class='sizes'>" . implode( '<span class="cpac-divider"></span>', $paths ) . "</div>";
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/caption.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_Caption
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_Caption extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-caption';
19
- $this->properties['label'] = __( 'Caption', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- return $this->get_raw_value( $id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.3.2
34
- */
35
- public function get_raw_value( $id ) {
36
-
37
- return get_post_field( 'post_excerpt', $id );
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/description.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Description
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Description extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-description';
20
- $this->properties['label'] = __( 'Description', 'codepress-admin-columns' );
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.0
26
- */
27
- public function get_value( $id ) {
28
- return $this->get_raw_value( $id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.3.2
34
- */
35
- public function get_raw_value( $id ) {
36
- return get_post_field( 'post_content', $id );
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/dimensions.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Dimensions
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Dimensions extends CPAC_Column {
9
-
10
- public function init() {
11
- parent::init();
12
-
13
- $this->properties['type'] = 'column-dimensions';
14
- $this->properties['label'] = __( 'Dimensions', 'codepress-admin-columns' );
15
- }
16
-
17
- public function get_value( $id ) {
18
- $value = $this->get_empty_char();
19
-
20
- $meta = $this->get_raw_value( $id );
21
-
22
- if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
23
- $value = "{$meta['width']} x {$meta['height']}";
24
- }
25
-
26
- return $value;
27
- }
28
-
29
- public function get_raw_value( $id ) {
30
- return get_post_meta( $id, '_wp_attachment_metadata', true );
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/exif-data.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_File_Size
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Exif_Data extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-exif_data';
20
- $this->properties['label'] = __( 'EXIF data', 'codepress-admin-columns' );
21
- $this->properties['is_cloneable'] = true;
22
-
23
- // Options
24
- $this->options['exif_datatype'] = '';
25
- }
26
-
27
- /**
28
- * Get EXIF data
29
- *
30
- * Get extended image metadata
31
- *
32
- * @since 2.0
33
- *
34
- * @return array EXIF data types
35
- */
36
- private function get_exif_types() {
37
-
38
- $exif_types = array(
39
- 'aperture' => __( 'Aperture', 'codepress-admin-columns' ),
40
- 'credit' => __( 'Credit', 'codepress-admin-columns' ),
41
- 'camera' => __( 'Camera', 'codepress-admin-columns' ),
42
- 'caption' => __( 'Caption', 'codepress-admin-columns' ),
43
- 'created_timestamp' => __( 'Timestamp', 'codepress-admin-columns' ),
44
- 'copyright' => __( 'Copyright EXIF', 'codepress-admin-columns' ),
45
- 'focal_length' => __( 'Focal Length', 'codepress-admin-columns' ),
46
- 'iso' => __( 'ISO', 'codepress-admin-columns' ),
47
- 'shutter_speed' => __( 'Shutter Speed', 'codepress-admin-columns' ),
48
- 'title' => __( 'Title', 'codepress-admin-columns' ),
49
- );
50
-
51
- return $exif_types;
52
- }
53
-
54
- /**
55
- * @see CPAC_Column::get_value()
56
- * @since 2.0
57
- */
58
- public function get_value( $id ) {
59
-
60
- $value = '';
61
-
62
- $data = $this->get_option( 'exif_datatype' );
63
- $meta = $this->get_raw_value( $id );
64
-
65
- if ( isset( $meta['image_meta'][ $data ] ) ) {
66
- $value = $meta['image_meta'][ $data ];
67
-
68
- if ( 'created_timestamp' == $data ) {
69
- $value = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $value ) );
70
- }
71
- }
72
- if ( empty( $value ) ) {
73
- $value = $this->get_empty_char();
74
- }
75
-
76
- return $value;
77
- }
78
-
79
- public function get_raw_value( $id ) {
80
- return get_post_meta( $id, '_wp_attachment_metadata', true );
81
- }
82
-
83
- public function apply_conditional() {
84
- return function_exists( 'exif_read_data' );
85
- }
86
-
87
- public function display_settings() { ?>
88
- <tr class="column-exif-data">
89
- <?php $this->label_view( $this->properties->label, '', 'exif_datatype' ); ?>
90
- <td class="input">
91
- <select name="<?php $this->attr_name( 'exif_datatype' ); ?>" id="<?php $this->attr_id( 'exif_datatype' ); ?>">
92
- <?php foreach ( $this->get_exif_types() as $key => $label ) : ?>
93
- <option value="<?php echo $key; ?>"<?php selected( $key, $this->get_option( 'exif_datatype' ) ); ?>><?php echo $label; ?></option>
94
- <?php endforeach; ?>
95
- </select>
96
- </td>
97
- </tr>
98
- <?php
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/file-name.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_File_Name
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_File_Name extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-file_name';
19
- $this->properties['label'] = __( 'File name', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- $file = wp_get_attachment_url( $id );
29
- $filename = $this->get_raw_value( $id );
30
-
31
- return "<a title='{$filename}' href='{$file}'>{$filename}</a>";
32
- }
33
-
34
- /**
35
- * @see CPAC_Column::get_value()
36
- * @since 2.0
37
- */
38
- public function get_raw_value( $id ) {
39
-
40
- $file = wp_get_attachment_url( $id );
41
-
42
- return basename( $file );
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/file-size.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_File_Size
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_File_Size extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-file_size';
19
- $this->properties['label'] = __( 'File size', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $id ) {
27
-
28
- $value = '';
29
-
30
- $file = wp_get_attachment_url( $id );
31
- $abs = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file );
32
-
33
- if ( file_exists( $abs ) ) {
34
- $value = $this->get_readable_filesize( filesize( $abs ) );
35
- }
36
-
37
- return $value;
38
- }
39
-
40
- /**
41
- * Convert file size to readable format
42
- *
43
- * @since 1.4.5
44
- *
45
- * @param string $size
46
- * @return string Readable filesize
47
- */
48
- function get_readable_filesize( $size ) {
49
- $filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
50
- return $size ? round( $size/pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2) . $filesizename[$i] : '0 Bytes';
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/full-path.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Full_Path
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Full_Path extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-full_path';
20
- $this->properties['label'] = __( 'Full path', 'codepress-admin-columns' );
21
-
22
- // Options
23
- $this->options['path_scope'] = 'full';
24
- }
25
-
26
- private function get_pathscope() {
27
- return $this->get_option( 'path_scope' );
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_value()
32
- * @since 2.0
33
- */
34
- function get_value( $id ) {
35
-
36
- $value = '';
37
-
38
- if ( $file = wp_get_attachment_url( $id ) ) {
39
- switch ( $this->get_pathscope() ) {
40
- case 'relative-domain':
41
- $file = str_replace( 'https://', 'http://', $file );
42
- $url = str_replace( 'https://', 'http://', home_url( '/' ) );
43
-
44
- if ( strpos( $file, $url ) === 0 ) {
45
- $file = '/' . substr( $file, strlen( $url ) );
46
- }
47
-
48
- break;
49
- case 'relative-uploads':
50
- $uploaddir = wp_upload_dir();
51
- $file = str_replace( 'https://', 'http://', $file );
52
- $url = str_replace( 'https://', 'http://', $uploaddir['baseurl'] );
53
-
54
- if ( strpos( $file, $url ) === 0 ) {
55
- $file = substr( $file, strlen( $url ) );
56
- }
57
-
58
- break;
59
- }
60
-
61
- $value = $file;
62
- }
63
-
64
- return $value;
65
- }
66
-
67
- /**
68
- *
69
- *
70
- * @see CPAC_Column::display_settings()
71
- * @since 2.3.4
72
- */
73
- public function display_settings() {
74
- $this->display_field_path_scope();
75
- }
76
-
77
- /**
78
- *
79
- *
80
- * @since 2.3.4
81
- */
82
- public function display_field_path_scope() {
83
-
84
- $field_key = 'path_scope';
85
- $label = __( 'Path scope', 'codepress-admin-columns' );
86
- $description = __( 'Part of the file path to display', 'codepress-admin-columns' );
87
-
88
- ?>
89
- <tr class="column_<?php echo $field_key; ?>">
90
- <?php $this->label_view( $label, $description, $field_key ); ?>
91
- <td class="input">
92
- <label for="<?php $this->attr_id( $field_key ); ?>-full">
93
- <input type="radio" value="full" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-full"<?php checked( $this->get_pathscope(), 'full' ); ?> />
94
- <?php _e( 'Full path', 'codepress-admin-columns' ); ?>
95
- </label>
96
- <br/>
97
- <label for="<?php $this->attr_id( $field_key ); ?>-relative-domain">
98
- <input type="radio" value="relative-domain" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-relative-domain"<?php checked( $this->get_pathscope(), 'relative-domain' ); ?> />
99
- <?php _e( 'Relative to domain', 'codepress-admin-columns' ); ?>
100
- </label>
101
- <br/>
102
- <label for="<?php $this->attr_id( $field_key ); ?>-relative-uploads">
103
- <input type="radio" value="relative-uploads" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-relative-uploads"<?php checked( $this->get_pathscope(), 'relative-uploads' ); ?> />
104
- <?php _e( 'Relative to main uploads folder ', 'codepress-admin-columns' ); ?>
105
- </label>
106
- </td>
107
- </tr>
108
- <?php
109
- }
110
-
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/height.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Media_Height
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Media_Height extends CPAC_Column {
9
-
10
- public function init() {
11
- parent::init();
12
-
13
- $this->properties['type'] = 'column-height';
14
- $this->properties['label'] = __( 'Height', 'codepress-admin-columns' );
15
- }
16
-
17
- function get_value( $id ) {
18
- $value = $this->get_raw_value( $id );
19
-
20
- return $value ? $value . 'px' : $this->get_empty_char();
21
- }
22
-
23
- function get_raw_value( $id ) {
24
- $meta = get_post_meta( $id, '_wp_attachment_metadata', true );
25
-
26
- return ! empty( $meta['height'] ) ? $meta['height'] : false;
27
- }
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/mime-type.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_Mime_Type
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_Mime_Type extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-mime_type';
19
- $this->properties['label'] = __( 'Mime type', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $id ) {
27
-
28
- return $this->get_raw_value( $id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.3.2
34
- */
35
- public function get_raw_value( $id ) {
36
-
37
- return get_post_field( 'post_mime_type', $id );
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/media/width.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Media_Width
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Media_Width extends CPAC_Column {
8
-
9
- public function init() {
10
- parent::init();
11
-
12
- $this->properties['type'] = 'column-width';
13
- $this->properties['label'] = __( 'Width', 'codepress-admin-columns' );
14
- }
15
-
16
- function get_value( $id ) {
17
- $value = $this->get_raw_value( $id );
18
-
19
- return $value ? $value . 'px' : $this->get_empty_char();
20
- }
21
-
22
- function get_raw_value( $id ) {
23
- $meta = get_post_meta( $id, '_wp_attachment_metadata', true );
24
-
25
- return ! empty( $meta['width'] ) ? $meta['width'] : false;
26
- }
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/ID.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_ID
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_ID extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-postid';
19
- $this->properties['label'] = __( 'ID', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $post_id ) {
27
- return $this->get_raw_value( $post_id );
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_value()
32
- * @since 2.0.3
33
- */
34
- function get_raw_value( $post_id ) {
35
- return $post_id;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/actions.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Actions
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Actions extends CPAC_Column_Actions {
9
-
10
- /**
11
- * @see CPAC_Column_Actions::get_actions()
12
- * @since 2.2.6
13
- */
14
- public function get_actions( $item_id ) {
15
-
16
- $actions = array();
17
-
18
- $post = get_post( $item_id );
19
- $title = _draft_or_post_title();
20
- $post_type_object = get_post_type_object( $post->post_type );
21
- $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
22
- $quickedit_enabled = false;
23
-
24
- $stored_columns = $this->get_storage_model()->get_stored_columns();
25
-
26
- foreach ( $stored_columns as $column ) {
27
- if ( $column['type'] == 'title' ) {
28
- $quickedit_enabled = true;
29
- }
30
- }
31
-
32
- // taken from Wordpress core
33
- if ( $can_edit_post && 'trash' != $post->post_status ) {
34
- $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
35
-
36
- if ( $quickedit_enabled ) {
37
- $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
38
- }
39
- }
40
- if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
41
- if ( 'trash' == $post->post_status ) {
42
- $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
43
- }
44
- elseif ( EMPTY_TRASH_DAYS ) {
45
- $actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
46
- }
47
- if ( 'trash' == $post->post_status || ! EMPTY_TRASH_DAYS ) {
48
- $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
49
- }
50
- }
51
- if ( $post_type_object->public ) {
52
- if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
53
- if ( $can_edit_post ) {
54
- $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
55
- }
56
- }
57
- elseif ( 'trash' != $post->post_status ) {
58
- $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
59
- }
60
- }
61
-
62
- return $actions;
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/attachment-count.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Column displaying number of attachment for an item.
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Attachment_Count extends CPAC_Column {
9
-
10
- public function init() {
11
- parent::init();
12
-
13
- $this->properties['type'] = 'column-attachment_count';
14
- $this->properties['label'] = __( 'No. of Attachments', 'codepress-admin-columns' );
15
- }
16
-
17
- function get_value( $post_id ) {
18
- $count = $this->get_raw_value( $post_id );
19
-
20
- return $count ? $count : $this->get_empty_char();
21
- }
22
-
23
- function get_raw_value( $post_id ) {
24
- $attachment_ids = get_posts( array(
25
- 'post_type' => 'attachment',
26
- 'numberposts' => - 1,
27
- 'post_status' => null,
28
- 'post_parent' => $post_id,
29
- 'fields' => 'ids'
30
- ) );
31
-
32
- return count( $attachment_ids );
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/attachment.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Attachment
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Attachment extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-attachment';
19
- $this->properties['label'] = __( 'Attachments', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['image_size'] = '';
23
- $this->options['image_size_w'] = 80;
24
- $this->options['image_size_h'] = 80;
25
- }
26
-
27
- /**
28
- * @see CPAC_Column::get_value()
29
- * @since 2.0
30
- */
31
- public function get_value( $post_id ) {
32
-
33
- $values = (array) $this->get_raw_value( $post_id );
34
-
35
- foreach ( $values as $index => $value ) {
36
- if ( ! $value ) {
37
- unset( $values[ $index ] );
38
- continue;
39
- }
40
-
41
- $image = implode( $this->get_thumbnails( $value, (array) $this->options ) );
42
-
43
- $values[ $index ] = '<div class="cacie-item" data-cacie-id="' . esc_attr( $value ) . '">' . $image . '</div>';
44
- }
45
- return implode( '', $values );
46
- }
47
-
48
- /**
49
- * @see CPAC_Column::get_raw_value()
50
- * @since 2.0.3
51
- */
52
- public function get_raw_value( $post_id ) {
53
-
54
- return get_posts( array(
55
- 'post_type' => 'attachment',
56
- 'numberposts' => -1,
57
- 'post_status' => null,
58
- 'post_parent' => $post_id,
59
- 'fields' => 'ids'
60
- ));
61
- }
62
-
63
- /**
64
- * @see CPAC_Column::display_settings()
65
- * @since 2.0
66
- */
67
- public function display_settings() {
68
-
69
- $this->display_field_preview_size();
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/author-name.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Column displaying information about the author of a post, such as the
5
- * author's display name, user ID and email address.
6
- *
7
- * @since 2.0
8
- */
9
- class CPAC_Column_Post_Author_Name extends CPAC_Column {
10
-
11
- /**
12
- * @see CPAC_Column::init()
13
- * @since 2.2.1
14
- */
15
- public function init() {
16
- parent::init();
17
-
18
- $this->properties['type'] = 'column-author_name';
19
- $this->properties['label'] = __( 'Display Author As', 'codepress-admin-columns' );
20
- $this->properties['is_cloneable'] = true;
21
- $this->properties['object_property'] = 'post_author';
22
-
23
- // Options
24
- $this->options['display_author_as'] = '';
25
- $this->options['user_link_to'] = '';
26
- }
27
-
28
- /**
29
- * @see CPAC_Column::get_value()
30
- * @since 2.0
31
- */
32
- public function get_value( $post_id ) {
33
- $value = '';
34
-
35
- if ( $user_id = $this->get_raw_value( $post_id ) ) {
36
- $value = $this->get_display_name( $user_id );
37
- }
38
-
39
- switch ( $this->get_option( 'user_link_to' ) ) {
40
- case 'edit_user':
41
- $link = get_edit_user_link( $user_id );
42
- break;
43
- case 'view_user_posts':
44
- $link = add_query_arg( array(
45
- 'post_type' => get_post_field( 'post_type', $post_id ),
46
- 'author' => get_the_author_meta( 'ID' )
47
- ), 'edit.php' );
48
- break;
49
- case 'view_author':
50
- $link = get_author_posts_url( $user_id );
51
- break;
52
- default:
53
- $link = '';
54
- }
55
-
56
- if ( $link ) {
57
- $value = '<a href="' . esc_url( $link ) . '">' . $value . '</a>';
58
- }
59
-
60
- return $value;
61
- }
62
-
63
- /**
64
- * @see CPAC_Column::get_raw_value()
65
- * @since 2.0.3
66
- */
67
- public function get_raw_value( $post_id ) {
68
- return get_post_field( 'post_author', $post_id );
69
- }
70
-
71
- /**
72
- * Display Settings
73
- *
74
- * @see CPAC_Column::display_settings()
75
- * @since 2.0
76
- */
77
- public function display_settings() {
78
- $this->display_field_user_format();
79
- $this->display_field_user_link_to();
80
- }
81
-
82
- /**
83
- * Display settings field for the page the posts should link to
84
- *
85
- * @since 2.4.7
86
- */
87
- public function display_field_user_link_to() {
88
- $this->display_field_select(
89
- 'user_link_to',
90
- __( 'Link To', 'codepress-admin-columns' ),
91
- array(
92
- '' => __( 'None' ),
93
- 'edit_user' => __( 'Edit User Profile' ),
94
- 'view_user_posts' => __( 'View User Posts' ),
95
- 'view_author' => __( 'View Public Author Page', 'codepress-admin-columns' )
96
- ),
97
- __( 'Page the author name should link to.', 'codepress-admin-columns' )
98
- );
99
- }
100
-
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/before-moretag.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Before_Moretag
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Before_Moretag extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-before_moretag';
19
- $this->properties['label'] = __( 'Before More Tag', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['excerpt_length'] = 15;
23
- }
24
-
25
- /**
26
- * @see CPAC_Column::get_value()
27
- * @since 2.0
28
- */
29
- function get_value( $post_id ) {
30
-
31
- return $this->get_raw_value( $post_id );
32
- }
33
-
34
- /**
35
- * @see CPAC_Column::get_raw_value()
36
- * @since 2.0.3
37
- */
38
- function get_raw_value( $post_id ) {
39
-
40
- $value = '';
41
-
42
- $p = get_post( $post_id );
43
- $extended = get_extended( $p->post_content );
44
-
45
- if ( ! empty( $extended['extended'] ) ) {
46
- $value = $this->get_shortened_string( $extended['main'], $this->get_option( 'excerpt_length' ) );
47
- }
48
-
49
- return $value;
50
- }
51
-
52
- /**
53
- * @see CPAC_Column::display_settings()
54
- * @since 2.0
55
- */
56
- function display_settings() {
57
-
58
- $this->display_field_excerpt_length();
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/comment-count.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- /**
3
- * Column displaying the number of comments for an item, displaying either the total
4
- * amount of comments, or the amount per status (e.g. "Approved", "Pending").
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Comment_Count extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-comment_count';
18
- $this->properties['label'] = __( 'Comment count', 'codepress-admin-columns' );
19
- $this->properties['is_cloneable'] = true;
20
-
21
- $this->options['comment_status'] = '';
22
- }
23
-
24
- /**
25
- * get_comment_stati
26
- * @since 2.0
27
- */
28
- function get_comment_stati() {
29
- return array(
30
- 'total_comments' => __( 'Total', 'codepress-admin-columns' ),
31
- 'approved' => __( 'Approved', 'codepress-admin-columns' ),
32
- 'moderated' => __( 'Pending', 'codepress-admin-columns' ),
33
- 'spam' => __( 'Spam', 'codepress-admin-columns' ),
34
- 'trash' => __( 'Trash', 'codepress-admin-columns' ),
35
- );
36
- }
37
-
38
- /**
39
- * @see CPAC_Column::get_value()
40
- * @since 2.0
41
- */
42
- function get_value( $post_id ) {
43
- $value = '';
44
-
45
- $status = $this->get_option( 'comment_status' );
46
- $count = $this->get_raw_value( $post_id );
47
-
48
- if ( $count !== '' ) {
49
- $names = $this->get_comment_stati();
50
-
51
- $url = esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => $status ), admin_url( 'edit-comments.php' ) ) );
52
- $value = "<a href='{$url}' class='cp-{$status}' title='" . $names[ $status ] . "'>{$count}</a>";
53
- }
54
-
55
- return $value;
56
- }
57
-
58
- /**
59
- * @see CPAC_Column::get_raw_value()
60
- * @since 2.0.3
61
- */
62
- function get_raw_value( $post_id ) {
63
- $value = '';
64
-
65
- $status = $this->get_option( 'comment_status' );
66
- $count = wp_count_comments( $post_id );
67
-
68
- if ( isset( $count->{$status} ) ) {
69
- $value = $count->{$status};
70
- }
71
-
72
- return $value;
73
- }
74
-
75
- /**
76
- * @see CPAC_Column::apply_conditional()
77
- * @since 2.0
78
- */
79
- function apply_conditional() {
80
- return post_type_supports( $this->get_post_type(), 'comments' );
81
- }
82
-
83
- /**
84
- * Display Settings
85
- *
86
- * @see CPAC_Column::display_settings()
87
- * @since 2.0
88
- */
89
- function display_settings() { ?>
90
- <tr class="column_comment-count">
91
- <?php $this->label_view( __( 'Comment status', 'codepress-admin-columns' ), __( 'Select which comment status you like to display.', 'codepress-admin-columns' ), 'comment-status' ); ?>
92
- <td class="input">
93
- <select name="<?php $this->attr_name( 'comment_status' ); ?>" id="<?php $this->attr_id( 'comment-status' ); ?>">
94
- <?php foreach ( $this->get_comment_stati() as $key => $label ) : ?>
95
- <option value="<?php echo $key; ?>"<?php selected( $key, $this->get_option( 'comment_status' ) ) ?>><?php echo $label; ?></option>
96
- <?php endforeach; ?>
97
- </select>
98
- </td>
99
- </tr>
100
- <?php
101
- }
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/comment-status.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Column displaying whether an item is open for comments, i.e. whether users can
5
- * comment on this item.
6
- *
7
- * @since 2.0
8
- */
9
- class CPAC_Column_Post_Comment_Status extends CPAC_Column {
10
-
11
- /**
12
- * @see CPAC_Column::init()
13
- * @since 2.2.1
14
- */
15
- public function init() {
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-comment_status';
20
- $this->properties['label'] = __( 'Comment status', 'codepress-admin-columns' );
21
- $this->properties['object_property'] = 'comment_status';
22
- }
23
-
24
- /**
25
- * @see CPAC_Column::apply_conditional()
26
- * @since 2.2
27
- */
28
- function apply_conditional() {
29
- return post_type_supports( $this->get_post_type(), 'comments' );
30
- }
31
-
32
- /**
33
- * @see CPAC_Column::get_value()
34
- * @since 2.0
35
- */
36
- function get_value( $post_id ) {
37
- $comment_status = $this->get_raw_value( $post_id );
38
- $value = '<span class="dashicons dashicons-no cpac_status_no" title="' . $comment_status . '"></span>';
39
- if ( 'open' == $comment_status ) {
40
- $value = '<span class="dashicons dashicons-yes cpac_status_yes" title="' . $comment_status . '"></span>';
41
- }
42
-
43
- return $value;
44
- }
45
-
46
- /**
47
- * @see CPAC_Column::get_raw_value()
48
- * @since 2.0.3
49
- */
50
- function get_raw_value( $post_id ) {
51
- return get_post_field( 'comment_status', $post_id, 'raw' );
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/content.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Content
5
- *
6
- * @since 2.4
7
- */
8
- class CPAC_Column_Post_Content extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.4
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-content';
18
- $this->properties['label'] = __( 'Content', 'codepress-admin-columns' );
19
- $this->properties['object_property'] = 'post_content';
20
-
21
- $this->options['excerpt_length'] = 30;
22
- }
23
-
24
- /**
25
- * @see CPAC_Column::get_value()
26
- * @since 2.4
27
- */
28
- public function get_value( $post_id ) {
29
- return $this->get_shortened_string( $this->get_raw_value( $post_id ), $this->get_option( 'excerpt_length' ) );
30
- }
31
-
32
- /**
33
- * @see CPAC_Column::get_raw_value()
34
- * @since 2.4
35
- */
36
- public function get_raw_value( $post_id ) {
37
- return get_post_field( 'post_content', $post_id, 'raw' );
38
- }
39
-
40
- /**
41
- * @see CPAC_Column::display_settings()
42
- * @since 2.4
43
- */
44
- public function display_settings() {
45
- $this->display_field_excerpt_length();
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/date-published.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * @since 2.4
4
- */
5
- class CPAC_Column_Post_Date_Published extends CPAC_Column {
6
-
7
- /**
8
- * @see CPAC_Column::init()
9
- * @since 2.4
10
- */
11
- public function init() {
12
-
13
- parent::init();
14
-
15
- // Properties
16
- $this->properties['type'] = 'column-date_published';
17
- $this->properties['label'] = __( 'Date Published' );
18
-
19
- // Options
20
- $this->options['date_format'] = '';
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.4
26
- */
27
- public function get_value( $post_id ) {
28
-
29
- $raw_value = $this->get_raw_value( $post_id );
30
-
31
- if ( ! $this->get_option( 'date_format' ) ) {
32
- return $this->get_date( $raw_value ) . ' ' . $this->get_time( $raw_value );
33
- }
34
-
35
- return $this->get_date( $raw_value, $this->get_option( 'date_format' ) );
36
- }
37
-
38
- /**
39
- * @see CPAC_Column::get_raw_value()
40
- * @since 2.4
41
- */
42
- public function get_raw_value( $post_id ) {
43
- $post = get_post( $post_id );
44
- return $post->post_date;
45
- }
46
-
47
- /**
48
- * @see CPAC_Column::display_settings()
49
- * @since 2.4
50
- */
51
- public function display_settings() {
52
- parent::display_settings();
53
- $this->display_field_date_format();
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/depth.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * Depth of the current page (number of ancestors + 1)
4
- *
5
- * @since 2.3.4
6
- */
7
- class CPAC_Column_Post_Depth extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.3.4
12
- */
13
- public function init() {
14
- parent::init();
15
-
16
- $this->properties['type'] = 'column-depth';
17
- $this->properties['label'] = __( 'Depth', 'codepress-admin-columns' );
18
- }
19
-
20
- /**
21
- * @see CPAC_Column::get_value()
22
- * @since 2.3.4
23
- */
24
- public function get_value( $post_id ) {
25
- return $this->get_raw_value( $post_id );
26
- }
27
-
28
- /**
29
- * @see CPAC_Column::get_raw_value()
30
- * @since 2.3.4
31
- */
32
- public function get_raw_value( $post_id ) {
33
- return count( get_post_ancestors( $post_id ) ) + 1;
34
- }
35
-
36
- /**
37
- * @see CPAC_Column::apply_conditional()
38
- * @since 2.0
39
- */
40
- public function apply_conditional() {
41
- return is_post_type_hierarchical( $this->get_post_type() );
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/estimated-reading-time.php DELETED
@@ -1,115 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Estimated_Reading_Time
5
- *
6
- * @since 2.3.3
7
- */
8
- class CPAC_Column_Post_Estimated_Reading_Time extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.3.3
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-estimated_reading_time';
18
- $this->properties['label'] = __( 'Estimated Reading Time', 'codepress-admin-columns' );
19
-
20
- $this->options['words_per_minute'] = 200;
21
- }
22
-
23
- private function get_words_per_minute( ) {
24
- return $this->get_option( 'words_per_minute' );
25
- }
26
-
27
- /**
28
- * Estimate read time in readable format
29
- *
30
- * @see CPAC_Column::get_value()
31
- * @since 2.3.3
32
- */
33
- public function get_value( $post_id ) {
34
- $seconds = $this->get_raw_value( $post_id );
35
-
36
- return $seconds ? $this->convert_seconds_to_readable_time( $seconds ) : $this->get_empty_char();
37
- }
38
-
39
- /**
40
- * Estimate read time in seconds
41
- *
42
- * @see CPAC_Column::get_raw_value()
43
- * @since 2.3.3
44
- */
45
- public function get_raw_value( $post_id ) {
46
- return $this->get_estimated_reading_time_in_seconds( get_post_field( 'post_content', $post_id ) );
47
- }
48
-
49
- /**
50
- * @since 2.3.3
51
- */
52
- public function convert_seconds_to_readable_time( $seconds ) {
53
- $time = 0;
54
-
55
- if ( $seconds ) {
56
-
57
- $minutes = floor( $seconds / 60 );
58
- $seconds = floor( $seconds % 60 );
59
-
60
- $time = $minutes;
61
- if ( $minutes && $seconds < 10 ) {
62
- $seconds = '0' . $seconds;
63
- }
64
- if ( '00' != $seconds ) {
65
- $time .= ':' . $seconds;
66
- }
67
- if ( $minutes < 1 ) {
68
- $time = $seconds . ' ' . _n( 'second', 'seconds', $seconds, 'codepress-admin-columns' );
69
- }
70
- else {
71
- $time .= ' ' . _n( 'minute', 'minutes', $minutes, 'codepress-admin-columns' );
72
- }
73
- }
74
-
75
- return $time;
76
- }
77
-
78
- /**
79
- * @since 2.3.3
80
- */
81
- public function get_estimated_reading_time_in_seconds( $content ) {
82
- $word_count = $this->str_count_words( $this->strip_trim( $content ) );
83
- if ( ! $word_count ) {
84
- return 0;
85
- }
86
-
87
- return (int) floor( ( $word_count / $this->get_words_per_minute() ) * 60 );
88
- }
89
-
90
- /**
91
- * @see CPAC_Column::apply_conditional()
92
- * @since 2.3.3
93
- */
94
- public function apply_conditional() {
95
- return post_type_supports( $this->get_post_type(), 'editor' );
96
- }
97
-
98
- /**
99
- * @since 2.3.3
100
- */
101
- public function display_settings() {
102
- $field_key = 'words_per_minute';
103
- $label = __( 'Words per minute', 'codepress-admin-columns' );
104
- $description = __( 'Estimated reading time in words per minute', 'codepress-admin-columns' );
105
-
106
- ?>
107
- <tr class="column_<?php echo $field_key; ?>">
108
- <?php $this->label_view( $label, $description, $field_key ); ?>
109
- <td class="input">
110
- <input type="text" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>" value="<?php echo $this->get_words_per_minute(); ?>"/>
111
- </td>
112
- </tr>
113
- <?php
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/excerpt.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Excerpt
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Excerpt extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-excerpt';
18
- $this->properties['label'] = __( 'Excerpt', 'codepress-admin-columns' );
19
- $this->properties['object_property'] = 'post_excerpt';
20
-
21
- $this->options['excerpt_length'] = 30;
22
- }
23
-
24
- /**
25
- * @see CPAC_Column::get_value()
26
- * @since 2.0
27
- */
28
- public function get_value( $post_id ) {
29
- $value = $this->get_post_excerpt( $post_id, $this->get_option( 'excerpt_length' ) );
30
- if ( ! has_excerpt( $post_id ) && $value ) {
31
- $value = '<span class="cpac-inline-info">' . __( 'Excerpt from content', 'codepress-admin-columns' ) . '</span> ' . $value;
32
- }
33
-
34
- return $value;
35
- }
36
-
37
- /**
38
- * @see CPAC_Column::get_raw_value()
39
- * @since 2.0.3
40
- */
41
- public function get_raw_value( $post_id ) {
42
- return get_post_field( 'post_excerpt', $post_id, 'raw' );
43
- }
44
-
45
- /**
46
- * @see CPAC_Column::display_settings()
47
- * @since 2.0
48
- */
49
- public function display_settings() {
50
- $this->display_field_excerpt_length();
51
- }
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/featured-image.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Featured_Image
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Featured_Image extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-featured_image';
19
- $this->properties['label'] = __( 'Featured Image', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['image_size'] = '';
23
- $this->options['image_size_w'] = 80;
24
- $this->options['image_size_h'] = 80;
25
- }
26
-
27
- /**
28
- * @see CPAC_Column::apply_conditional()
29
- * @since 2.2
30
- */
31
- public function apply_conditional() {
32
- return post_type_supports( $this->get_post_type(), 'thumbnail' );
33
- }
34
-
35
- /**
36
- * @see CPAC_Column::get_value()
37
- * @since 2.0
38
- */
39
- public function get_value( $post_id ) {
40
- $thumbnail_id = $this->get_raw_value( $post_id );
41
-
42
- if ( ! $thumbnail_id ) {
43
- return false;
44
- }
45
-
46
- $thumb = implode( $this->get_thumbnails( $thumbnail_id, (array) $this->options ) );
47
- $link = get_edit_post_link( $post_id );
48
-
49
- return $link ? "<a href='{$link}#postimagediv'>{$thumb}</a>" : $thumb;
50
- }
51
-
52
- /**
53
- * @see CPAC_Column::get_raw_value()
54
- * @since 2.0.3
55
- */
56
- public function get_raw_value( $post_id ) {
57
- if ( ! has_post_thumbnail( $post_id ) ) {
58
- return false;
59
- }
60
-
61
- return get_post_thumbnail_id( $post_id );
62
- }
63
-
64
- /**
65
- * @see CPAC_Column::display_settings()
66
- * @since 2.0
67
- */
68
- public function display_settings() {
69
- $this->display_field_preview_size();
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/formats.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Page_Template
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Formats extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-post_formats';
19
- $this->properties['label'] = __( 'Post Format', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::apply_conditional()
24
- * @since 2.0
25
- */
26
- function apply_conditional() {
27
- return post_type_supports( $this->get_post_type(), 'post-formats' );
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_value()
32
- * @since 2.0
33
- */
34
- function get_value( $post_id ) {
35
- if ( ! ( $format = $this->get_raw_value( $post_id ) ) ) {
36
- return false;
37
- }
38
-
39
- return esc_html( get_post_format_string( $format ) );
40
- }
41
-
42
- /**
43
- * @see CPAC_Column::get_raw_value()
44
- * @since 2.0.3
45
- */
46
- function get_raw_value( $post_id ) {
47
- if ( ! ( $format = get_post_format( $post_id ) ) ) {
48
- return false;
49
- }
50
-
51
- return $format;
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/last-modified-author.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- /**
3
- * Column displaying information about the author of a post, such as the
4
- * author's display name, user ID and email address.
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Last_Modified_Author extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-last_modified_author';
20
- $this->properties['label'] = __( 'Last Modified Author', 'codepress-admin-columns' );
21
- $this->properties['is_cloneable'] = true;
22
-
23
- // Options
24
- $this->options['display_author_as'] = '';
25
- }
26
-
27
- /**
28
- * @see CPAC_Column::get_value()
29
- * @since 2.0
30
- */
31
- public function get_value( $post_id ) {
32
-
33
- $value = '';
34
-
35
- if ( $user_id = $this->get_raw_value( $post_id ) ) {
36
- $value = $this->get_display_name( $user_id );
37
- }
38
-
39
- return $value;
40
- }
41
-
42
- /**
43
- * @see CPAC_Column::get_raw_value()
44
- * @since 2.0.3
45
- */
46
- public function get_raw_value( $post_id ) {
47
- return get_post_meta( $post_id, '_edit_last', true );
48
- }
49
-
50
- /**
51
- * Display Settings
52
- *
53
- * @see CPAC_Column::display_settings()
54
- * @since 2.0
55
- */
56
- public function display_settings() {
57
-
58
- $this->display_field_user_format();
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/modified.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Modified
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Modified extends CPAC_Column {
8
-
9
- public function init() {
10
- parent::init();
11
-
12
- $this->properties['type'] = 'column-modified';
13
- $this->properties['label'] = __( 'Last modified', 'codepress-admin-columns' );
14
-
15
- $this->options['date_format'] = '';
16
- }
17
-
18
- public function get_value( $post_id ) {
19
- $modified = $this->get_raw_value( $post_id );
20
- $date_format = $this->get_option( 'date_format' );
21
-
22
- if ( ! $date_format ) {
23
- $value = $this->get_date( $modified ) . ' ' . $this->get_time( $modified );
24
- }
25
- else {
26
- $value = date_i18n( $date_format, strtotime( $modified ) );
27
- }
28
-
29
- return $value;
30
- }
31
-
32
- public function get_raw_value( $post_id ) {
33
- return get_post_field( 'post_modified', $post_id );
34
- }
35
-
36
- function display_settings() {
37
- $this->display_field_date_format();
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/order.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Order
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Order extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
- parent::init();
15
-
16
- $this->properties['type'] = 'column-order';
17
- $this->properties['label'] = __( 'Order', 'codepress-admin-columns' );
18
- }
19
-
20
- /**
21
- * @see CPAC_Column::apply_conditional()
22
- * @since 2.0
23
- */
24
- public function apply_conditional() {
25
- return is_post_type_hierarchical( $this->get_post_type() ) || post_type_supports( $this->get_post_type(), 'page-attributes' );
26
- }
27
-
28
- /**
29
- * @see CPAC_Column::get_value()
30
- * @since 2.0
31
- */
32
- public function get_value( $post_id ) {
33
- return $this->get_raw_value( $post_id );
34
- }
35
-
36
- /**
37
- * @see CPAC_Column::get_raw_value()
38
- * @since 2.0.3
39
- */
40
- public function get_raw_value( $post_id ) {
41
- return get_post_field( 'menu_order', $post_id );
42
- }
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/page-template.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Page_Template
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Page_Template extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-page_template';
18
- $this->properties['label'] = __( 'Page Template', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- function get_value( $post_id ) {
26
- return array_search( $this->get_raw_value( $post_id ), get_page_templates() );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- function get_raw_value( $post_id ) {
34
- return get_post_meta( $post_id, '_wp_page_template', true );
35
- }
36
-
37
- /**
38
- * @see CPAC_Column::apply_conditional()
39
- * @since 2.0
40
- */
41
- function apply_conditional() {
42
- return 'page' == $this->get_post_type();
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/parent.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Parent
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Parent extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-parent';
18
- $this->properties['label'] = __( 'Parent', 'codepress-admin-columns' );
19
- $this->properties['object_property'] = 'post_parent';
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- public function get_value( $post_id ) {
27
-
28
- if ( ! ( $parent_id = $this->get_raw_value( $post_id ) ) ) {
29
- return false;
30
- }
31
-
32
- $title = $this->get_post_title( $parent_id );
33
- $link = get_edit_post_link( $parent_id );
34
-
35
- return $link ? "<a href='{$link}'>{$title}</a>" : $title;
36
- }
37
-
38
- /**
39
- * @see CPAC_Column::get_raw_value()
40
- * @since 2.0.3
41
- */
42
- public function get_raw_value( $post_id ) {
43
- $parent_id = $this->get_raw_post_field( 'post_parent', $post_id );
44
-
45
- return $parent_id && is_numeric( $parent_id ) ? $parent_id : false;
46
- }
47
-
48
- /**
49
- * @see CPAC_Column::apply_conditional()
50
- * @since 2.0
51
- */
52
- public function apply_conditional() {
53
- return is_post_type_hierarchical( $this->get_post_type() );
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/path.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Column displaying path (without URL, e.g. "/my-category/sample-post/") to the front-end location of this item.
4
- *
5
- * @since 2.2.3
6
- */
7
- class CPAC_Column_Post_Path extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.3
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-path';
19
- $this->properties['label'] = __( 'Path', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.2.3
25
- */
26
- public function get_value( $post_id ) {
27
-
28
- return $this->get_raw_value( $post_id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_value()
33
- * @since 2.2.3
34
- */
35
- public function get_raw_value( $post_id ) {
36
- return str_replace( home_url(), '', get_permalink( $post_id ) );
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/permalink.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- /**
3
- * Columng displaying full item permalink (including URL).
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Permalink extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-permalink';
19
- $this->properties['label'] = __( 'Permalink', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['link_to_post'] = false;
23
- }
24
-
25
- /**
26
- * @see CPAC_Column::get_value()
27
- * @since 2.0
28
- */
29
- public function get_value( $post_id ) {
30
-
31
- $value = $this->get_raw_value( $post_id );
32
-
33
- if ( 'on' == $this->get_option( 'link_to_post' ) ) {
34
- $value = '<a href="' . esc_attr( $value ) .'" target="_blank">' . $value . '</a>';
35
- }
36
-
37
- return $value;
38
- }
39
-
40
- /**
41
- * @see CPAC_Column::get_value()
42
- * @since 2.0.3
43
- */
44
- public function get_raw_value( $post_id ) {
45
-
46
- return get_permalink( $post_id );
47
- }
48
-
49
- /**
50
- * @see CPAC_Column::display_settings()
51
- * @since 2.2.1
52
- */
53
- public function display_settings() {
54
-
55
- $this->display_field_link_to_post();
56
- }
57
-
58
- /**
59
- * Display the settings field for selecting whether the column value should link to the corresponding post
60
- *
61
- * @since 2.2.1
62
- */
63
- public function display_field_link_to_post() {
64
- $field_key = 'link_to_post';
65
- ?>
66
- <tr class="column_<?php echo $field_key; ?>">
67
- <?php $this->label_view( __( 'Link to post', 'codepress-admin-columns' ), __( 'This will make the permalink clickable.', 'codepress-admin-columns' ), $field_key ); ?>
68
- <td class="input">
69
- <label for="<?php $this->attr_id( $field_key ); ?>-on">
70
- <input type="radio" value="on" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-on"<?php checked( $this->get_option( 'link_to_post' ), 'on' ); ?> />
71
- <?php _e( 'Yes' ); ?>
72
- </label>
73
- <label for="<?php $this->attr_id( $field_key ); ?>-off">
74
- <input type="radio" value="off" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-off"<?php checked( in_array( $this->get_option( 'link_to_post' ), array( '', 'off' ) ) ); ?> />
75
- <?php _e( 'No' ); ?>
76
- </label>
77
- </td>
78
- </tr>
79
- <?php
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/ping-status.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Ping_Status
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Ping_Status extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-ping_status';
18
- $this->properties['label'] = __( 'Ping Status', 'codepress-admin-columns' );
19
- $this->properties['object_property'] = 'ping_status';
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::apply_conditional()
24
- * @since 2.2
25
- */
26
- public function apply_conditional() {
27
- return post_type_supports( $this->get_post_type(), 'comments' );
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_value()
32
- * @since 2.0
33
- */
34
- public function get_value( $post_id ) {
35
- $ping_status = $this->get_raw_value( $post_id );
36
- $value = '<span class="dashicons dashicons-no cpac_status_no" title="' . $ping_status . '"></span>';
37
- if ( 'open' == $ping_status ) {
38
- $value = '<span class="dashicons dashicons-yes cpac_status_yes" title="' . $ping_status . '"></span>';
39
- }
40
-
41
- return $value;
42
- }
43
-
44
- /**
45
- * @see CPAC_Column::get_raw_value()
46
- * @since 2.0.3
47
- */
48
- public function get_raw_value( $post_id ) {
49
- return get_post_field( 'ping_status', $post_id, 'raw' );
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/roles.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Roles
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Roles extends CPAC_Column {
9
-
10
- public function init() {
11
- parent::init();
12
-
13
- $this->properties['type'] = 'column-roles';
14
- $this->properties['label'] = __( 'Roles', 'codepress-admin-columns' );
15
- }
16
-
17
- public function get_roles() {
18
- $roles = array();
19
- foreach ( wp_roles()->roles as $k => $role ) {
20
- $roles[ $k ] = translate_user_role( $role['name'] );
21
- }
22
-
23
- return $roles;
24
- }
25
-
26
- public function get_value( $post_id ) {
27
- $roles = $this->get_roles();
28
-
29
- $role_names = array();
30
- foreach ( $this->get_raw_value( $post_id ) as $role ) {
31
- if ( isset( $roles[ $role ] ) ) {
32
- $role_names[ $role ] = $roles[ $role ];
33
- }
34
- }
35
-
36
- return implode( ', ', $role_names );
37
- }
38
-
39
- public function get_raw_value( $post_id ) {
40
- $userdata = get_userdata( get_post_field( 'post_author', $post_id ) );
41
-
42
- return empty( $userdata->roles[0] ) ? array() : $userdata->roles;
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/slug.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Slug
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Slug extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-slug';
19
- $this->properties['label'] = __( 'Slug', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $post_id ) {
27
-
28
- return $this->get_raw_value( $post_id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.0.3
34
- */
35
- function get_raw_value( $post_id ) {
36
-
37
- return get_post_field( 'post_name', $post_id, 'raw' );
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/status.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Status
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Status extends CPAC_Column {
9
-
10
- private $statuses;
11
-
12
- public function init() {
13
- parent::init();
14
-
15
- $this->properties['type'] = 'column-status';
16
- $this->properties['label'] = __( 'Status', 'codepress-admin-columns' );
17
- }
18
-
19
- public function get_status( $name ) {
20
- $stati = $this->get_statuses();
21
-
22
- return isset( $stati[ $name ] ) ? $stati[ $name ] : false;
23
- }
24
-
25
- public function get_statuses() {
26
- if ( empty( $this->statuses ) ) {
27
- $stati = get_post_stati( array( 'internal' => 0 ), 'objects' ) ;
28
- foreach ( $stati as $k => $status ) {
29
- $this->statuses[ $k ] = $status->label;
30
- }
31
- }
32
-
33
- return $this->statuses;
34
- }
35
-
36
- public function get_value( $post_id ) {
37
- $statuses = $this->get_statuses();
38
- if ( isset( $statuses['future'] ) ) {
39
- $statuses['future'] .= " <p class='description'>" . date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( get_post_field( 'post_date', $post_id ) ) ) . "</p>";
40
- }
41
- $post_status = $this->get_raw_value( $post_id );
42
-
43
- return isset( $statuses[ $post_status ] ) ? $statuses[ $post_status ] : '';
44
- }
45
-
46
- public function get_raw_value( $post_id ) {
47
- return get_post_field( 'post_status', $post_id );
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/sticky.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_Post_Sticky
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_Post_Sticky extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-sticky';
18
- $this->properties['label'] = __( 'Sticky', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::apply_conditional()
23
- * @since 2.0
24
- */
25
- function apply_conditional() {
26
- return 'post' == $this->get_post_type();
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_value()
31
- * @since 2.0
32
- */
33
- function get_value( $post_id ) {
34
- return $this->get_raw_value( $post_id ) ? '<span class="dashicons dashicons-yes cpac_status_yes"></span>' : '<span class="dashicons dashicons-no cpac_status_no"></span>';
35
- }
36
-
37
- /**
38
- * @see CPAC_Column::get_raw_value()
39
- * @since 2.0.3
40
- */
41
- function get_raw_value( $post_id ) {
42
- return is_sticky( $post_id );
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/title-raw.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Title_Raw
4
- *
5
- * @since 2.2.4
6
- */
7
- class CPAC_Column_Post_Title_Raw extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.4
12
- */
13
- public function init() {
14
-
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-title_raw';
19
- $this->properties['label'] = __( 'Title without actions', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.2.4
25
- */
26
- function get_value( $post_id ) {
27
-
28
- return $this->get_raw_value( $post_id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.2.4
34
- */
35
- function get_raw_value( $post_id ) {
36
-
37
- return get_post_field( 'post_title', $post_id );
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/post/word-count.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_Post_Word_Count
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_Post_Word_Count extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
- parent::init();
15
-
16
- $this->properties['type'] = 'column-word_count';
17
- $this->properties['label'] = __( 'Word count', 'codepress-admin-columns' );
18
- }
19
-
20
- /**
21
- * @see CPAC_Column::get_value()
22
- * @since 2.0
23
- */
24
- function get_value( $post_id ) {
25
- $count = $this->get_raw_value( $post_id );
26
-
27
- return $count ? $count : $this->get_empty_char();
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_raw_value()
32
- * @since 2.0.3
33
- */
34
- function get_raw_value( $post_id ) {
35
- return $this->str_count_words( $this->strip_trim( get_post_field( 'post_content', $post_id ) ) );
36
- }
37
-
38
- /**
39
- * @see CPAC_Column::apply_conditional()
40
- * @since 2.0
41
- */
42
- function apply_conditional() {
43
- return post_type_supports( $this->get_post_type(), 'editor' );
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/taxonomy.php DELETED
@@ -1,91 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Taxonomy column, displaying terms from a taxonomy for any object type (i.e. posts)
5
- * supporting WordPress' native way of handling terms.
6
- *
7
- * @since 2.0
8
- */
9
- class CPAC_Column_Taxonomy extends CPAC_Column {
10
-
11
- public function init() {
12
- parent::init();
13
-
14
- // Properties
15
- $this->properties['type'] = 'column-taxonomy';
16
- $this->properties['label'] = __( 'Taxonomy', 'codepress-admin-columns' );
17
- $this->properties['is_cloneable'] = true;
18
-
19
- // Options
20
- $this->options['taxonomy'] = ''; // Taxonomy slug
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.0
26
- */
27
- public function get_value( $post_id ) {
28
- $term_ids = $this->get_raw_value( $post_id );
29
-
30
- return $this->get_terms_for_display( $term_ids, $this->get_taxonomy() );
31
- }
32
-
33
- /**
34
- * @see CPAC_Column::get_raw_value()
35
- * @since 2.0.3
36
- */
37
- public function get_raw_value( $post_id ) {
38
- return wp_get_post_terms( $post_id, $this->get_taxonomy(), array( 'fields' => 'ids' ) );
39
- }
40
-
41
- /**
42
- * @see CPAC_Column::get_value()
43
- * @since 2.3.4
44
- */
45
- public function get_taxonomy() {
46
- return $this->get_option( 'taxonomy' );
47
- }
48
-
49
- /**
50
- * @see CPAC_Column::apply_conditional()
51
- * @since 2.0
52
- */
53
- public function apply_conditional() {
54
- $post_type = $this->get_post_type();
55
- if ( ! $post_type || ! get_object_taxonomies( $post_type ) ) {
56
- return false;
57
- }
58
-
59
- return true;
60
- }
61
-
62
- /**
63
- * Display Settings
64
- *
65
- * @see CPAC_Column::display_settings()
66
- * @since 2.0
67
- */
68
- public function display_settings() {
69
- $taxonomies = get_object_taxonomies( $this->get_post_type(), 'objects' );
70
-
71
- foreach ( $taxonomies as $index => $taxonomy ) {
72
- if ( $taxonomy->name == 'post_format' ) {
73
- unset( $taxonomies[ $index ] );
74
- }
75
- }
76
- ?>
77
-
78
- <tr class="column_taxonomy">
79
- <?php $this->label_view( __( "Taxonomy", 'codepress-admin-columns' ), '', 'taxonomy' ); ?>
80
- <td class="input">
81
- <select name="<?php $this->attr_name( 'taxonomy' ); ?>" id="<?php $this->attr_id( 'taxonomy' ); ?>">
82
- <?php foreach ( $taxonomies as $taxonomy ) : ?>
83
- <option value="<?php echo $taxonomy->name; ?>"<?php selected( $taxonomy->name, $this->get_taxonomy() ) ?>><?php echo $taxonomy->label; ?></option>
84
- <?php endforeach; ?>
85
- </select>
86
- </td>
87
- </tr>
88
-
89
- <?php
90
- }
91
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/used-by-menu.php DELETED
@@ -1,144 +0,0 @@
1
- <?php
2
- /**
3
- * Column displaying the menus the item is used in. Supported by all object types that
4
- * can be referenced in menus (i.e. posts).
5
- *
6
- * @since 2.2.5
7
- */
8
- class CPAC_Column_Used_By_Menu extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.5
13
- */
14
- public function init() {
15
-
16
- parent::init();
17
-
18
- // Properties
19
- $this->properties['type'] = 'column-used_by_menu';
20
- $this->properties['label'] = __( 'Used by Menu', 'codepress-admin-columns' );
21
-
22
- // Options
23
- $this->options['link_to_menu'] = false;
24
- }
25
-
26
- /**
27
- * @see CPAC_Column::apply_conditional()
28
- * @since 2.2.5
29
- */
30
- function apply_conditional() {
31
- if ( ! $this->get_meta_type() ) {
32
- return false;
33
- }
34
- return true;
35
- }
36
-
37
- /**
38
- * @see CPAC_Column::get_value()
39
- * @since 2.2.5
40
- */
41
- function get_value( $object_id ) {
42
-
43
- $menus = array();
44
- if ( $menu_ids = $this->get_raw_value( $object_id ) ) {
45
- foreach ( $menu_ids as $menu_id ) {
46
- $term = get_term_by( 'id', $menu_id, 'nav_menu' );
47
-
48
- $title = $term->name;
49
- if ( 'on' == $this->get_option( 'link_to_menu' ) ) {
50
- $title = '<a href="' . esc_url( add_query_arg( array( 'menu' => $menu_id ), admin_url('nav-menus.php') ) ) . '">' . $term->name . '</a>';
51
- }
52
-
53
- $menus[] = $title;
54
- }
55
- }
56
-
57
- return implode( ', ', $menus );
58
- }
59
-
60
- /**
61
- * Get object metatype of the storage model
62
- *
63
- * @since 2.2.5
64
- */
65
- function get_meta_type() {
66
- $object_type = false;
67
- $model = $this->get_storage_model();
68
- if ( isset( $model->taxonomy ) ) {
69
- $object_type = $model->taxonomy;
70
- }
71
- elseif ( $post_type = $this->get_post_type() ) {
72
- $object_type = $post_type;
73
- }
74
- return $object_type;
75
- }
76
-
77
- /**
78
- * @see CPAC_Column::get_raw_value()
79
- * @since 2.2.5
80
- */
81
- function get_raw_value( $object_id ) {
82
- $object_type = $this->get_meta_type();
83
-
84
- $menu_item_ids = get_posts( array(
85
- 'post_type' => 'nav_menu_item',
86
- 'numberposts' => -1,
87
- 'post_status' => 'publish',
88
- 'fields' => 'ids',
89
- 'meta_query' => array(
90
- array(
91
- 'key' => '_menu_item_object_id',
92
- 'value' => $object_id
93
- ),
94
- array(
95
- 'key' => '_menu_item_object',
96
- 'value' => $object_type
97
- ),
98
- )
99
- ) );
100
-
101
- if ( ! $menu_item_ids ) {
102
- return false;
103
- }
104
-
105
- $menu_ids = wp_get_object_terms( $menu_item_ids, 'nav_menu', array( 'fields' => 'ids') );
106
- if ( ! $menu_ids || is_wp_error( $menu_ids ) ) {
107
- return false;
108
- }
109
-
110
- return $menu_ids;
111
- }
112
-
113
- /**
114
- * @see CPAC_Column::display_settings()
115
- * @since 2.2.5
116
- */
117
- public function display_settings() {
118
- $this->display_field_link_to_menu();
119
- }
120
-
121
- /**
122
- * Display the settings field for selecting whether the column value should link to the corresponding post
123
- *
124
- * @since 2.2.5
125
- */
126
- public function display_field_link_to_menu() {
127
- $field_key = 'link_to_menu';
128
- ?>
129
- <tr class="column_<?php echo $field_key; ?>">
130
- <?php $this->label_view( __( 'Link to menu', 'codepress-admin-columns' ), __( 'This will make the title link to the menu.', 'codepress-admin-columns' ), $field_key ); ?>
131
- <td class="input">
132
- <label for="<?php $this->attr_id( $field_key ); ?>-on">
133
- <input type="radio" value="on" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-on"<?php checked( $this->get_option( 'link_to_menu' ), 'on' ); ?> />
134
- <?php _e( 'Yes'); ?>
135
- </label>
136
- <label for="<?php $this->attr_id( $field_key ); ?>-off">
137
- <input type="radio" value="off" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-off"<?php checked( in_array( $this->get_option( 'link_to_menu' ), array( '', 'off' ) ) ); ?> />
138
- <?php _e( 'No'); ?>
139
- </label>
140
- </td>
141
- </tr>
142
- <?php
143
- }
144
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/ID.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_ID
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_ID extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-user_id';
18
- $this->properties['label'] = __( 'User ID', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- function get_value( $user_id ) {
26
- return $this->get_raw_value( $user_id );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- function get_raw_value( $user_id ) {
34
- return $user_id;
35
- }
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/actions.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Actions
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Actions extends CPAC_Column_Actions {
9
-
10
- /**
11
- * @see CPAC_Column_Actions::get_actions()
12
- * @since 2.4.7
13
- */
14
- public function get_actions( $id ) {
15
- $actions = array();
16
-
17
- $user_object = new WP_User( $id );
18
- $screen = get_current_screen();
19
-
20
- if ( 'site-users-network' == $screen->id ) {
21
- $url = "site-users.php?id={$this->site_id}&amp;";
22
- }
23
- else {
24
- $url = 'users.php?';
25
- }
26
-
27
- if ( get_current_user_id() == $user_object->ID ) {
28
- $edit_link = 'profile.php';
29
- }
30
- else {
31
- $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
32
- }
33
-
34
- if ( current_user_can( 'edit_user', $user_object->ID ) ) {
35
- $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
36
- $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
37
- }
38
- else {
39
- $edit = "<strong>$user_object->user_login</strong><br />";
40
- }
41
-
42
- if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) {
43
- $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
44
- }
45
- if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) {
46
- $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
47
- }
48
-
49
- return $actions;
50
- }
51
-
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/comment-count.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Comment_Count
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Comment_Count extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-user_commentcount';
18
- $this->properties['label'] = __( 'Comment Count' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- function get_value( $user_id ) {
26
- return $this->get_raw_value( $user_id );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- function get_raw_value( $user_id ) {
34
- return get_comments( array(
35
- 'user_id' => $user_id,
36
- 'count' => true,
37
- 'orderby' => false
38
- ) );
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/description.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Description
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Description extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-user_description';
18
- $this->properties['label'] = __( 'Description', 'codepress-admin-columns' );
19
-
20
- $this->options['excerpt_length'] = 30;
21
- }
22
-
23
- /**
24
- * @see CPAC_Column::get_value()
25
- * @since 2.0
26
- */
27
- function get_value( $user_id ) {
28
- return $this->get_raw_value( $user_id );
29
- }
30
-
31
- /**
32
- * @see CPAC_Column::get_raw_value()
33
- * @since 2.0.3
34
- */
35
- function get_raw_value( $user_id ) {
36
- return $this->get_shortened_string( get_the_author_meta( 'user_description', $user_id ), $this->get_option( 'excerpt_length' ) );
37
- }
38
-
39
- /**
40
- * @see CPAC_Column::display_settings()
41
- * @since 2.0
42
- */
43
- function display_settings() {
44
- $this->display_field_excerpt_length();
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/display-name.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * CPAC_Column_User_Display_Name
4
- *
5
- * @since 2.0
6
- */
7
- class CPAC_Column_User_Display_Name extends CPAC_Column {
8
-
9
- /**
10
- * @see CPAC_Column::init()
11
- * @since 2.2.1
12
- */
13
- public function init() {
14
- parent::init();
15
-
16
- $this->properties['type'] = 'column-display_name';
17
- $this->properties['label'] = __( 'Display name', 'codepress-admin-columns' );
18
- }
19
-
20
- /**
21
- * @see CPAC_Column::get_value()
22
- * @since 2.0
23
- */
24
- function get_value( $user_id ) {
25
- return $this->get_raw_value( $user_id );
26
- }
27
-
28
- /**
29
- * @see CPAC_Column::get_raw_value()
30
- * @since 2.0.3
31
- */
32
- function get_raw_value( $user_id ) {
33
- $userdata = get_userdata( $user_id );
34
-
35
- return $userdata->display_name;
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/first-name.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_First_Name
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_First_Name extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-first_name';
18
- $this->properties['label'] = __( 'First name', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- public function get_value( $user_id ) {
26
- return $this->get_raw_value( $user_id );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- public function get_raw_value( $user_id ) {
34
- $userdata = get_userdata( $user_id );
35
-
36
- return $userdata->first_name;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/last-name.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Last_Name
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Last_Name extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-last_name';
18
- $this->properties['label'] = __( 'Last name', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- function get_value( $user_id ) {
26
- return $this->get_raw_value( $user_id );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- function get_raw_value( $user_id ) {
34
- $userdata = get_userdata( $user_id );
35
-
36
- return $userdata->last_name;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/nickname.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Nickname
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Nickname extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
-
18
- $this->properties['type'] = 'column-nickname';
19
- $this->properties['label'] = __( 'Nickname', 'codepress-admin-columns' );
20
- }
21
-
22
- /**
23
- * @see CPAC_Column::get_value()
24
- * @since 2.0
25
- */
26
- function get_value( $user_id ) {
27
- return $this->get_raw_value( $user_id );
28
- }
29
-
30
- /**
31
- * @see CPAC_Column::get_raw_value()
32
- * @since 2.0.3
33
- */
34
- function get_raw_value( $user_id ) {
35
- $userdata = get_userdata( $user_id );
36
-
37
- return $userdata->nickname;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/post-count.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Post_Count
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Post_Count extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-user_postcount';
19
- $this->properties['label'] = __( 'Post Count', 'codepress-admin-columns' );
20
- $this->properties['is_cloneable'] = true;
21
-
22
- // Options
23
- $this->options['post_type'] = '';
24
- }
25
-
26
- /**
27
- * Get count
28
- *
29
- * @since 2.0
30
- */
31
- public function get_count( $user_id ) {
32
- return $this->get_user_postcount( $user_id, $this->get_option( 'post_type' ) );
33
- }
34
-
35
- /**
36
- * @see CPAC_Column::get_value()
37
- * @since 2.0
38
- */
39
- function get_value( $user_id ) {
40
- $value = '0';
41
-
42
- $count = $this->get_raw_value( $user_id );
43
- if ( $count > 0 ) {
44
- $value = "<a href='edit.php?post_type=" . $this->get_option( 'post_type' ) . "&author={$user_id}'>{$count}</a>";
45
- }
46
-
47
- return $value;
48
- }
49
-
50
- /**
51
- * @see CPAC_Column::get_raw_value()
52
- * @since 2.0.3
53
- */
54
- function get_raw_value( $user_id ) {
55
- return $this->get_count( $user_id );
56
- }
57
-
58
- /**
59
- * Display Settings
60
- *
61
- * @see CPAC_Column::display_settings()
62
- * @since 2.0
63
- */
64
- function display_settings() {
65
- $ptypes = array();
66
-
67
- if ( post_type_exists( 'post' ) ) {
68
- $ptypes['post'] = 'post';
69
- }
70
-
71
- if ( post_type_exists( 'page' ) ) {
72
- $ptypes['page'] = 'page';
73
- }
74
-
75
- $ptypes = array_merge( $ptypes, get_post_types( array(
76
- '_builtin' => false
77
- ) ) );
78
-
79
- // get posttypes and name
80
- $post_types = array();
81
- foreach ( $ptypes as $type ) {
82
- $obj = get_post_type_object( $type );
83
- $post_types[ $type ] = $obj->labels->name;
84
- }
85
-
86
- ?>
87
- <tr class="<?php $this->properties->type; ?>">
88
- <?php $this->label_view( __( 'Post Type', 'codepress-admin-columns' ), '', 'post_type' ); ?>
89
- <td class="input">
90
- <select name="<?php $this->attr_name( 'post_type' ); ?>" id="<?php $this->attr_id( 'post_type' ); ?>">
91
- <?php foreach ( $post_types as $key => $label ) : ?>
92
- <option value="<?php echo $key; ?>"<?php selected( $key, $this->get_option( 'post_type' ) ); ?>><?php echo $label; ?></option>
93
- <?php endforeach; ?>
94
- </select>
95
- </td>
96
- </tr>
97
- <?php
98
- }
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/registered.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Registered
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Registered extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- // Properties
18
- $this->properties['type'] = 'column-user_registered';
19
- $this->properties['label'] = __( 'Registered', 'codepress-admin-columns' );
20
-
21
- // Options
22
- $this->options['date_format'] = '';
23
- }
24
-
25
- /**
26
- * @see CPAC_Column::get_value()
27
- * @since 2.0
28
- */
29
- function get_value( $user_id ) {
30
- $user_registered = $this->get_raw_value( $user_id );
31
-
32
- // GMT offset is used
33
- return $this->get_date( get_date_from_gmt( $user_registered ), $this->get_option( 'date_format' ) );
34
- }
35
-
36
- /**
37
- * @see CPAC_Column::get_raw_value()
38
- * @since 2.0.3
39
- */
40
- function get_raw_value( $user_id ) {
41
- $userdata = get_userdata( $user_id );
42
-
43
- return $userdata->user_registered;
44
- }
45
-
46
- /**
47
- * @see CPAC_Column::display_settings()
48
- * @since 2.0
49
- */
50
- function display_settings() {
51
- $this->display_field_date_format();
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/rich-editing.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Column_User_Rich_Editing extends CPAC_Column {
4
-
5
- /**
6
- * @see CPAC_Column::init()
7
- * @since 2.2.1
8
- */
9
- public function init() {
10
- parent::init();
11
-
12
- $this->properties['type'] = 'column-rich_editing';
13
- $this->properties['label'] = __( 'Visual Editor', 'codepress-admin-columns' );
14
- }
15
-
16
- /**
17
- * @see CPAC_Column::get_value()
18
- * @since 2.0
19
- */
20
- function get_value( $user_id ) {
21
- return $this->get_raw_value( $user_id ) ? '<span class="dashicons dashicons-yes cpac_status_yes"></span>' : '<span class="dashicons dashicons-no cpac_status_no"></span>';
22
- }
23
-
24
- /**
25
- * @see CPAC_Column::get_raw_value()
26
- * @since 2.0.3
27
- */
28
- function get_raw_value( $user_id ) {
29
- $userdata = get_userdata( $user_id );
30
-
31
- return $userdata->rich_editing;
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/user/url.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Column_User_Url
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Column_User_Url extends CPAC_Column {
9
-
10
- /**
11
- * @see CPAC_Column::init()
12
- * @since 2.2.1
13
- */
14
- public function init() {
15
- parent::init();
16
-
17
- $this->properties['type'] = 'column-user_url';
18
- $this->properties['label'] = __( 'Url', 'codepress-admin-columns' );
19
- }
20
-
21
- /**
22
- * @see CPAC_Column::get_value()
23
- * @since 2.0
24
- */
25
- function get_value( $user_id ) {
26
- return $this->get_raw_value( $user_id );
27
- }
28
-
29
- /**
30
- * @see CPAC_Column::get_raw_value()
31
- * @since 2.0.3
32
- */
33
- function get_raw_value( $user_id ) {
34
- $userdata = get_userdata( $user_id );
35
-
36
- return $userdata->user_url;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/column/wc-placeholder.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @since 2.4.7
5
- */
6
- class CPAC_Column_WC_Placeholder extends CPAC_Column {
7
-
8
- public function init() {
9
- parent::init();
10
-
11
- $this->properties['type'] = 'column-wc_placeholder';
12
- $this->properties['label'] = __( 'WooCommerce', 'codepress-admin-columns' );
13
- $this->properties['is_pro_only'] = true;
14
- $this->properties['group'] = 'woocommerce';
15
- }
16
-
17
- public function apply_conditional() {
18
- return in_array( $this->get_post_type(), array( 'product', 'shop_order', 'shop_coupon' ) );
19
- }
20
-
21
- public function display_settings() {
22
- $this->display_settings_placeholder( ac_get_site_url( 'woocommerce-columns' ) );
23
- }
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/review_notice.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Review_Notice {
4
-
5
- const OPTION_INSTALL_DATE = 'cpac-install-timestamp';
6
- const OPTION_ADMIN_NOTICE_KEY = 'cpac-hide-review-notice';
7
-
8
- private $days_since_install;
9
- private $cpac;
10
-
11
- function __construct( $cpac ) {
12
-
13
- register_activation_hook( __FILE__, array( $this, 'insert_install_timestamp' ) );
14
-
15
- // show notice after x days of installing
16
- $this->days_since_install = 30; // 30 days
17
-
18
- add_action( 'admin_init', array( $this, 'maybe_display_review_notice' ) );
19
- add_action( 'wp_ajax_cpac_hide_review_notice', array( $this, 'ajax_hide_review_notice' ) );
20
- }
21
-
22
- public function insert_install_timestamp() {
23
- add_site_option( self::OPTION_INSTALL_DATE, time() );
24
- return time();
25
- }
26
-
27
- private function get_install_timestamp() {
28
- $timestamp = get_site_option( self::OPTION_INSTALL_DATE, '' );
29
- if ( '' == $timestamp ) {
30
- $timestamp = $this->insert_install_timestamp();
31
- }
32
- return $timestamp;
33
- }
34
-
35
- public function maybe_display_review_notice() {
36
-
37
- if( cpac()->suppress_site_wide_notices() ){
38
- return;
39
- }
40
-
41
- if ( current_user_can( 'manage_admin_columns' ) && ( ! get_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_KEY, true ) ) ) {
42
- if ( ( time() - ( 86400 * absint( $this->days_since_install ) ) ) >= $this->get_install_timestamp() ) {
43
- add_action( 'admin_notices', array( $this, 'display_admin_review_notice' ) );
44
- }
45
- }
46
- }
47
-
48
- public function ajax_hide_review_notice() {
49
- update_user_meta( get_current_user_id(), self::OPTION_ADMIN_NOTICE_KEY, '1', true );
50
- }
51
-
52
- public function display_admin_review_notice() {
53
- $screen = get_current_screen();
54
-
55
- // only display on settings and plugins page
56
- if ( ! $screen || ! in_array( $screen->parent_base, array( 'options-general', 'plugins' ) ) ) {
57
- return false;
58
- }
59
-
60
- $product = __( 'Admin Columns', 'codepress-admin-columns' );
61
-
62
- if ( defined( 'ACP_VERSION' ) ) {
63
- $product = __( 'Admin Columns Pro', 'codepress-admin-columns' );
64
- }
65
- ?>
66
- <div class="cpac_message updated">
67
- <div class="info">
68
- <p>
69
- <?php printf( __(
70
- "We don't mean to bug you, but you've been using %s for some time now, and we were wondering if you're happy with the plugin. If so, could you please leave a review at wordpress.org? If you're not happy with %s, please %s.", 'codepress-admin-columns' ),
71
- '<strong>' . $product . '</strong>',
72
- $product,
73
- '<a class="hide-review-notice hide-review-notice-soft" href="#">' . __( 'click here', 'codepress-admin-columns' ) . '</a>'
74
- ); ?>
75
- </p>
76
- <p class="buttons">
77
- <a class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/codepress-admin-columns?rate=5#postform" target="_blank"><?php _e( 'Leave a review!', 'codepress-admin-columns' ); ?></a>
78
- <a class="button button-secondary hide-review-notice" href='#'><?php _e( "Permanently hide notice", 'codepress-admin-columns' ); ?></a>
79
- </p>
80
- </div>
81
- <div class="help">
82
- <a href="#" class="hide-notice hide-review-notice"></a>
83
- <p>
84
- <?php printf(
85
- __( "We're sorry to hear that; maybe we can help! If you're having problems properly setting up %s or if you would like help with some more advanced features, please visit our %s.", 'codepress-admin-columns' ),
86
- $product,
87
- '<a href="' . ac_get_site_url( 'documentation' ) . '" target="_blank">' . __( 'documentation page', 'codepress-admin-columns' ) . '</a>'
88
- ); ?>
89
- <?php if ( defined( 'ACP_VERSION' ) ) : ?>
90
- <?php printf(
91
- __( 'As an Admin Columns Pro user, you can also use your AdminColumns.com account to access product support through %s!', 'codepress-admin-columns' ),
92
- '<a href="' . ac_get_site_url( 'forumns' ) . '" target="_blank">' . __( 'our forums', 'codepress-admin-columns' ) . '</a>'
93
- ); ?>
94
- <?php else : ?>
95
- <?php printf(
96
- __( 'You can also find help on the %s, and %s.', 'codepress-admin-columns' ),
97
- '<a href="https://wordpress.org/support/plugin/codepress-admin-columns#postform" target="_blank">' . __( 'Admin Columns forums on WordPress.org', 'codepress-admin-columns' ) . '</a>',
98
- '<a href="https://wordpress.org/plugins/codepress-admin-columns/faq/#plugin-info" target="_blank">' . __( 'find answers to some frequently asked questions', 'codepress-admin-columns' ) . '</a>'
99
- ); ?>
100
- <?php endif; ?>
101
- </p>
102
- </div>
103
- <div class="clear"></div>
104
- </div>
105
- <style type="text/css">
106
- body .wrap .cpac_message {
107
- position: relative;
108
- padding-right: 40px;
109
- }
110
- .cpac_message .spinner.right {
111
- visibility: visible;
112
- display: block;
113
- right: 8px;
114
- text-decoration: none;
115
- text-align: right;
116
- position: absolute;
117
- top: 50%;
118
- margin-top: -10px;
119
- }
120
- .cpac_message .spinner.inline {
121
- display: inline-block;
122
- position: absolute;
123
- margin: 4px 0 0 4px;
124
- padding: 0;
125
- float: none;
126
- }
127
- .cpac_message .hide-notice {
128
- right: 8px;
129
- text-decoration: none;
130
- width: 32px;
131
- text-align: right;
132
- position: absolute;
133
- top: 50%;
134
- height: 32px;
135
- margin-top: -16px;
136
- }
137
- .cpac_message .hide-notice:before {
138
- display: block;
139
- content: '\f335';
140
- font-family: 'Dashicons';
141
- margin: .5em 0;
142
- padding: 2px;
143
- }
144
- .cpac_message .buttons {
145
- margin-top: 8px;
146
- }
147
- .cpac_message .help {
148
- display: none;
149
- }
150
- </style>
151
- <script type="text/javascript">
152
- jQuery( function( $ ) {
153
- $( document ).ready( function() {
154
- $( '.updated a.hide-review-notice' ).click( function( e ) {
155
- e.preventDefault();
156
-
157
- var el = $( this ).parents( '.cpac_message' );
158
- var el_close = el.find( '.hide-notice' );
159
- var soft = $( this ).hasClass( 'hide-review-notice-soft' );
160
-
161
- if ( soft ) {
162
- el.find( '.info' ).slideUp();
163
- el.find( '.help' ).slideDown();
164
- }
165
- else {
166
- el_close.hide();
167
- el_close.after( '<div class="spinner right"></div>' );
168
- el.find( '.spinner' ).show();
169
- }
170
-
171
- $.post( ajaxurl, {
172
- 'action': 'cpac_hide_review_notice'
173
- }, function( data ) {
174
- if ( ! soft ) {
175
- el.find( '.spinner' ).remove();
176
- el.slideUp();
177
- }
178
- } );
179
-
180
- return false;
181
- } );
182
- } );
183
- } );
184
- </script>
185
- <?php
186
- }
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/settings.php DELETED
@@ -1,1179 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * CPAC_Settings Class
5
- *
6
- * @since 2.0
7
- */
8
- class CPAC_Settings {
9
-
10
- CONST OPTION_CURRENT = 'cpac_current_model';
11
-
12
- /**
13
- * CPAC class
14
- *
15
- * @since 2.0
16
- */
17
- private $cpac;
18
-
19
- /**
20
- * Settings Page
21
- *
22
- * @since 2.0
23
- */
24
- private $settings_page;
25
-
26
- /**
27
- * @since 2.0
28
- *
29
- * @param object CPAC
30
- */
31
- function __construct( $cpac ) {
32
-
33
- $this->cpac = $cpac;
34
-
35
- // register settings
36
- add_action( 'admin_menu', array( $this, 'settings_menu' ) );
37
-
38
- // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
39
- add_action( 'admin_init', array( $this, 'handle_column_request' ), 1000 );
40
-
41
- add_action( 'wp_ajax_cpac_column_refresh', array( $this, 'ajax_column_refresh' ) );
42
- add_action( 'wp_ajax_cpac_columns_update', array( $this, 'ajax_columns_update' ) );
43
-
44
- add_action( 'cpac_messages', array( $this, 'maybe_display_addon_statuschange_message' ) );
45
- }
46
-
47
- /**
48
- * @since 3.1.1
49
- */
50
- public function get_settings_page() {
51
- return $this->settings_page;
52
- }
53
-
54
- /**
55
- * Get available Admin Columns admin page URLs
56
- *
57
- * @since 2.2
58
- * @return array Available settings URLs ([settings_page] => [url])
59
- */
60
- public function get_settings_urls() {
61
-
62
- /**
63
- * Filter the URLs for the different settings screens available in admin columns
64
- *
65
- * @since 2.2
66
- *
67
- * @param array $settings_urls Available settings URLs ([settings_page] => [url])
68
- * @param CPAC_Settings $settings_instance Settings class instance
69
- */
70
- $settings_urls = apply_filters( 'cac/settings/settings_urls', array(
71
- 'admin' => admin_url( 'options-general.php?page=codepress-admin-columns' ),
72
- 'settings' => admin_url( 'options-general.php?page=codepress-admin-columns&tab=settings' ),
73
- 'network_settings' => network_admin_url( 'settings.php?page=codepress-admin-columns' ),
74
- 'info' => admin_url( 'options-general.php?page=codepress-admin-columns&info=' ),
75
- 'upgrade' => admin_url( 'options-general.php?page=cpac-upgrade' ),
76
- ), $this );
77
-
78
- return $settings_urls;
79
- }
80
-
81
- /**
82
- * Get the settings URL for a page
83
- *
84
- * @since 2.2
85
- *
86
- * @param string $page Optional. Admin page to get the URL from. Defaults to the basic Admin Columns page
87
- *
88
- * @return string Settings page URL
89
- */
90
- public function get_settings_url( $page = '' ) {
91
-
92
- $settings_urls = $this->get_settings_urls();
93
-
94
- if ( isset( $settings_urls[ $page ] ) ) {
95
- return $settings_urls[ $page ];
96
- }
97
-
98
- if ( ! $page ) {
99
- return $settings_urls['admin'];
100
- }
101
-
102
- return add_query_arg( 'tab', $page, $this->get_settings_url() );
103
- }
104
-
105
- /**
106
- * Display an activation/deactivation message on the addons page if applicable
107
- *
108
- * @since 2.2
109
- */
110
- public function maybe_display_addon_statuschange_message() {
111
- if ( empty( $_REQUEST['tab'] ) || $_REQUEST['tab'] != 'addons' ) {
112
- return;
113
- }
114
-
115
- $message = '';
116
-
117
- if ( ! empty( $_REQUEST['activate'] ) ) {
118
- $message = __( 'Add-on successfully activated.', 'codepress-admin-columns' );
119
- }
120
- else if ( ! empty( $_REQUEST['deactivate'] ) ) {
121
- $message = __( 'Add-on successfully deactivated.', 'codepress-admin-columns' );
122
- }
123
-
124
- if ( ! $message ) {
125
- return;
126
- }
127
- ?>
128
- <div class="updated cac-notification below-h2">
129
- <p><?php echo $message; ?></p>
130
- </div>
131
- <?php
132
- }
133
-
134
- /**
135
- * @since 2.2
136
- */
137
- public function ajax_column_refresh() {
138
- check_ajax_referer( 'cpac-settings' );
139
-
140
- if ( ! current_user_can( 'manage_admin_columns' ) ) {
141
- wp_die();
142
- }
143
-
144
- $formdata = filter_input( INPUT_POST, 'formdata' );
145
- $column = filter_input( INPUT_POST, 'column' );
146
-
147
- if ( ! $formdata || ! $column ) {
148
- wp_die();
149
- }
150
-
151
- parse_str( $_POST['formdata'], $formdata );
152
-
153
- if ( empty( $formdata['cpac_key'] ) ) {
154
- wp_die();
155
- }
156
-
157
- $storage_model = cpac()->get_storage_model( $formdata['cpac_key'] );
158
-
159
- $storage_model->set_layout( $_POST['layout'] );
160
-
161
- if ( ! $storage_model || empty( $formdata[ $storage_model->key ][ $column ] ) ) {
162
- wp_die();
163
- }
164
-
165
- $columndata = $formdata[ $storage_model->key ][ $column ];
166
-
167
- $column = $storage_model->create_column( $columndata );
168
- if ( ! $column ) {
169
- wp_die();
170
- }
171
-
172
- // Trigger add-ons like inline-edit and sortable
173
- do_action( "cac/columns", array( $column->properties->name => $column ), $storage_model );
174
- do_action( "cac/columns/storage_key={$storage_model->key}", array( $column->properties->name => $column ), $storage_model );
175
-
176
- ob_start();
177
- $column->display();
178
- wp_send_json_success( ob_get_clean() );
179
- }
180
-
181
- /**
182
- * @since 1.0
183
- */
184
- public function settings_menu() {
185
- $this->settings_page = add_submenu_page( 'options-general.php', __( 'Admin Columns Settings', 'codepress-admin-columns' ), __( 'Admin Columns', 'codepress-admin-columns' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'display' ), false, 98 );
186
-
187
- register_setting( 'cpac-general-settings', 'cpac_general_options' );
188
-
189
- add_filter( 'option_page_capability_cpac-general-settings', array( $this, 'add_capability' ) );
190
- add_action( "load-{$this->settings_page}", array( $this, 'help_tabs' ) );
191
-
192
- $this->enqueue_admin_scripts();
193
- }
194
-
195
- /**
196
- * Print scripts and styles
197
- *
198
- * @since 2.4.7
199
- */
200
- public function enqueue_admin_scripts() {
201
- add_action( 'admin_print_styles-' . $this->settings_page, array( $this, 'admin_styles' ) );
202
- add_action( 'admin_print_scripts-' . $this->settings_page, array( $this, 'admin_scripts' ) );
203
- }
204
-
205
- /**
206
- * Allows the capaiblity 'manage_admin_columns' to store data through /wp-admin/options.php
207
- *
208
- * @since 2.0
209
- */
210
- public function add_capability() {
211
- return 'manage_admin_columns';
212
- }
213
-
214
- /**
215
- * @since 1.0
216
- */
217
- public function admin_styles() {
218
-
219
- $minified = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
220
-
221
- wp_enqueue_style( 'wp-pointer' );
222
- wp_enqueue_style( 'cpac-admin', CPAC_URL . "assets/css/admin-column{$minified}.css", array(), CPAC_VERSION, 'all' );
223
- }
224
-
225
- /**
226
- * @since 1.0
227
- */
228
- public function admin_scripts() {
229
-
230
- wp_enqueue_script( 'wp-pointer' );
231
-
232
- // width slider
233
- wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
234
- wp_enqueue_script( 'jquery-ui-slider' );
235
-
236
- $minified = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
237
-
238
- wp_enqueue_script( 'cpac-admin-settings', CPAC_URL . "assets/js/admin-settings{$minified}.js", array(
239
- 'jquery',
240
- 'dashboard',
241
- 'jquery-ui-slider',
242
- 'jquery-ui-sortable',
243
- ), CPAC_VERSION );
244
-
245
- // javascript translations
246
- wp_localize_script( 'cpac-admin-settings', 'cpac_i18n', array(
247
- 'clone' => __( '%s column is already present and can not be duplicated.', 'codepress-admin-columns' ),
248
- 'error' => __( 'Invalid response.', 'codepress-admin-columns' ),
249
- ) );
250
-
251
- // nonce
252
- wp_localize_script( 'cpac-admin-settings', 'cpac', array(
253
- '_ajax_nonce' => wp_create_nonce( 'cpac-settings' ),
254
- ) );
255
- }
256
-
257
- /**
258
- * @since 2.5
259
- */
260
- public function ajax_columns_update() {
261
- check_ajax_referer( 'cpac-settings' );
262
-
263
- if ( ! current_user_can( 'manage_admin_columns' ) ) {
264
- wp_die();
265
- }
266
-
267
- $storage_model = $this->cpac->get_storage_model( filter_input( INPUT_POST, 'storage_model' ) );
268
-
269
- if ( ! $storage_model ) {
270
- wp_die();
271
- }
272
-
273
- $storage_model->set_layout( filter_input( INPUT_POST, 'layout' ) );
274
-
275
- parse_str( $_POST['data'], $formdata );
276
-
277
- if ( ! isset( $formdata[ $storage_model->key ] ) ) {
278
- wp_die();
279
- }
280
-
281
- $stored = $storage_model->store( $formdata[ $storage_model->key ] );
282
-
283
- if ( is_wp_error( $stored ) ) {
284
- wp_send_json_error( array(
285
- 'type' => 'same-settings' === $stored->get_error_code() ? 'notice notice-warning' : 'error',
286
- 'message' => $stored->get_error_message(),
287
- )
288
- );
289
- }
290
-
291
- wp_send_json_success(
292
- sprintf( __( 'Settings for %s updated successfully.', 'codepress-admin-columns' ), "<strong>" . $storage_model->get_label_or_layout_name() . "</strong>" )
293
- . ' <a href="' . $storage_model->get_link() . '">' . sprintf( __( 'View %s screen', 'codepress-admin-columns' ), $storage_model->label ) . '</a>'
294
- );
295
- }
296
-
297
- /**
298
- * @since 1.0
299
- */
300
- public function handle_column_request() {
301
-
302
- // only handle updates from the admin columns page
303
- if ( ! ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns' ) ) && isset( $_REQUEST['cpac_action'] ) ) ) {
304
- return false;
305
- }
306
-
307
- // use $_REQUEST because the values are send both over $_GET and $_POST
308
- $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
309
- $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
310
- $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
311
-
312
- switch ( $action ) :
313
-
314
- case 'restore_by_type' :
315
- if ( wp_verify_nonce( $nonce, 'restore-type' ) && $key ) {
316
- if ( $storage_model = $this->cpac->get_storage_model( $key ) ) {
317
-
318
- if ( isset( $_POST['cpac_layout'] ) ) {
319
- $storage_model->set_layout( $_POST['cpac_layout'] );
320
- }
321
-
322
- $storage_model->restore();
323
- $storage_model->flush_columns();
324
-
325
- cpac_settings_message( sprintf( __( 'Settings for %s restored successfully.', 'codepress-admin-columns' ), "<strong>" . $storage_model->get_label_or_layout_name() . "</strong>" ), 'updated' );
326
- }
327
- }
328
- break;
329
-
330
- case 'restore_all' :
331
- if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
332
- $this->restore_all();
333
- }
334
- break;
335
-
336
- endswitch;
337
- }
338
-
339
- /**
340
- * Restore all column defaults
341
- *
342
- * @since 1.0
343
- */
344
- private function restore_all() {
345
- global $wpdb;
346
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
347
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_layouts%'" );
348
-
349
- cpac_admin_message( __( 'Default settings succesfully restored.', 'codepress-admin-columns' ), 'updated' );
350
- }
351
-
352
- /**
353
- * Add help tabs to top menu
354
- *
355
- * @since 1.3.0
356
- */
357
- public function help_tabs() {
358
-
359
- $screen = get_current_screen();
360
-
361
- if ( ! method_exists( $screen, 'add_help_tab' ) ) {
362
- return;
363
- }
364
-
365
- $tabs = array(
366
- array(
367
- 'title' => __( "Overview", 'codepress-admin-columns' ),
368
- 'content' => "<h5>Admin Columns</h5>
369
- <p>" . __( "This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.", 'codepress-admin-columns' ) . "</p>",
370
- ),
371
- array(
372
- 'title' => __( "Basics", 'codepress-admin-columns' ),
373
- 'content' => "
374
- <h5>" . __( "Change order", 'codepress-admin-columns' ) . "</h5>
375
- <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'codepress-admin-columns' ) . "</p>
376
- <h5>" . __( "Change label", 'codepress-admin-columns' ) . "</h5>
377
- <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'codepress-admin-columns' ) . "</p>
378
- <h5>" . __( "Change column width", 'codepress-admin-columns' ) . "</h5>
379
- <p>" . __( "By clicking on the triangle you will see the column options. By using the draggable slider you can set the width of the columns in percentages.", 'codepress-admin-columns' ) . "</p>
380
- ",
381
- ),
382
- array(
383
- 'title' => __( "Custom Field", 'codepress-admin-columns' ),
384
- 'content' => "<h5>" . __( "'Custom Field' column", 'codepress-admin-columns' ) . "</h5>
385
- <p>" . __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'codepress-admin-columns' ) . "</p>
386
- <ul>
387
- <li><strong>" . __( "Default", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: Can be either a string or array. Arrays will be flattened and values are seperated by a ',' comma.", 'codepress-admin-columns' ) . "</li>
388
- <li><strong>" . __( "Checkmark", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: should be a 1 (one) or 0 (zero).", 'codepress-admin-columns' ) . "</li>
389
- <li><strong>" . __( "Color", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: hex value color, such as #808080.", 'codepress-admin-columns' ) . "</li>
390
- <li><strong>" . __( "Counter", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: Can be either a string or array. This will display a count of the number of times the meta key is used by the item.", 'codepress-admin-columns' ) . "</li>
391
- <li><strong>" . __( "Date", 'codepress-admin-columns' ) . "</strong><br/>" . sprintf( __( "Value: Can be unix time stamp or a date format as described in the <a href='%s'>Codex</a>. You can change the outputted date format at the <a href='%s'>general settings</a> page.", 'codepress-admin-columns' ), 'http://codex.wordpress.org/Formatting_Date_and_Time', get_admin_url() . 'options-general.php' ) . "</li>
392
- <li><strong>" . __( "Excerpt", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: This will show the first 20 words of the Post content.", 'codepress-admin-columns' ) . "</li>
393
- <li><strong>" . __( "Image", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'codepress-admin-columns' ) . "</li>
394
- <li><strong>" . __( "Media Library", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: should contain Attachment IDs ( seperated by a ',' comma ).", 'codepress-admin-columns' ) . "</li>
395
- <li><strong>" . __( "Multiple Values", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'codepress-admin-columns' ) . "</li>
396
- <li><strong>" . __( "Numeric", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: Integers only.<br/>If you have the 'sorting addon' this will be used for sorting, so you can sort your posts on numeric (custom field) values.", 'codepress-admin-columns' ) . "</li>
397
- <li><strong>" . __( "Post Titles", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: can be one or more Post ID's (seperated by ',').", 'codepress-admin-columns' ) . "</li>
398
- <li><strong>" . __( "Usernames", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: can be one or more User ID's (seperated by ',').", 'codepress-admin-columns' ) . "</li>
399
- <li><strong>" . __( "Term Name", 'codepress-admin-columns' ) . "</strong><br/>" . __( "Value: should be an array with term_id and taxonomy.", 'codepress-admin-columns' ) . "</li>
400
- </ul>
401
- ",
402
- ),
403
- );
404
-
405
- foreach ( $tabs as $k => $tab ) {
406
- $screen->add_help_tab( array(
407
- 'id' => 'cpac-tab-' . $k,
408
- 'title' => $tab['title'],
409
- 'content' => $tab['content'],
410
- ) );
411
- }
412
- }
413
-
414
- /**
415
- * @since 1.0
416
- *
417
- * @param string $storage_model URL type.
418
- *
419
- * @return string Url.
420
- */
421
- public function get_url( $type ) {
422
- $urls = array(
423
- 'pricing' => ac_get_site_url( 'pricing-purchase' ),
424
- 'documentation' => ac_get_site_url( 'documentation' ),
425
- );
426
-
427
- return isset( $urls[ $type ] ) ? $urls[ $type ] : false;
428
- }
429
-
430
- /**
431
- * @since 2.0
432
- */
433
- public function uses_custom_fields() {
434
-
435
- $old_columns = get_option( 'cpac_options' );
436
-
437
- if ( empty( $old_columns['columns'] ) ) {
438
- return false;
439
- }
440
-
441
- foreach ( $old_columns['columns'] as $columns ) {
442
- foreach ( $columns as $id => $values ) {
443
- if ( strpos( $id, 'column-meta-' ) !== false ) {
444
- return true;
445
- }
446
- }
447
- }
448
-
449
- return false;
450
- }
451
-
452
- /**
453
- * Welcome screen
454
- *
455
- * @since 2.0
456
- */
457
- public function welcome_screen() {
458
-
459
- // Should only be set after upgrade
460
- $show_welcome = false !== get_transient( 'cpac_show_welcome' );
461
-
462
- // Should only be set manual
463
- if ( isset( $_GET['info'] ) ) {
464
- $show_welcome = true;
465
- }
466
-
467
- if ( ! $show_welcome ) {
468
- return false;
469
- }
470
-
471
- // Set check that welcome should not be displayed.
472
- delete_transient( 'cpac_show_welcome' );
473
-
474
- $tab = ! empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
475
-
476
- ?>
477
-
478
- <div id="cpac-welcome" class="wrap about-wrap">
479
-
480
- <h1><?php _e( "Welcome to Admin Columns", 'codepress-admin-columns' ); ?><?php echo CPAC_VERSION; ?></h1>
481
-
482
- <div class="about-text">
483
- <?php _e( "Thank you for updating to the latest version!", 'codepress-admin-columns' ); ?>
484
- <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'codepress-admin-columns' ); ?>
485
- </div>
486
-
487
- <div class="cpac-content-body">
488
- <h2 class="nav-tab-wrapper">
489
- <a class="cpac-tab-toggle nav-tab <?php if ( $tab == 'whats-new' ) {
490
- echo 'nav-tab-active';
491
- } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>whats-new"><?php _e( "What’s New", 'codepress-admin-columns' ); ?></a>
492
- <a class="cpac-tab-toggle nav-tab <?php if ( $tab == 'changelog' ) {
493
- echo 'nav-tab-active';
494
- } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>changelog"><?php _e( "Changelog", 'codepress-admin-columns' ); ?></a>
495
- </h2>
496
-
497
- <?php if ( 'whats-new' === $tab ) : ?>
498
-
499
- <h3><?php _e( "Important", 'codepress-admin-columns' ); ?></h3>
500
-
501
- <h4><?php _e( "Database Changes", 'codepress-admin-columns' ); ?></h4>
502
- <p><?php _e( "The database has been changed between versions 1 and 2. But we made sure you can still roll back to version 1x without any issues.", 'codepress-admin-columns' ); ?></p>
503
-
504
- <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
505
- <p><?php _e( "Make sure you backup your database and then click", 'codepress-admin-columns' ); ?>
506
- <a href="<?php echo $this->get_settings_url( 'upgrade' ); ?>" class="button-primary"><?php _e( "Upgrade Database", 'codepress-admin-columns' ); ?></a>
507
- </p>
508
- <?php endif; ?>
509
-
510
- <h4><?php _e( "Potential Issues", 'codepress-admin-columns' ); ?></h4>
511
- <p><?php _e( "Do to the sizable refactoring the code, surounding Addons and action/filters, your website may not operate correctly. It is important that you read the full", 'codepress-admin-columns' ); ?>
512
- <a href="<?php ac_site_url(); ?>migrating-from-v1-to-v2" target="_blank"><?php _e( "Migrating from v1 to v2", 'codepress-admin-columns' ); ?></a> <?php _e( "guide to view the full list of changes.", 'codepress-admin-columns' ); ?> <?php printf( __( "When you have found a bug please <a href='%s'>report them to us</a> so we can fix it in the next release.", 'codepress-admin-columns' ), 'mailto:info@codepress.nl' ); ?>
513
- </p>
514
-
515
- <div class="cpac-alert cpac-alert-error">
516
- <p>
517
- <strong><?php _e( "Important!", 'codepress-admin-columns' ); ?></strong> <?php _e( "If you updated the Admin Columns plugin without prior knowledge of such changes, Please roll back to the latest", 'codepress-admin-columns' ); ?>
518
- <a href="http://downloads.wordpress.org/plugin/codepress-admin-columns.1.4.9.zip"> <?php _e( "version 1", 'codepress-admin-columns' ); ?></a> <?php _e( "of this plugin.", 'codepress-admin-columns' ); ?>
519
- </p>
520
- </div>
521
-
522
- <?php endif; ?>
523
- <?php if ( 'changelog' === $tab ) : ?>
524
-
525
- <h3><?php _e( "Changelog for", 'codepress-admin-columns' ); ?><?php echo CPAC_VERSION; ?></h3>
526
- <?php
527
-
528
- $items = file_get_contents( CPAC_DIR . 'readme.txt' );
529
- $items = explode( '= ' . CPAC_VERSION . ' =', $items );
530
- $items = end( $items );
531
- $items = current( explode( "\n\n", $items ) );
532
- $items = current( explode( "= ", $items ) );
533
- $items = array_filter( array_map( 'trim', explode( "*", $items ) ) );
534
-
535
- ?>
536
- <ul class="cpac-changelog">
537
- <?php foreach ( $items as $item ) :
538
- $item = explode( 'http', $item );
539
- ?>
540
- <li><?php echo $item[0]; ?><?php if ( isset( $item[1] ) ): ?><a
541
- href="http<?php echo $item[1]; ?>"
542
- target="_blank"><?php _e( "Learn more", 'codepress-admin-columns' ); ?></a><?php endif; ?>
543
- </li>
544
- <?php endforeach; ?>
545
- </ul>
546
-
547
- <?php endif; ?>
548
- <hr/>
549
-
550
- </div><!--.cpac-content-body-->
551
-
552
- <div class="cpac-content-footer">
553
- <a class="button-primary button-large" href="<?php echo $this->get_settings_url( 'general' ); ?>"><?php _e( "Start using Admin Columns", 'codepress-admin-columns' ); ?></a>
554
- </div><!--.cpac-content-footer-->
555
-
556
- </div>
557
- <?php
558
-
559
- return true;
560
- }
561
-
562
- /**
563
- * @since 1.0
564
- */
565
- public function display_settings() {
566
- ?>
567
- <table class="form-table cpac-form-table settings">
568
- <tbody>
569
-
570
- <tr class="general">
571
- <th scope="row">
572
- <h3><?php _e( 'General Settings', 'codepress-admin-columns' ); ?></h3>
573
-
574
- <p><?php _e( 'Customize your Admin Columns settings.', 'codepress-admin-columns' ); ?></p>
575
- </th>
576
- <td class="padding-22">
577
- <div class="cpac_general">
578
- <form method="post" action="options.php">
579
- <?php settings_fields( 'cpac-general-settings' ); ?>
580
- <?php $options = get_option( 'cpac_general_options' ); ?>
581
- <p>
582
- <label for="show_edit_button">
583
- <input name="cpac_general_options[show_edit_button]" type="hidden" value="0">
584
- <input name="cpac_general_options[show_edit_button]" id="show_edit_button" type="checkbox" value="1" <?php checked( ! isset( $options['show_edit_button'] ) || ( '1' == $options['show_edit_button'] ) ); ?>>
585
- <?php _e( "Show \"Edit Columns\" button on admin screens. Default is <code>on</code>.", 'codepress-admin-columns' ); ?>
586
- </label>
587
- </p>
588
-
589
- <?php do_action( 'cac/settings/general', $options ); ?>
590
-
591
- <p>
592
- <input type="submit" class="button" value="<?php _e( 'Save' ); ?>"/>
593
- </p>
594
- </form>
595
- </div>
596
- </td>
597
- </tr><!--.general-->
598
-
599
- <?php
600
-
601
- /** Allow plugins to add their own custom settings to the settings page. */
602
- if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
603
-
604
- foreach ( $groups as $id => $group ) {
605
-
606
- $title = isset( $group['title'] ) ? $group['title'] : '';
607
- $description = isset( $group['description'] ) ? $group['description'] : '';
608
-
609
- ?>
610
- <tr>
611
- <th scope="row">
612
- <h3><?php echo $title; ?></h3>
613
-
614
- <p><?php echo $description; ?></p>
615
- </th>
616
- <td class="padding-22">
617
- <?php
618
-
619
- /** Use this Hook to add additonal fields to the group */
620
- do_action( "cac/settings/groups/row={$id}" );
621
-
622
- ?>
623
- </td>
624
- </tr>
625
- <?php
626
- }
627
- }
628
- ?>
629
-
630
- <tr class="restore">
631
- <th scope="row">
632
- <h3><?php _e( 'Restore Settings', 'codepress-admin-columns' ); ?></h3>
633
- <p><?php _e( 'This will delete all column settings and restore the default settings.', 'codepress-admin-columns' ); ?></p>
634
- </th>
635
- <td class="padding-22">
636
- <form method="post">
637
- <?php wp_nonce_field( 'restore-all', '_cpac_nonce' ); ?>
638
- <input type="hidden" name="cpac_action" value="restore_all"/>
639
- <input type="submit" class="button" name="cpac-restore-defaults" value="<?php _e( 'Restore default settings', 'codepress-admin-columns' ) ?>" onclick="return confirm('<?php _e( "Warning! ALL saved admin columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", 'codepress-admin-columns' ); ?>');"/>
640
- </form>
641
- </td>
642
- </tr><!--.restore-->
643
-
644
- </tbody>
645
- </table>
646
-
647
- <?php
648
- }
649
-
650
- public function sort_by_label( $a, $b ) {
651
- return strcmp( $a->label, $b->label );
652
- }
653
-
654
- private function set_user_model_preference( $storage_model_key ) {
655
- update_user_meta( get_current_user_id(), self::OPTION_CURRENT, $storage_model_key );
656
- }
657
-
658
- private function delete_user_model_preference() {
659
- delete_user_meta( get_current_user_id(), self::OPTION_CURRENT );
660
- }
661
-
662
- private function get_user_model_preference() {
663
- return cpac()->get_storage_model( get_user_meta( get_current_user_id(), self::OPTION_CURRENT, true ) );
664
- }
665
-
666
- public function get_settings_storage_model() {
667
-
668
- if ( isset( $_REQUEST['cpac_key'] ) ) {
669
-
670
- // By request
671
- if ( $_storage_model = cpac()->get_storage_model( $_REQUEST['cpac_key'] ) ) {
672
- $storage_model = $_storage_model;
673
- }
674
-
675
- // User preference
676
- else if ( $_storage_model = $this->get_user_model_preference() ) {
677
- $storage_model = $_storage_model;
678
- }
679
-
680
- // First one served
681
- else {
682
- $storage_model = cpac()->get_first_storage_model();
683
- }
684
-
685
- $this->set_user_model_preference( $storage_model->key );
686
- }
687
-
688
- else {
689
-
690
- // User preference
691
- if ( $exists = $this->get_user_model_preference() ) {
692
- $storage_model = $exists;
693
- }
694
-
695
- // First one served
696
- else {
697
- $storage_model = cpac()->get_first_storage_model();
698
- }
699
- }
700
-
701
- // Init layout
702
- $storage_model->init_settings_layout();
703
-
704
- return $storage_model;
705
- }
706
-
707
- public function messages() {
708
- if ( ! empty( $GLOBALS['cpac_settings_messages'] ) ) {
709
- echo implode( $GLOBALS['cpac_settings_messages'] );
710
- }
711
- }
712
-
713
- /**
714
- * @since 1.0
715
- */
716
- public function display() {
717
-
718
- if ( $this->welcome_screen() ) {
719
- return;
720
- }
721
-
722
- $tabs = array(
723
- 'general' => __( 'Admin Columns', 'codepress-admin-columns' ),
724
- 'settings' => __( 'Settings', 'codepress-admin-columns' ),
725
- 'addons' => __( 'Add-ons', 'codepress-admin-columns' ),
726
- );
727
-
728
- /**
729
- * Filter the tabs on the settings screen
730
- *
731
- * @param array $tabs Available tabs
732
- */
733
- $tabs = apply_filters( 'cac/settings/tabs', $tabs );
734
-
735
- $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
736
- ?>
737
- <div id="cpac" class="wrap">
738
- <?php screen_icon( 'codepress-admin-columns' ); ?>
739
- <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
740
- <?php foreach ( $tabs as $name => $label ) : ?>
741
- <a href="<?php echo $this->get_settings_url( 'admin' ) . "&amp;tab={$name}"; ?>"
742
- class="nav-tab<?php if ( $current_tab == $name ) {
743
- echo ' nav-tab-active';
744
- } ?>"><?php echo $label; ?></a>
745
- <?php endforeach; ?>
746
- </h2>
747
-
748
- <?php do_action( 'cpac_messages' ); ?>
749
-
750
- <?php
751
- switch ( $current_tab ) :
752
- case 'general':
753
-
754
- $storage_model = $this->get_settings_storage_model();
755
- $has_been_stored = $storage_model->get_stored_columns() ? true : false;
756
-
757
- // columns should not be editable when layout isn't
758
- if ( $layout = $storage_model->get_layout_object() ) {
759
- if ( isset( $layout->not_editable ) ) {
760
- $storage_model->enable_php_export();
761
- }
762
- }
763
-
764
- // Grouped storage models
765
- $grouped = array();
766
- foreach ( cpac()->get_storage_models() as $_storage_model ) {
767
- $grouped[ $_storage_model->get_menu_type() ][] = (object) array(
768
- 'key' => $_storage_model->key,
769
- 'link' => $_storage_model->settings_url(),
770
- 'label' => $_storage_model->label,
771
- );
772
- usort( $grouped[ $_storage_model->get_menu_type() ], array( $this, 'sort_by_label' ) );
773
- }
774
-
775
- ?>
776
-
777
- <?php do_action( 'cac/settings/after_menu' ); ?>
778
-
779
- <div class="columns-container<?php echo $has_been_stored ? ' stored' : ''; ?>" data-type="<?php echo $storage_model->key ?>" data-layout="<?php echo $storage_model->get_layout(); ?>">
780
-
781
- <div class="main">
782
-
783
- <div class="menu">
784
- <select id="cpac_storage_modal_select">
785
- <?php foreach ( $grouped as $menu_type => $models ) : ?>
786
- <optgroup label="<?php echo esc_attr( $menu_type ); ?>">
787
- <?php foreach ( $models as $model ) : ?>
788
- <option value="<?php echo esc_attr( $model->link ); ?>" <?php selected( $model->key, $storage_model->key ); ?>><?php echo esc_html( $model->label ); ?></option>
789
- <?php endforeach; ?>
790
- </optgroup>
791
- <?php endforeach; ?>
792
- </select>
793
- <span class="spinner"></span>
794
-
795
- <?php $storage_model->screen_link(); ?>
796
- </div>
797
-
798
-
799
- <?php do_action( 'cac/settings/after_title', $storage_model ); ?>
800
-
801
- </div>
802
-
803
- <div class="columns-right">
804
- <div class="columns-right-inside">
805
- <?php if ( ! $storage_model->is_using_php_export() ) : ?>
806
- <div class="sidebox form-actions">
807
- <?php $label = __( 'Store settings', 'codepress-admin-columns' ); ?>
808
- <h3>
809
- <span class="left"><?php echo $label; ?></span>
810
- <?php if ( 18 > strlen( $label ) && ( $truncated_label = $storage_model->get_truncated_side_label( $label ) ) ) : ?>
811
- <span class="right contenttype"><?php echo esc_html( $truncated_label ); ?></span>
812
- <?php else : ?>
813
- <span class="clear contenttype"><?php echo esc_html( $storage_model->label ); ?></span>
814
- <?php endif; ?>
815
- </h3>
816
-
817
- <div class="form-update">
818
- <a href="javascript:;" class="button-primary submit update"><?php _e( 'Update' ); ?></a>
819
- <a href="javascript:;" class="button-primary submit save"><?php _e( 'Save' ); ?></a>
820
- </div>
821
-
822
- <form class="form-reset" method="post">
823
- <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>"/>
824
- <input type="hidden" name="cpac_action" value="restore_by_type"/>
825
- <input type="hidden" name="cpac_layout" value="<?php echo $storage_model->layout; ?>"/>
826
- <?php wp_nonce_field( 'restore-type', '_cpac_nonce' ); ?>
827
-
828
- <?php $onclick = $this->cpac->use_delete_confirmation() ? ' onclick="return confirm(\'' . esc_attr( addslashes( sprintf( __( "Warning! The %s columns data will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop", 'codepress-admin-columns' ), "'" . $storage_model->get_label_or_layout_name() . "'" ) ) ) . '\');"' : ''; ?>
829
- <input class="reset-column-type" type="submit"<?php echo $onclick; ?> value="<?php _e( 'Restore columns', 'codepress-admin-columns' ); ?>">
830
- <span class="spinner"></span>
831
- </form>
832
-
833
- <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
834
-
835
- </div><!--form-actions-->
836
- <?php endif; ?>
837
-
838
- <?php do_action( 'cac/settings/sidebox', $storage_model ); ?>
839
-
840
- <?php if ( ! cpac_is_pro_active() ) : ?>
841
-
842
- <?php $url_args = array(
843
- 'utm_source' => 'plugin-installation',
844
- 'utm_medium' => 'banner',
845
- 'utm_campaign' => 'plugin-installation',
846
- );
847
-
848
- $active_promotion = false;
849
-
850
- $promotions = array(
851
-
852
- // Black Friday
853
- array(
854
- 'title' => '30% Off from Black Friday until Cyber Monday',
855
- 'button' => sprintf( __( 'Get %s Off' ), '30%' ),
856
- 'date_start' => '2016-11-24',
857
- 'date_end' => '2016-11-29',
858
- ),
859
- );
860
-
861
- $today = date( 'Y-m-d' );
862
-
863
- foreach ( $promotions as $promotion ) {
864
- if ( $today >= $promotion['date_start'] && $today <= $promotion['date_end'] ) {
865
- $active_promotion = $promotion;
866
- break;
867
- }
868
- }
869
-
870
- ?>
871
- <div class="sidebox" id="ac-pro-version">
872
- <div class="padding-box">
873
- <h3>
874
- <a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'title' ) ), ac_get_site_url() ); ?>"><?php _e( 'Upgrade to', 'codepress-admin-columns' ); ?>&nbsp;<span>Pro</span></a>
875
- </h3>
876
-
877
- <div class="inside">
878
- <p><?php _e( 'Take Admin Columns to the next level:', 'codepress-admin-columns' ); ?></p>
879
- <ul>
880
- <li>
881
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-sorting' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><?php _e( 'Add sortable columns', 'codepress-admin-columns' ); ?></a>
882
- </li>
883
- <li>
884
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-filtering' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><?php _e( 'Add filterable columns', 'codepress-admin-columns' ); ?></a>
885
- </li>
886
- <li>
887
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-editing' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><?php _e( 'Edit your column content', 'codepress-admin-columns' ); ?></a>
888
- </li>
889
- <li>
890
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-columns-sets' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><?php _e( 'Create multiple columns sets', 'codepress-admin-columns' ); ?></a>
891
- </li>
892
- <li>
893
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-import-export' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><?php _e( 'Import &amp; Export settings', 'codepress-admin-columns' ); ?></a>
894
- </li>
895
- <?php if ( cpac()->is_plugin_acf_active() ) : ?>
896
- <li class="acp-integration">
897
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-import-export' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><img class="acf" src="<?php echo CPAC_URL; ?>assets/images/logo-acf.png" alt="ACF"> <?php _e( 'Columns', 'codepress-admin-columns' ); ?></a>
898
- </li>
899
- <?php endif; ?>
900
- <?php if ( cpac()->is_plugin_woocommerce_active() ) : ?>
901
- <li class="acp-integration">
902
- <a href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-import-export' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>"><img class="woocommerce" src="<?php echo CPAC_URL; ?>assets/images/logo-woocommerce.png" alt="WooCommerce"> <?php _e( 'Columns', 'codepress-admin-columns' ); ?></a>
903
- </li>
904
- <?php endif; ?>
905
- </ul>
906
-
907
- <?php if ( ! $active_promotion ) : ?>
908
- <a target="_blank" href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'promo' ) ), ac_get_site_url() . '/upgrade-to-admin-columns-pro/' ) ); ?>" class="acp-button"><?php echo __( 'Learn more about Pro' ); ?></a>
909
- <?php endif; ?>
910
- </div>
911
- </div>
912
- <?php if ( $active_promotion ) : ?>
913
- <div class="padding-box ac-pro-deal">
914
- <h3><?php echo $active_promotion['title']; ?></h3>
915
- <a target="_blank" href="<?php echo esc_url( add_query_arg( array_merge( $url_args, array( 'utm_content' => 'cta' ) ), ac_get_site_url() . '/pricing-purchase/' ) ); ?>" class="acp-button"><?php echo $promotion['button']; ?></a>
916
- </div>
917
- <?php endif; ?>
918
- </div>
919
-
920
- <div class="sidebox" id="direct-feedback">
921
- <div id="feedback-choice">
922
- <h3><?php _e( 'Are you happy with Admin Columns?', 'codepress-admin-columns' ); ?></h3>
923
-
924
- <div class="inside">
925
- <a href="#" class="yes">Yes</a>
926
- <a href="#" class="no">No</a>
927
- </div>
928
- </div>
929
- <div id="feedback-support">
930
- <div class="inside">
931
- <p><?php _e( "What's wrong? Need help? Let us know!", 'codepress-admin-columns' ); ?></p>
932
-
933
- <p><?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'codepress-admin-columns' ); ?></p>
934
- <ul class="share">
935
- <li>
936
- <a href="<?php echo add_query_arg( array(
937
- 'utm_source' => 'plugin-installation',
938
- 'utm_medium' => 'feedback-docs-button',
939
- 'utm_campaign' => 'plugin-installation',
940
- ), $this->get_url( 'documentation' ) ); ?>" target="_blank">
941
- <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'codepress-admin-columns' ); ?>
942
- </a>
943
- </li>
944
- <li>
945
- <a href="https://wordpress.org/support/plugin/codepress-admin-columns"
946
- target="_blank">
947
- <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'codepress-admin-columns' ); ?>
948
- </a>
949
- </li>
950
- </ul>
951
- <div class="clear"></div>
952
- </div>
953
- </div>
954
- <div id="feedback-rate">
955
- <div class="inside">
956
- <p><?php _e( "Woohoo! We're glad to hear that!", 'codepress-admin-columns' ); ?></p>
957
-
958
- <p><?php _e( 'We would really love it if you could show your appreciation by giving us a rating on WordPress.org or tweet about Admin Columns!', 'codepress-admin-columns' ); ?></p>
959
- <ul class="share">
960
- <li>
961
- <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
962
- <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'codepress-admin-columns' ); ?>
963
- </a>
964
- </li>
965
-
966
- <li>
967
- <a href="<?php echo add_query_arg( array(
968
- 'hashtags' => 'admincolumns',
969
- 'text' => urlencode( "I'm using Admin Columns for WordPress!" ),
970
- 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ),
971
- 'via' => 'wpcolumns',
972
- ), 'https://twitter.com/intent/tweet' ); ?>" target="_blank">
973
- <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'codepress-admin-columns' ); ?>
974
- </a>
975
- </li>
976
-
977
- <li>
978
- <a href="<?php echo add_query_arg( array(
979
- 'utm_source' => 'plugin-installation',
980
- 'utm_medium' => 'feedback-purchase-button',
981
- 'utm_campaign' => 'plugin-installation',
982
- ), ac_get_site_url() ); ?>" target="_blank">
983
- <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'codepress-admin-columns' ); ?>
984
- </a>
985
- </li>
986
- </ul>
987
- <div class="clear"></div>
988
- </div>
989
- </div>
990
- </div>
991
-
992
- <?php endif; ?>
993
-
994
- <div class="sidebox" id="plugin-support">
995
- <h3><?php _e( 'Support', 'codepress-admin-columns' ); ?></h3>
996
-
997
- <div class="inside">
998
- <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
999
- <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'codepress-admin-columns' ); ?></p>
1000
- <?php endif; ?>
1001
- <p>
1002
- <?php printf( __( "For full documentation, bug reports, feature suggestions and other tips <a href='%s'>visit the Admin Columns website</a>", 'codepress-admin-columns' ), $this->get_url( 'documentation' ) ); ?>
1003
- </p>
1004
- </div>
1005
- </div><!--plugin-support-->
1006
-
1007
- </div><!--.columns-right-inside-->
1008
- </div><!--.columns-right-->
1009
-
1010
- <div class="columns-left">
1011
- <?php if ( ! $storage_model->get_default_stored_columns() && ! $storage_model->is_using_php_export() ): ?>
1012
- <div class="cpac-notice">
1013
- <p>
1014
- <?php echo sprintf( __( 'Please visit the %s screen once to load all available columns', 'codepress-admin-columns' ), "<a href='" . $storage_model->get_link() . "'>" . esc_html( $storage_model->label ) . "</a>" ); ?>
1015
- </p>
1016
- </div>
1017
- <?php endif ?>
1018
-
1019
- <?php $this->messages(); ?>
1020
-
1021
- <div class="ajax-message"><p></p></div>
1022
-
1023
- <?php if ( $storage_model->is_using_php_export() ) : ?>
1024
- <div class="notice notice-warning below-h2">
1025
- <p><?php printf( __( 'The columns for %s are set up via PHP and can therefore not be edited', 'codepress-admin-columns' ), '<strong>' . $storage_model->label . '</strong>' ); ?></p>
1026
- </div>
1027
- <?php endif; ?>
1028
-
1029
- <div class="cpac-boxes<?php echo $storage_model->is_using_php_export() ? ' disabled' : ''; ?>">
1030
-
1031
- <div class="cpac-columns">
1032
- <form method="post" action="<?php echo $storage_model->get_edit_link(); ?>">
1033
-
1034
- <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>"/>
1035
- <input type="hidden" name="cpac_action" value="update_by_type"/>
1036
- <input type="hidden" name="cpac_layout" value="<?php echo $storage_model->layout; ?>"/>
1037
-
1038
- <?php do_action( 'cac/settings/form_columns', $storage_model ); ?>
1039
-
1040
- <?php wp_nonce_field( 'update-type', '_cpac_nonce' ); ?>
1041
-
1042
- <?php
1043
- foreach ( $storage_model->get_columns() as $column ) {
1044
- $column->display();
1045
- }
1046
- ?>
1047
- </form>
1048
-
1049
- </div><!--.cpac-columns-->
1050
-
1051
- <div class="column-footer">
1052
- <?php if ( ! $storage_model->is_using_php_export() ) : ?>
1053
- <div class="order-message">
1054
- <?php _e( 'Drag and drop to reorder', 'codepress-admin-columns' ); ?>
1055
- </div>
1056
- <div class="button-container">
1057
- <a href="javascript:;" class="add_column button-primary">+ <?php _e( 'Add Column', 'codepress-admin-columns' ); ?></a>
1058
- <?php /*<a href="javascript:;" class="button-primary submit update"><?php _e( 'Update' ); ?></a>*/ ?>
1059
- <?php /*<a href="javascript:;" class="button-primary submit save"><?php _e( 'Save' ); ?></a>*/ ?>
1060
- </div>
1061
- <?php endif; ?>
1062
- </div><!--.cpac-column-footer-->
1063
-
1064
- </div><!--.cpac-boxes-->
1065
-
1066
- <?php do_action( 'cac/settings/after_columns', $storage_model ); ?>
1067
-
1068
- </div><!--.columns-left-->
1069
- <div class="clear"></div>
1070
-
1071
- <div class="for-cloning-only" style="display:none">
1072
- <?php
1073
- foreach ( $storage_model->get_column_types() as $column ) {
1074
- $column->display();
1075
- }
1076
- ?>
1077
- </div>
1078
-
1079
- </div><!--.columns-container-->
1080
-
1081
- <div class="clear"></div>
1082
- <?php
1083
- break;
1084
- case 'settings' :
1085
- $this->display_settings();
1086
- break;
1087
- case 'addons' :
1088
- $this->tab_addons();
1089
- break;
1090
- default:
1091
-
1092
- /**
1093
- * Action to add tab contents
1094
- *
1095
- */
1096
- do_action( 'cac/settings/tab_contents/tab=' . $current_tab );
1097
-
1098
- endswitch;
1099
- ?>
1100
- </div><!--.wrap-->
1101
- <?php
1102
- }
1103
-
1104
- /**
1105
- * @since 2.2
1106
- */
1107
- public function tab_addons() {
1108
-
1109
- $addon_groups = $this->cpac->addons()->get_addon_groups();
1110
- $grouped_addons = $this->cpac->addons()->get_available_addons( true );
1111
- ?>
1112
- <?php foreach ( $grouped_addons as $group_name => $addons ) : ?>
1113
- <h3><?php echo $addon_groups[ $group_name ]; ?></h3>
1114
-
1115
- <ul class="cpac-addons">
1116
- <?php foreach ( $addons as $addon_name => $addon ) : ?>
1117
- <li>
1118
- <div class="cpac-addon-content">
1119
- <?php if ( ! empty( $addon['image'] ) ) : ?>
1120
- <img src="<?php echo $addon['image']; ?>"/>
1121
- <?php else : ?>
1122
- <h3><?php echo $addon['title']; ?></h3>
1123
- <?php endif; ?>
1124
- </div>
1125
- <div class="cpac-addon-header">
1126
- <h3><?php echo $addon['title']; ?></h3>
1127
-
1128
- <p><?php echo $addon['description']; ?></p>
1129
- </div>
1130
- <div class="cpac-addon-actions">
1131
- <?php
1132
-
1133
- // Installed..
1134
- if ( ( $plugin_basename = $this->cpac->addons()->get_installed_addon_plugin_basename( $addon_name ) ) ) : ?>
1135
- <?php if ( is_plugin_active( $plugin_basename ) ) : ?>
1136
- <?php $deactivation_url = wp_nonce_url( add_query_arg( array(
1137
- 'action' => 'deactivate',
1138
- 'plugin' => urlencode( $plugin_basename ),
1139
- 'cpac-redirect' => true,
1140
- ), admin_url( 'plugins.php' ) ), 'deactivate-plugin_' . $plugin_basename ); ?>
1141
- <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Active', 'codepress-admin-columns' ); ?></a>
1142
- <a href="<?php echo esc_attr( $deactivation_url ); ?>" class="button right"><?php _e( 'Deactivate', 'codepress-admin-columns' ); ?></a>
1143
- <?php else : ?>
1144
- <?php $activation_url = wp_nonce_url( add_query_arg( array(
1145
- 'action' => 'activate',
1146
- 'plugin' => urlencode( $plugin_basename ),
1147
- 'cpac-redirect' => true,
1148
- ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_basename ); ?>
1149
- <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Installed', 'codepress-admin-columns' ); ?></a>
1150
- <a href="<?php echo esc_attr( $activation_url ); ?>" class="button right"><?php _e( 'Activate', 'codepress-admin-columns' ); ?></a>
1151
- <?php endif; ?>
1152
- <?php
1153
-
1154
- // Not installed...
1155
- else :
1156
-
1157
- // Got ACP?
1158
- if ( class_exists( 'CAC_Addon_Pro' ) ) :
1159
- $install_url = wp_nonce_url( add_query_arg( array(
1160
- 'action' => 'install',
1161
- 'plugin' => $addon_name,
1162
- ), $this->get_settings_url( 'addons' ) ), 'install-cac-addon' );
1163
- ?>
1164
- <a href="<?php echo esc_attr( $install_url ); ?>" class="button"><?php _e( 'Download & Install', 'codepress-admin-columns' ); ?></a>
1165
- <?php
1166
-
1167
- // Get ACP?
1168
- else : ?>
1169
- <a target="_blank" href="<?php echo esc_attr( $this->get_url( 'pricing' ) ); ?>" class="button"><?php _e( 'Get this add-on', 'codepress-admin-columns' ); ?></a>
1170
- <?php endif; ?>
1171
- <?php endif; ?>
1172
- </div>
1173
- </li>
1174
- <?php endforeach; // addons ?>
1175
- </ul>
1176
- <?php endforeach; // grouped_addons ?>
1177
- <?php
1178
- }
1179
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model.php DELETED
@@ -1,1153 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Storage Model
5
- *
6
- * @since 2.0
7
- */
8
- abstract class CPAC_Storage_Model {
9
-
10
- CONST OPTIONS_KEY = 'cpac_options';
11
-
12
- CONST LAYOUT_KEY = 'cpac_layouts';
13
-
14
- /**
15
- * @since 2.0
16
- */
17
- public $label;
18
-
19
- /**
20
- * @since 2.3.5
21
- */
22
- public $singular_label;
23
-
24
- /**
25
- * Identifier for Storage Model; Posttype etc.
26
- *
27
- * @since 2.0
28
- */
29
- public $key;
30
-
31
- /**
32
- * Type of storage model; Post, Media, User or Comments
33
- *
34
- * @since 2.0
35
- */
36
- public $type;
37
-
38
- /**
39
- * Meta type of storage model; post, user, comment. Mostly used for custom field data.
40
- *
41
- * @since 3.0
42
- */
43
- public $meta_type;
44
-
45
- /**
46
- * Groups the storage model in the menu.
47
- *
48
- * @since 2.0
49
- */
50
- public $menu_type;
51
-
52
- /**
53
- * @since 2.4.3
54
- */
55
- private $column_headings;
56
-
57
- /**
58
- * @since 2.0
59
- * @var string
60
- */
61
- public $page;
62
-
63
- /**
64
- * @since 2.4.10
65
- * @var string
66
- */
67
- public $subpage;
68
-
69
- /**
70
- * @since 2.5
71
- * @var string
72
- */
73
- public $screen;
74
-
75
- /**
76
- * Active layout for presets
77
- *
78
- * @since 2.5
79
- * @var string
80
- */
81
- public $layout;
82
-
83
- /**
84
- * Uses PHP export to display settings
85
- *
86
- * @since 2.0
87
- * @var string
88
- */
89
- private $php_export = false;
90
-
91
- /**
92
- * @since 2.0.1
93
- * @var array
94
- */
95
- protected $columns_filepath;
96
-
97
- /**
98
- * @since 2.0.1
99
- * @var array
100
- */
101
- private $columns = array();
102
-
103
- /**
104
- * @since 2.2
105
- * @var array
106
- */
107
- private $column_types = array();
108
-
109
- /**
110
- * @since 2.5
111
- * @var array
112
- */
113
- private $stored_columns = array();
114
-
115
- /**
116
- * @since 2.4.4
117
- */
118
- abstract function get_default_column_names();
119
-
120
- /**
121
- * @since 2.0
122
- * @return array Column Name | Column Label
123
- */
124
- abstract function get_default_columns();
125
-
126
- /**
127
- * @since 2.2
128
- */
129
- function __construct() {
130
- $this->set_columns_filepath();
131
- }
132
-
133
- /**
134
- * Get the default column widths in percentages
135
- *
136
- * @since 2.5
137
- */
138
- protected function get_default_column_widths() {
139
- }
140
-
141
- /**
142
- * @since 2.5
143
- */
144
- public function get_grouped_columns() {
145
- $grouped = array();
146
- foreach ( $this->column_types as $type => $column ) {
147
-
148
- // Labels with html will be replaced by the it's name.
149
- $grouped[ $column->properties->group ][ $type ] = ( 0 === strlen( strip_tags( $column->properties->label ) ) ) ? ucfirst( $column->properties->name ) : ucfirst( $column->properties->label );
150
- asort( $grouped[ $column->properties->group ] );
151
- }
152
-
153
- krsort( $grouped );
154
-
155
- return apply_filters( 'cac/grouped_columns', $grouped, $this );
156
- }
157
-
158
- public function get_screen_id() {
159
- return $this->screen ? $this->screen : $this->page;
160
- }
161
-
162
- /**
163
- * @since 2.5
164
- */
165
- public function get_column_types() {
166
-
167
- if ( empty( $this->column_types ) ) {
168
-
169
- $column_types = array();
170
-
171
- // Get default column that have been set on the listings screen
172
- $default_columns = $this->get_default_stored_columns();
173
-
174
- // As a fallback we can use the table headings. this is not reliable, because most 3rd party column will not be loaded at this point.
175
- if ( empty( $default_columns ) ) {
176
- $default_columns = $this->get_default_column_headings();
177
- }
178
-
179
- // Default columns
180
- if ( $default_columns ) {
181
-
182
- // Remove checkbox
183
- if ( isset( $default_columns['cb'] ) ) {
184
- unset( $default_columns['cb'] );
185
- }
186
-
187
- /**
188
- * Filter the default column names
189
- *
190
- * @since 2.4.4
191
- *
192
- * @param array $default_column_names Default column names
193
- * @param object $column Column object
194
- * @param object $this Storage_Model object
195
- */
196
- $default_column_names = apply_filters( 'cac/default_column_names', $this->get_default_column_names(), $this );
197
- $default_column_widths = apply_filters( 'cac/default_column_widths', $this->get_default_column_widths(), $this );
198
-
199
- foreach ( $default_columns as $name => $label ) {
200
- $column = $this->create_column_instance( $name, $label );
201
-
202
- // If it's not a default column it probably is set by a plugin
203
- if ( $default_column_names && ! in_array( $name, $default_column_names ) ) {
204
- $column->set_properties( 'group', __( 'Columns by Plugins', 'codepress-admin-columns' ) );
205
- }
206
-
207
- // Set the default percentage
208
- if ( $default_column_widths && isset( $default_column_widths[ $name ] ) ) {
209
- $column->set_options( 'width', $default_column_widths[ $name ]['width'] );
210
-
211
- if ( isset( $default_column_widths[ $name ]['unit'] ) ) {
212
- $column->set_options( 'width_unit', $default_column_widths[ $name ]['unit'] );
213
- }
214
- }
215
-
216
- $column_types[ $name ] = $column;
217
- }
218
- }
219
-
220
- // Custom columns
221
- foreach ( $this->columns_filepath as $classname => $path ) {
222
- include_once $path;
223
- if ( class_exists( $classname, false ) ) {
224
- $column = new $classname( $this->key );
225
-
226
- if ( $column->is_registered() ) {
227
- $column_types[ $column->get_type() ] = $column;
228
- }
229
- }
230
- }
231
-
232
- $this->column_types = $column_types;
233
-
234
- // @since 2.5
235
- do_action( "cac/column_types", $this->column_types, $this );
236
- do_action( "cac/column_types/storage_key={$this->key}", $this->column_types, $this );
237
- }
238
-
239
- return $this->column_types;
240
- }
241
-
242
- /**
243
- * @since 2.5
244
- */
245
- private function get_default_colummn_types() {
246
- $defaults = array();
247
-
248
- foreach ( $this->get_column_types() as $type => $column ) {
249
- if ( $column->is_default() || $column->is_original() ) {
250
- $defaults[ $type ] = $column;
251
- }
252
- }
253
-
254
- return $defaults;
255
- }
256
-
257
- /**
258
- * @since 2.5
259
- */
260
- public function get_column_type( $type ) {
261
- $column_types = $this->get_column_types();
262
-
263
- return isset( $column_types[ $type ] ) ? $column_types[ $type ] : false;
264
- }
265
-
266
- /**
267
- * @since 2.5
268
- */
269
- public function create_column( $options ) {
270
- $column_types = $this->get_column_types();
271
-
272
- if ( ! isset( $options['type'] ) || ! isset( $column_types[ $options['type'] ] ) ) {
273
- return false;
274
- }
275
-
276
- $column = clone $column_types[ $options['type'] ];
277
-
278
- if ( isset( $options['clone'] ) ) {
279
- $column->set_clone( $options['clone'] );
280
- }
281
-
282
- // merge default options with stored
283
- $column->options = (object) array_merge( (array) $column->options, $options );
284
-
285
- $column->sanitize_label();
286
-
287
- return $column;
288
- }
289
-
290
- /**
291
- * Clears columns variable, which allow it to be repopulated by get_columns().
292
- *
293
- * @since 2.5
294
- */
295
- public function flush_columns() {
296
- $this->stored_columns = array();
297
- $this->columns = array();
298
- }
299
-
300
- /**
301
- * @since 2.5
302
- */
303
- public function get_columns() {
304
-
305
- if ( empty( $this->columns ) ) {
306
-
307
- // Stored columns
308
- if ( $stored = $this->get_stored_columns() ) {
309
- foreach ( $stored as $name => $options ) {
310
- if ( $column = $this->create_column( $options ) ) {
311
- $this->columns[ $name ] = $column;
312
- }
313
- }
314
- }
315
-
316
- // Nothing stored
317
- else {
318
- $this->columns = $this->get_default_colummn_types();
319
- }
320
-
321
- do_action( "cac/columns", $this->columns, $this );
322
- do_action( "cac/columns/storage_key={$this->key}", $this->columns, $this );
323
- }
324
-
325
- return $this->columns;
326
- }
327
-
328
- /**
329
- * initialize callback for managing the headers and values for columns
330
- * @since 2.4.10
331
- *
332
- */
333
- public function init_manage_columns() {
334
- }
335
-
336
- /**
337
- * @since 2.0.3
338
- * @return boolean
339
- */
340
- public function is_current_screen() {
341
- global $pagenow;
342
-
343
- return $this->page . '.php' === $pagenow && $this->subpage == filter_input( INPUT_GET, 'page' );
344
- }
345
-
346
- /**
347
- * Set menutype
348
- *
349
- * @since 2.4.1
350
- */
351
- public function set_menu_type( $menu_type ) {
352
- $this->menu_type = $menu_type;
353
-
354
- return $this;
355
- }
356
-
357
- /**
358
- * @since 2.5
359
- */
360
- public function get_menu_type() {
361
- return empty( $this->menu_type ) || 'other' === $this->menu_type ? __( 'Other', 'codepress-admin-columns' ) : $this->menu_type;
362
- }
363
-
364
- public function get_truncated_side_label( $main_label = '' ) {
365
- $sidelabel = $this->label;
366
- if ( 34 < ( strlen( $this->label ) + ( strlen( $main_label ) * 1.1 ) ) ) {
367
- $sidelabel = substr( $this->label, 0, 34 - ( strlen( $main_label ) * 1.1 ) ) . '...';
368
- }
369
-
370
- return $sidelabel;
371
- }
372
-
373
- /**
374
- * Checks if menu type is currently viewed
375
- *
376
- * @since 1.0
377
- *
378
- * @param string $key
379
- *
380
- * @return bool
381
- */
382
- public function is_menu_type_current( $first_posttype ) {
383
-
384
- // display the page that was being viewed before saving
385
- if ( ! empty( $_REQUEST['cpac_key'] ) ) {
386
- if ( $_REQUEST['cpac_key'] == $this->key ) {
387
- return true;
388
- }
389
- } // settings page has not yet been saved
390
- elseif ( $first_posttype == $this->key ) {
391
- return true;
392
- }
393
-
394
- return false;
395
- }
396
-
397
- /**
398
- * @since 2.4.7
399
- */
400
- public function format_meta_keys( $keys ) {
401
- $add_hidden_meta = true; // always true @todo
402
-
403
- $formatted_keys = array();
404
- foreach ( $keys as $key ) {
405
-
406
- // give hidden keys a prefix for identifaction
407
- if ( $add_hidden_meta && "_" == substr( $key[0], 0, 1 ) ) {
408
- $formatted_keys[] = 'cpachidden' . $key[0];
409
- } // non hidden keys are saved as is
410
- elseif ( "_" != substr( $key[0], 0, 1 ) ) {
411
- $formatted_keys[] = $key[0];
412
- }
413
- }
414
-
415
- return $formatted_keys;
416
- }
417
-
418
- /**
419
- * @since 2.0
420
- * @return array
421
- */
422
- public function get_meta_keys() {
423
- if ( $cache = wp_cache_get( $this->key, 'cac_columns' ) ) {
424
- $keys = $cache;
425
- }
426
- else {
427
- $keys = $this->get_meta();
428
- wp_cache_add( $this->key, $keys, 'cac_columns', 10 ); // 10 sec.
429
- }
430
-
431
- if ( is_wp_error( $keys ) || empty( $keys ) ) {
432
- $keys = false;
433
- }
434
- else {
435
- $keys = $this->format_meta_keys( $keys );
436
- }
437
-
438
- /**
439
- * Filter the available custom field meta keys
440
- * If showing hidden fields is enabled, they are prefixed with "cpachidden" in the list
441
- *
442
- * @since 2.0
443
- *
444
- * @param array $keys Available custom field keys
445
- * @param CPAC_Storage_Model $storage_model Storage model class instance
446
- */
447
- $keys = apply_filters( 'cac/storage_model/meta_keys', $keys, $this );
448
-
449
- /**
450
- * Filter the available custom field meta keys for this storage model type
451
- *
452
- * @since 2.0
453
- * @see Filter cac/storage_model/meta_keys
454
- */
455
- return apply_filters( "cac/storage_model/meta_keys/storage_key={$this->key}", $keys, $this );
456
- }
457
-
458
- /**
459
- * @since 2.0
460
- *
461
- * @param array $fields Custom fields.
462
- *
463
- * @return array Custom fields.
464
- */
465
- protected function add_hidden_meta( $fields ) {
466
- if ( ! $fields ) {
467
- return false;
468
- }
469
-
470
- $combined_fields = array();
471
-
472
- // filter out hidden meta fields
473
- foreach ( $fields as $field ) {
474
-
475
- // give hidden fields a prefix for identifaction
476
- if ( "_" == substr( $field[0], 0, 1 ) ) {
477
- $combined_fields[] = 'cpachidden' . $field[0];
478
- } // non hidden fields are saved as is
479
- elseif ( "_" != substr( $field[0], 0, 1 ) ) {
480
- $combined_fields[] = $field[0];
481
- }
482
- }
483
-
484
- if ( empty( $combined_fields ) ) {
485
- return false;
486
- }
487
-
488
- return $combined_fields;
489
- }
490
-
491
- /**
492
- * Layouts
493
- *
494
- * @since 2.5
495
- */
496
- public function get_layout() {
497
- return $this->layout;
498
- }
499
-
500
- public function get_layout_object() {
501
- return $this->get_layout_by_id( $this->layout );
502
- }
503
-
504
- public function get_layout_name() {
505
- $object = $this->get_layout_by_id( $this->layout );
506
-
507
- return isset( $object->name ) ? $object->name : false;
508
- }
509
-
510
- public function set_layout( $layout_id ) {
511
- $this->layout = is_scalar( $layout_id ) ? $layout_id : null;
512
- $this->flush_columns(); // forces $columns and $stored_columns to be repopulated
513
- }
514
-
515
- public function init_settings_layout() {
516
-
517
- // try admin preference..
518
- $layout_id = $this->get_user_layout_preference();
519
-
520
- // ..when not found use the first one
521
- if ( false === $layout_id ) {
522
- $layout_id = $this->get_single_layout_id();
523
- }
524
-
525
- $this->set_layout( $layout_id );
526
- }
527
-
528
- public function init_listings_layout() {
529
- $layout_id = null;
530
-
531
- // User layouts
532
- if ( $layouts_current_user = $this->get_layouts_for_current_user() ) {
533
- $layout_preference = $this->get_user_layout_preference();
534
-
535
- $layout_found = false;
536
-
537
- // try user preference..
538
- foreach ( $layouts_current_user as $_layout ) {
539
- if ( $_layout->id == $layout_preference ) {
540
- $layout_id = $_layout->id;
541
- $layout_found = true;
542
- break;
543
- }
544
- }
545
-
546
- // when no longer available use the first user layout
547
- if ( ! $layout_found ) {
548
- $_layouts_current_user = array_values( $layouts_current_user );
549
- $layout_id = $_layouts_current_user[0]->id;
550
- }
551
- }
552
-
553
- // User doesn't have eligible layouts.. but the current (null) layout does exists, then the WP default columns are loaded
554
- else if ( $this->get_layout_by_id( $layout_id ) ) {
555
- $layout_id = '_wp_default_'; // _wp_default_ does not exists therefor will load WP default
556
- }
557
-
558
- $this->set_layout( $layout_id );
559
- }
560
-
561
- public function set_single_layout_id() {
562
- $this->set_layout( $this->get_single_layout_id() );
563
- }
564
-
565
- public function layout_exists( $id ) {
566
- return $this->get_layout_by_id( $id ) ? true : false;
567
- }
568
-
569
- public function get_single_layout_id() {
570
- $layouts = array_values( (array) $this->get_layouts() );
571
-
572
- return isset( $layouts[0]->id ) ? $layouts[0]->id : null;
573
- }
574
-
575
- public function get_layouts() {
576
- global $wpdb;
577
- $layouts = array();
578
- if ( $results = $wpdb->get_col( $wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name LIKE %s ORDER BY option_id DESC", $this->get_layout_key() . '%' ) ) ) {
579
- foreach ( $results as $result ) {
580
- $layout = (object) maybe_unserialize( $result );
581
- $layouts[ $layout->id ] = $layout;
582
- }
583
- }
584
-
585
- if ( empty( $layouts ) ) {
586
- $layouts = array();
587
- }
588
-
589
- return apply_filters( 'ac/layouts', $layouts, $this );
590
- }
591
-
592
- public function get_layout_by_id( $id ) {
593
- $layouts = $this->get_layouts();
594
-
595
- return isset( $layouts[ $id ] ) ? $layouts[ $id ] : false;
596
- }
597
-
598
- public function get_delete_layout_link( $layout_id ) {
599
- return add_query_arg( array( 'layout_id' => $layout_id, 'cpac_action' => 'delete_layout', '_cpac_nonce' => wp_create_nonce( 'delete-layout' ) ), $this->settings_url() );
600
- }
601
-
602
- private function get_layout_key( $layout_id = '' ) {
603
- return self::LAYOUT_KEY . $this->key . $layout_id;
604
- }
605
-
606
- public function set_user_layout_preference() {
607
- update_user_meta( get_current_user_id(), $this->get_layout_key(), $this->layout );
608
- }
609
-
610
- public function get_user_layout_preference() {
611
- $id = get_user_meta( get_current_user_id(), $this->get_layout_key(), true );
612
-
613
- return $this->layout_exists( $id ) ? $id : false;
614
- }
615
-
616
- public function get_layouts_for_current_user() {
617
- $user_layouts = array();
618
-
619
- $current_user = get_current_user_id();
620
- $layouts = $this->get_layouts();
621
- foreach ( $layouts as $k => $layout ) {
622
-
623
- // Roles
624
- if ( ! empty( $layout->roles ) ) {
625
- foreach ( $layout->roles as $role ) {
626
- if ( current_user_can( $role ) ) {
627
- $user_layouts[ $k ] = $layout;
628
- }
629
- }
630
- }
631
-
632
- // Users
633
- if ( ! empty( $layout->users ) ) {
634
- foreach ( $layout->users as $user ) {
635
- if ( $current_user == $user ) {
636
- $user_layouts[ $k ] = $layout;
637
- }
638
- }
639
- }
640
-
641
- // Both
642
- if ( empty( $layout->roles ) && empty( $layout->users ) ) {
643
- $user_layouts[ $k ] = $layout;
644
- }
645
- }
646
-
647
- return $user_layouts;
648
- }
649
-
650
- public function get_default_layout_args( $args = array() ) {
651
- $default = array(
652
- 'id' => null,
653
- 'name' => __( 'Default' ),
654
- 'roles' => '',
655
- 'users' => '',
656
- );
657
-
658
- return array_merge( $default, $args );
659
- }
660
-
661
- public function save_layout( $id, $args ) {
662
-
663
- if ( empty( $args['name'] ) ) {
664
- return new WP_Error( 'empty-name' );
665
- }
666
-
667
- update_option( $this->get_layout_key( $id ), (object) array(
668
- 'id' => $id ? $id : null,
669
- 'name' => trim( $args['name'] ),
670
- 'roles' => isset( $args['roles'] ) ? $args['roles'] : '',
671
- 'users' => isset( $args['users'] ) ? $args['users'] : '',
672
- ) );
673
-
674
- return $this->get_layout_by_id( $id );
675
- }
676
-
677
- public function create_layout( $args, $is_default = false ) {
678
-
679
- // The default layout has an empty ID, that way it stays compatible when layouts is disabled.
680
- $id = $is_default ? null : uniqid();
681
- $this->save_layout( $id, $args );
682
-
683
- return $id;
684
- }
685
-
686
- public function delete_layout( $id ) {
687
- return delete_option( $this->get_layout_key( $id ) );
688
- }
689
-
690
- /**
691
- * Get store ID
692
- * @since 2.5
693
- */
694
- private function get_storage_id() {
695
- $layout = $this->layout ? $this->layout : null;
696
-
697
- return $this->get_storage_key() . $layout;
698
- }
699
-
700
- /**
701
- * @since 2.0
702
- */
703
- public function restore() {
704
- return delete_option( $this->get_storage_id() );
705
- }
706
-
707
- /**
708
- * @since 2.5
709
- */
710
- public function get_label_or_layout_name() {
711
- $label = $this->label;
712
-
713
- if ( $name = $this->get_layout_name() ) {
714
- $label = $name;
715
- }
716
-
717
- return $label;
718
- }
719
-
720
- /**
721
- * @since 2.0
722
- *
723
- * @param array $columns
724
- * @param array $default_columns Default columns heading names.
725
- */
726
- public function store( $columns ) {
727
-
728
- if ( ! $columns ) {
729
- return new WP_Error( 'no-settings', __( 'No columns settings available.', 'codepress-admin-columns' ) );
730
- }
731
-
732
- // sanitize user inputs
733
- foreach ( $columns as $name => $options ) {
734
- if ( $_column = $this->get_column_by_name( $name ) ) {
735
- $columns[ $name ] = $_column->sanitize_storage( $options );
736
- }
737
-
738
- // Santize Label: Need to replace the url for images etc, so we do not have url problem on exports
739
- // this can not be done by CPAC_Column::sanitize_storage() because 3rd party plugins are not available there
740
- $columns[ $name ]['label'] = stripslashes( str_replace( site_url(), '[cpac_site_url]', trim( $columns[ $name ]['label'] ) ) );
741
- }
742
-
743
- // store columns
744
- $result = update_option( $this->get_storage_id(), $columns );
745
-
746
- // reset object
747
- $this->flush_columns();
748
-
749
- if ( ! $result ) {
750
- return new WP_Error( 'same-settings', sprintf( __( 'You are trying to store the same settings for %s.', 'codepress-admin-columns' ), "<strong>" . $this->get_label_or_layout_name() . "</strong>" ) );
751
- }
752
-
753
- /**
754
- * Fires after a new column setup is stored in the database
755
- * Primarily used when columns are saved through the Admin Columns settings screen
756
- *
757
- * @since 2.2.9
758
- *
759
- * @param array $columns List of columns ([columnid] => (array) [column properties])
760
- * @param CPAC_Storage_Model $storage_model_instance Storage model instance
761
- */
762
- do_action( 'cac/storage_model/columns_stored', $columns, $this );
763
-
764
- return true;
765
- }
766
-
767
- /**
768
- * @since 2.5
769
- */
770
- public function get_default_column_headings() {
771
- $default_columns = apply_filters( "cac/default_columns", $this->get_default_columns(), $this );
772
- $default_columns = apply_filters( "cac/default_columns/type=" . $this->type, $default_columns, $this );
773
- $default_columns = apply_filters( "cac/default_columns/storage_key=" . $this->key, $default_columns, $this );
774
-
775
- return $default_columns;
776
- }
777
-
778
- /**
779
- * Goes through all files in 'classes/column' and includes each file.
780
- *
781
- * @since 2.0.1
782
- * @return array Column Classnames | Filepaths
783
- */
784
- public function set_columns_filepath() {
785
-
786
- require_once CPAC_DIR . 'classes/column.php';
787
- require_once CPAC_DIR . 'classes/column/default.php';
788
- require_once CPAC_DIR . 'classes/column/actions.php';
789
-
790
- $columns = array(
791
- 'CPAC_Column_Custom_Field' => CPAC_DIR . 'classes/column/custom-field.php',
792
- 'CPAC_Column_Taxonomy' => CPAC_DIR . 'classes/column/taxonomy.php',
793
- 'CPAC_Column_Used_By_Menu' => CPAC_DIR . 'classes/column/used-by-menu.php'
794
- );
795
-
796
- // Add-on placeholders
797
- if ( ! cpac_is_pro_active() ) {
798
-
799
- // Display ACF placeholder
800
- if ( cpac_is_acf_active() ) {
801
- $columns['CPAC_Column_ACF_Placeholder'] = CPAC_DIR . 'classes/column/acf-placeholder.php';
802
- }
803
-
804
- // Display WooCommerce placeholder
805
- if ( cpac_is_woocommerce_active() ) {
806
- $columns['CPAC_Column_WC_Placeholder'] = CPAC_DIR . 'classes/column/wc-placeholder.php';
807
- }
808
- }
809
-
810
- // Directory to iterate
811
- $columns_dir = CPAC_DIR . 'classes/column/' . $this->type;
812
- if ( is_dir( $columns_dir ) ) {
813
- $iterator = new DirectoryIterator( $columns_dir );
814
- foreach ( $iterator as $leaf ) {
815
-
816
- if ( $leaf->isDot() || $leaf->isDir() ) {
817
- continue;
818
- }
819
-
820
- // only allow php files, exclude .SVN .DS_STORE and such
821
- if ( substr( $leaf->getFilename(), -4 ) !== '.php' ) {
822
- continue;
823
- }
824
-
825
- // build classname from filename
826
- $class_name = 'CPAC_Column_' . ucfirst( $this->type ) . '_' . implode( '_', array_map( 'ucfirst', explode( '-', basename( $leaf->getFilename(), '.php' ) ) ) );
827
-
828
- // classname | filepath
829
- $columns[ $class_name ] = $leaf->getPathname();
830
- }
831
- }
832
-
833
- /**
834
- * Filter the available custom column types
835
- * Use this to register a custom column type
836
- *
837
- * @since 2.0
838
- *
839
- * @param array $columns Available custom columns ([class_name] => [class file path])
840
- * @param CPAC_Storage_Model $storage_model Storage model class instance
841
- */
842
- $columns = apply_filters( 'cac/columns/custom', $columns, $this );
843
-
844
- /**
845
- * Filter the available custom column types for a specific type
846
- *
847
- * @since 2.0
848
- * @see Filter cac/columns/custom
849
- */
850
- $columns = apply_filters( 'cac/columns/custom/type=' . $this->type, $columns, $this );
851
-
852
- /**
853
- * Filter the available custom column types for a specific type
854
- *
855
- * @since 2.0
856
- * @see Filter cac/columns/custom
857
- */
858
- $columns = apply_filters( 'cac/columns/custom/post_type=' . $this->key, $columns, $this );
859
-
860
- $this->columns_filepath = $columns;
861
- }
862
-
863
- /**
864
- * @since 2.0
865
- *
866
- * @param $column_name
867
- * @param $label
868
- *
869
- * @return object CPAC_Column
870
- */
871
- public function create_column_instance( $column_name, $label ) {
872
-
873
- $column = new CPAC_Column( $this->key );
874
-
875
- $column
876
- ->set_properties( 'type', $column_name )
877
- ->set_properties( 'name', $column_name )
878
- ->set_properties( 'label', $label )
879
- ->set_properties( 'is_cloneable', false )
880
- ->set_properties( 'default', true )
881
- ->set_properties( 'group', __( 'Default', 'codepress-admin-columns' ) )
882
- ->set_options( 'label', $label )
883
- ->set_options( 'state', 'on' );
884
-
885
- // Hide Label when it contains HTML elements
886
- if ( strlen( $label ) != strlen( strip_tags( $label ) ) ) {
887
- $column->set_properties( 'hide_label', true );
888
- }
889
-
890
- // Label empty? Use it's column_name
891
- if ( ! $label ) {
892
- $column->set_properties( 'label', ucfirst( $column_name ) );
893
- }
894
-
895
- return $column;
896
- }
897
-
898
- /**
899
- * @since 1.0
900
- *
901
- * @param string $key
902
- *
903
- * @return array Column options
904
- */
905
- public function get_default_stored_columns() {
906
- return get_option( $this->get_storage_key() . "__default", array() );
907
- }
908
-
909
- public function delete_default_stored_columns() {
910
- delete_option( $this->get_storage_key() . "__default" );
911
- }
912
-
913
- private function store_default_columns( $columns ) {
914
- return update_option( $this->get_storage_key() . "__default", $columns );
915
- }
916
-
917
- private function get_storage_key() {
918
- return self::OPTIONS_KEY . '_' . $this->key;
919
- }
920
-
921
- /**
922
- * @since 1.0
923
- * @return array Column options
924
- */
925
- public function get_stored_columns() {
926
- if ( empty( $this->stored_columns ) ) {
927
-
928
- $columns = apply_filters( 'cpac/storage_model/stored_columns', $this->get_database_columns(), $this );
929
- $columns = apply_filters( 'cpac/storage_model/stored_columns/storage_key=' . $this->key, $columns, $this );
930
-
931
- $this->stored_columns = ! empty( $columns ) ? $columns : array();
932
- }
933
-
934
- return $this->stored_columns;
935
- }
936
-
937
- public function get_database_columns() {
938
- return get_option( $this->get_storage_id() );
939
- }
940
-
941
- /**
942
- * Are column set by third party plugin
943
- *
944
- * @since 2.3.4
945
- */
946
- public function is_using_php_export() {
947
- return $this->php_export;
948
- }
949
-
950
- /**
951
- * @since 2.4.10
952
- */
953
- public function enable_php_export() {
954
- $this->php_export = true;
955
- }
956
-
957
- /**
958
- * @since 2.1.1
959
- */
960
- public function get_post_type() {
961
- return isset( $this->post_type ) ? $this->post_type : false;
962
- }
963
-
964
- /**
965
- * @since 2.3.4
966
- */
967
- public function get_type() {
968
- return $this->type;
969
- }
970
-
971
- /**
972
- * @since 2.3.4
973
- */
974
- public function get_meta_type() {
975
- return $this->meta_type;
976
- }
977
-
978
- /**
979
- * @since 2.0
980
- */
981
- public function get_column_by_name( $name ) {
982
- $columns = $this->get_columns();
983
-
984
- return isset( $columns[ $name ] ) ? $columns[ $name ] : false;
985
- }
986
-
987
- /**
988
- * @since 2.0
989
- */
990
- public function add_headings( $columns ) {
991
-
992
- if ( empty( $columns ) ) {
993
- return $columns;
994
- }
995
-
996
- // for the rare case where a screen hasn't been set yet and a
997
- // plugin uses a custom version of apply_filters( "manage_{$screen->id}_columns", array() )
998
- if ( ! get_current_screen() && ! cac_wp_is_doing_ajax() ) {
999
- return $columns;
1000
- }
1001
-
1002
- // Stores the default columns on the listings screen
1003
- $this->store_default_columns( $columns );
1004
-
1005
- // make sure we run this only once
1006
- if ( $this->column_headings ) {
1007
- return $this->column_headings;
1008
- }
1009
-
1010
- $stored_columns = $this->get_stored_columns();
1011
-
1012
- if ( ! $stored_columns ) {
1013
- return $columns;
1014
- }
1015
-
1016
- $this->column_headings = array();
1017
-
1018
- // add mandatory checkbox
1019
- if ( isset( $columns['cb'] ) ) {
1020
- $this->column_headings['cb'] = $columns['cb'];
1021
- }
1022
-
1023
- $types = array_keys( $this->get_column_types() );
1024
-
1025
- // add active stored headings
1026
- foreach ( $stored_columns as $column_name => $options ) {
1027
-
1028
- // Label needs stripslashes() for HTML tagged labels, like icons and checkboxes
1029
- $label = stripslashes( $options['label'] );
1030
-
1031
- // Remove 3rd party columns that are no longer available (deactivated or removed from code)
1032
- if ( ! in_array( $options['type'], $types ) ) {
1033
- continue;
1034
- }
1035
-
1036
- /**
1037
- * Filter the stored column headers label for use in a WP_List_Table
1038
- * Label needs stripslashes() for HTML tagged labels, like icons and checkboxes
1039
- *
1040
- * @since 2.0
1041
- *
1042
- * @param string $label Label
1043
- * @param string $column_name Column name
1044
- * @param array $options Column options
1045
- * @param CPAC_Storage_Model $storage_model Storage model class instance
1046
- */
1047
- $label = apply_filters( 'cac/headings/label', $label, $column_name, $options, $this );
1048
- $label = str_replace( '[cpac_site_url]', site_url(), $label );
1049
-
1050
- $this->column_headings[ $column_name ] = $label;
1051
- }
1052
-
1053
- // Add 3rd party columns that have ( or could ) not been stored.
1054
- // For example when a plugin has been activated after storing column settings.
1055
- // When $diff contains items, it means an available column has not been stored.
1056
- if ( ! $this->is_using_php_export() && ( $diff = array_diff( array_keys( $columns ), array_keys( (array) $this->get_default_stored_columns() ) ) ) ) {
1057
- foreach ( $diff as $column_name ) {
1058
- $this->column_headings[ $column_name ] = $columns[ $column_name ];
1059
- }
1060
- }
1061
-
1062
- return $this->column_headings;
1063
- }
1064
-
1065
- /**
1066
- * @since 2.0
1067
- * @return string Link
1068
- */
1069
- protected function get_screen_link() {
1070
- return is_network_admin() ? network_admin_url( $this->page . '.php' ) : admin_url( $this->page . '.php' );
1071
- }
1072
-
1073
- /**
1074
- * New public function to get screen link instead of making get_screen_link public. To prevent errors in other plugins
1075
- * @since 2.5
1076
- */
1077
- public function get_link() {
1078
- return $this->get_screen_link();
1079
- }
1080
-
1081
- /**
1082
- * @since 2.0
1083
- */
1084
- public function screen_link() {
1085
- if ( $link = $this->get_screen_link() ) {
1086
- echo '<a href="' . $link . '" class="page-title-action view-link">' . __( 'View', 'codepress-admin-columns' ) . '</a>';
1087
- }
1088
- }
1089
-
1090
- public function settings_url() {
1091
- $args = array(
1092
- 'page' => 'codepress-admin-columns',
1093
- 'cpac_key' => $this->key,
1094
- );
1095
-
1096
- return add_query_arg( $args, admin_url( 'options-general.php' ) );
1097
- }
1098
-
1099
- /**
1100
- * @since 2.0
1101
- */
1102
- public function get_edit_link() {
1103
- return add_query_arg( array( 'layout_id' => $this->layout ? $this->layout : '' ), $this->settings_url() );
1104
- }
1105
-
1106
- /**
1107
- * @since 2.5
1108
- */
1109
- public function get_edit_link_by_layout( $layout_id ) {
1110
- return add_query_arg( array( 'layout_id' => $layout_id ? $layout_id : '' ), $this->settings_url() );
1111
- }
1112
-
1113
- /**
1114
- * @since 2.0
1115
- */
1116
- public function get_restore_link() {
1117
- $args = array(
1118
- '_cpac_nonce' => wp_create_nonce( 'restore-type' ),
1119
- 'cpac_action' => 'restore_by_type'
1120
- );
1121
-
1122
- return add_query_arg( $args, $this->settings_url() );
1123
- }
1124
-
1125
- /**
1126
- * @deprecated deprecated since version 2.4.9
1127
- */
1128
- public function is_columns_screen() {
1129
- _deprecated_function( 'is_columns_screen', '2.4.9', 'is_current_screen' );
1130
-
1131
- return $this->is_current_screen();
1132
- }
1133
-
1134
- /**
1135
- * @since 2.3.2
1136
- */
1137
- public function delete_general_option() {
1138
- delete_option( 'cpac_general_options' );
1139
- }
1140
-
1141
- /**
1142
- * @since 2.1.1
1143
- */
1144
- public function get_general_option( $option ) {
1145
- $options = get_option( 'cpac_general_options' );
1146
-
1147
- if ( ! isset( $options[ $option ] ) ) {
1148
- return false;
1149
- }
1150
-
1151
- return $options[ $option ];
1152
- }
1153
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model/comment.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * @since 2.0
5
- */
6
- class CPAC_Storage_Model_Comment extends CPAC_Storage_Model {
7
-
8
- public function __construct() {
9
-
10
- $this->key = 'wp-comments';
11
- $this->label = __( 'Comments' );
12
- $this->singular_label = __( 'Comment' );
13
- $this->type = 'comment';
14
- $this->meta_type = 'comment';
15
- $this->page = 'edit-comments';
16
-
17
- parent::__construct();
18
- }
19
-
20
- /**
21
- * @since 2.4.9
22
- */
23
- public function init_manage_columns() {
24
-
25
- add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 100 );
26
- add_action( 'manage_comments_custom_column', array( $this, 'manage_value' ), 100, 2 );
27
- }
28
-
29
- public function get_default_column_names() {
30
- return array( 'cb', 'author', 'comment', 'response', 'date' );
31
- }
32
-
33
- protected function get_default_column_widths() {
34
- return array(
35
- 'author' => array( 'width' => 20 ),
36
- 'response' => array( 'width' => 15 ),
37
- 'date' => array( 'width' => 14 ),
38
- );
39
- }
40
-
41
- public function get_default_columns() {
42
- if ( ! function_exists( '_get_list_table' ) ) {
43
- return array();
44
- }
45
-
46
- // You can use this filter to add thirdparty columns by hooking into this.
47
- // See classes/third_party.php for an example.
48
- do_action( "cac/columns/default/storage_key={$this->key}" );
49
-
50
- // get columns
51
- $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'comments' ) );
52
-
53
- // Since 4.4 the `floated_admin_avatar` filter is added in the constructor of the `WP_Comments_List_Table` class.
54
- // Here we remove the filter from the constructor.
55
- remove_filter( 'comment_author', array( $table, 'floated_admin_avatar' ), 10, 2 );
56
-
57
- $columns = (array) $table->get_columns();
58
-
59
- return $columns;
60
- }
61
-
62
- public function get_meta() {
63
- global $wpdb;
64
-
65
- return $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->commentmeta} ORDER BY 1", ARRAY_N );
66
- }
67
-
68
- public function manage_value( $column_name, $comment_id ) {
69
- if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
70
- return false;
71
- }
72
- $value = $column->get_display_value( $comment_id );
73
-
74
- // hook
75
- $value = apply_filters( "cac/column/value", $value, $comment_id, $column, $this->key );
76
- $value = apply_filters( "cac/column/value/{$this->type}", $value, $comment_id, $column, $this->key );
77
-
78
- echo $value;
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model/link.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Storage_Model_Link extends CPAC_Storage_Model {
4
-
5
- function __construct() {
6
-
7
- $this->key = 'wp-links';
8
- $this->label = __( 'Links' );
9
- $this->singular_label = __( 'Link' );
10
- $this->type = 'link';
11
- $this->page = 'link-manager';
12
-
13
- parent::__construct();
14
- }
15
-
16
- /**
17
- * @since 2.4.9
18
- */
19
- public function init_manage_columns() {
20
-
21
- add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 100 );
22
- add_action( 'manage_link_custom_column', array( $this, 'manage_value' ), 100, 2 );
23
- }
24
-
25
- public function get_default_columns() {
26
-
27
- if ( ! function_exists( '_get_list_table' ) ) {
28
- return array();
29
- }
30
-
31
- // You can use this filter to add thirdparty columns by hooking into this.
32
- // See classes/third_party.php for an example.
33
- do_action( "cac/columns/default/storage_key={$this->key}" );
34
-
35
- // get columns
36
- $table = _get_list_table( 'WP_Links_List_Table', array( 'screen' => 'link-manager' ) );
37
- $columns = (array) $table->get_columns();
38
-
39
- return $columns;
40
- }
41
-
42
- public function get_default_column_names() {
43
- return array();
44
- }
45
-
46
- public function get_meta() {
47
- }
48
-
49
- public function manage_value( $column_name, $link_id ) {
50
-
51
- if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
52
- return false;
53
- }
54
-
55
- $value = $column->get_display_value( $link_id );
56
-
57
- // add hook
58
- $value = apply_filters( "cac/column/value", $value, $link_id, $column, $this->key );
59
- $value = apply_filters( "cac/column/value/{$this->type}", $value, $link_id, $column, $this->key );
60
-
61
- echo $value;
62
- }
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model/media.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Storage_Model_Media extends CPAC_Storage_Model {
4
-
5
- public function __construct() {
6
-
7
- $this->key = 'wp-media';
8
- $this->label = __( 'Media Library' );
9
- $this->singular_label = __( 'Media' );
10
- $this->type = 'media';
11
- $this->meta_type = 'post';
12
- $this->page = 'upload';
13
- $this->post_type = 'attachment';
14
-
15
- parent::__construct();
16
- }
17
-
18
- /**
19
- * @since 2.4.9
20
- */
21
- public function init_manage_columns() {
22
-
23
- add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 100 );
24
- add_action( 'manage_media_custom_column', array( $this, 'manage_value' ), 100, 2 );
25
- }
26
-
27
- public function get_default_columns() {
28
- if ( ! function_exists( '_get_list_table' ) ) {
29
- return array();
30
- }
31
-
32
- // You can use this filter to add thirdparty columns by hooking into this.
33
- // See classes/third_party.php for an example.
34
- do_action( "cac/columns/default/storage_key={$this->key}" );
35
-
36
- $table = _get_list_table( 'WP_Media_List_Table', array( 'screen' => 'upload' ) );
37
- $columns = (array) $table->get_columns();
38
-
39
- if ( cac_is_setting_screen() ) {
40
- $columns = array_merge( get_column_headers( 'upload' ), $columns );
41
- }
42
-
43
- return $columns;
44
- }
45
-
46
- /**
47
- * @since 2.5
48
- */
49
- public function get_default_column_names() {
50
- return array(
51
- 'cb',
52
- 'date',
53
- 'parent',
54
- 'icon',
55
- 'title',
56
- 'author',
57
- 'comments'
58
- );
59
- }
60
-
61
- /**
62
- * @since 2.5
63
- */
64
- protected function get_default_column_widths() {
65
- return array(
66
- 'author' => array( 'width' => 10 ),
67
- 'parent' => array( 'width' => 15 ),
68
- 'date' => array( 'width' => 10 ),
69
- );
70
- }
71
-
72
- public function get_meta() {
73
- global $wpdb;
74
-
75
- return $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = 'attachment' ORDER BY 1", ARRAY_N );
76
- }
77
-
78
- public function manage_value( $column_name, $media_id ) {
79
- if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
80
- return false;
81
- }
82
- $value = $column->get_display_value( $media_id );
83
-
84
- // hooks
85
- $value = apply_filters( "cac/column/value", $value, $media_id, $column, $this->key );
86
- $value = apply_filters( "cac/column/value/{$this->type}", $value, $media_id, $column, $this->key );
87
-
88
- echo $value;
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model/post.php DELETED
@@ -1,249 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Storage_Model_Post extends CPAC_Storage_Model {
4
-
5
- public $post_type;
6
-
7
- /**
8
- * @since 2.0
9
- */
10
- public function __construct( $post_type ) {
11
-
12
- $this->key = $post_type;
13
- $this->post_type = $post_type;
14
- $this->type = 'post';
15
- $this->meta_type = 'post';
16
- $this->page = 'edit';
17
- $this->screen = $this->page . '-' . $this->post_type;
18
- $this->menu_type = __( 'Post Type', 'codepress-admin-columns' );
19
-
20
- $this->set_labels();
21
-
22
- parent::__construct();
23
- }
24
-
25
- /**
26
- * @since 2.4.9
27
- */
28
- public function init_manage_columns() {
29
-
30
- // Headings
31
- // Filter is located in get_column_headers()
32
- add_filter( "manage_{$this->page}-{$this->post_type}_columns", array( $this, 'add_headings' ), 200 );
33
-
34
- // values
35
- add_action( "manage_{$this->post_type}_posts_custom_column", array( $this, 'manage_value_callback' ), 100, 2 );
36
- }
37
-
38
- /**
39
- * @since 2.3.5
40
- */
41
- public function get_post_type() {
42
- return $this->post_type;
43
- }
44
-
45
- /**
46
- * @since 2.4.7
47
- */
48
- public function get_posts( $args = array() ) {
49
- $defaults = array(
50
- 'posts_per_page' => -1,
51
- 'post_status' => apply_filters( 'cac/get_posts/post_status', array( 'any', 'trash' ), $this ),
52
- 'post_type' => $this->get_post_type(),
53
- 'fields' => 'ids',
54
- 'no_found_rows' => 1,
55
- );
56
-
57
- return (array) get_posts( array_merge( $defaults, $args ) );
58
- }
59
-
60
- /**
61
- * @since 2.7.2
62
- */
63
- private function set_labels() {
64
- $post_type_object = get_post_type_object( $this->post_type );
65
- $this->label = $post_type_object->labels->name;
66
- $this->singular_label = $post_type_object->labels->singular_name;
67
- }
68
-
69
- /**
70
- * @since 2.2.1
71
- */
72
- public function get_original_column_value( $column, $id ) {
73
-
74
- global $post;
75
-
76
- // Setup post data for current post
77
- $post_old = $post;
78
- $post = get_post( $id );
79
- setup_postdata( $post );
80
-
81
- // Remove Admin Columns action for this column's value
82
- remove_action( "manage_{$this->post_type}_posts_custom_column", array( $this, 'manage_value_callback' ), 100 );
83
-
84
- ob_start();
85
- // Run WordPress native actions to display column content
86
- if ( is_post_type_hierarchical( $this->post_type ) ) {
87
- do_action( 'manage_pages_custom_column', $column, $id );
88
- }
89
- else {
90
- do_action( 'manage_posts_custom_column', $column, $id );
91
- }
92
-
93
- do_action( "manage_{$this->post_type}_posts_custom_column", $column, $id );
94
-
95
- $contents = ob_get_clean();
96
-
97
- // Add removed Admin Columns action for this column's value
98
- add_action( "manage_{$this->post_type}_posts_custom_column", array( $this, 'manage_value_callback' ), 100, 2 );
99
-
100
- // Restore original post object
101
- $post = $post_old;
102
-
103
- if ( $post ) {
104
- setup_postdata( $post );
105
- }
106
-
107
- return $contents;
108
- }
109
-
110
- /**
111
- * @since 2.4.4
112
- */
113
- public function get_default_column_names() {
114
-
115
- $defaults = array( 'date' );
116
-
117
- if ( post_type_supports( $this->post_type, 'title' ) ) {
118
- $defaults[] = 'title';
119
- }
120
- if ( post_type_supports( $this->post_type, 'comments' ) ) {
121
- $defaults[] = 'comments';
122
- }
123
-
124
- if ( in_array( $this->post_type, array( 'post', 'page' ) ) ) {
125
- $defaults[] = 'cb';
126
- $defaults[] = 'author';
127
- $defaults[] = 'categories';
128
- $defaults[] = 'parent';
129
- $defaults[] = 'tags';
130
- }
131
-
132
- return $defaults;
133
- }
134
-
135
- /**
136
- * @since 2.5
137
- */
138
- public function get_default_column_widths() {
139
- return array(
140
- 'author' => array( 'width' => 10 ),
141
- 'categories' => array( 'width' => 15 ),
142
- 'tags' => array( 'width' => 15 ),
143
- 'date' => array( 'width' => 10 ),
144
- );
145
- }
146
-
147
- /**
148
- * @since 2.0
149
- */
150
- protected function get_screen_link() {
151
- return add_query_arg( array( 'post_type' => $this->key ), admin_url( $this->page . '.php' ) );
152
- }
153
-
154
- /**
155
- * @since 2.2
156
- */
157
- public function is_current_screen() {
158
- $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post';
159
-
160
- return ( $this->post_type === $post_type ) && parent::is_current_screen();
161
- }
162
-
163
- /**
164
- * Get WP default supported admin columns per post type.
165
- *
166
- * @see CPAC_Type::get_default_columns()
167
- * @since 1.0
168
- *
169
- * @return array
170
- */
171
- public function get_default_columns() {
172
-
173
- if ( ! function_exists( '_get_list_table' ) ) {
174
- return array();
175
- }
176
-
177
- // You can use this filter to add thirdparty columns by hooking into this.
178
- // See classes/third_party.php for an example.
179
- do_action( "cac/columns/default/posts" );
180
- do_action( "cac/columns/default/storage_key={$this->key}" );
181
- do_action( "cac/columns/default/post_type={$this->post_type}" );
182
-
183
- // Initialize table so it can add actions to manage_{screenid}_columns
184
- _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-' . $this->key ) );
185
-
186
- // get_column_headers() runs through both the manage_{screenid}_columns
187
- // and manage_{$post_type}_posts_columns filters
188
- $columns = (array) apply_filters( 'manage_edit-' . $this->key . '_columns', array() );
189
- $columns = array_filter( $columns );
190
-
191
- return $columns;
192
- }
193
-
194
- /**
195
- * @since 2.0
196
- */
197
- public function get_meta() {
198
- global $wpdb;
199
-
200
- return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = %s ORDER BY 1", $this->key ), ARRAY_N );
201
- }
202
-
203
- /**
204
- * @since 2.0
205
- */
206
- public function manage_value( $column_name, $post_id ) {
207
-
208
- if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
209
- return false;
210
- }
211
-
212
- global $post;
213
-
214
- // Setup post data for current post
215
- $post_old = $post;
216
- $post = get_post( $post_id );
217
- setup_postdata( $post );
218
-
219
- $value = $column->get_display_value( $post_id );
220
-
221
- $value = apply_filters( "cac/column/value", $value, $post_id, $column, $this->key );
222
- $value = apply_filters( "cac/column/value/{$this->type}", $value, $post_id, $column, $this->key );
223
-
224
- // Reset query to old post
225
- $post = $post_old;
226
-
227
- if ( $post ) {
228
- setup_postdata( $post );
229
- }
230
-
231
- echo $value;
232
- }
233
-
234
- /**
235
- * @since 2.4.7
236
- */
237
- public function manage_value_callback( $column_name, $post_id ) {
238
-
239
- $column = $this->get_column_by_name( $column_name );
240
- if ( $column && ! empty( $column->properties->handle ) ) {
241
- ob_start();
242
- $this->manage_value( $column_name, $post_id );
243
- ob_end_clean();
244
- }
245
- else {
246
- $this->manage_value( $column_name, $post_id );
247
- }
248
- }
249
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/storage_model/user.php DELETED
@@ -1,120 +0,0 @@
1
- <?php
2
-
3
- class CPAC_Storage_Model_User extends CPAC_Storage_Model {
4
-
5
- /**
6
- * @since 2.0
7
- */
8
- public function __construct() {
9
-
10
- $this->key = 'wp-users';
11
- $this->label = __( 'Users' );
12
- $this->singular_label = __( 'User' );
13
- $this->type = 'user';
14
- $this->meta_type = 'user';
15
- $this->page = 'users';
16
-
17
- parent::__construct();
18
- }
19
-
20
- /**
21
- * @since 2.4.9
22
- */
23
- public function init_manage_columns() {
24
- add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 100 );
25
- add_filter( 'manage_users_custom_column', array( $this, 'manage_value_callback' ), 100, 3 );
26
- }
27
-
28
- /**
29
- * @since 2.4.10
30
- */
31
- public function is_current_screen() {
32
- return ! is_network_admin() && parent::is_current_screen();
33
- }
34
-
35
- /**
36
- * @since 2.4.7
37
- */
38
- public function get_original_column_value( $column, $id ) {
39
-
40
- // Remove Admin Columns action for this column's value
41
- remove_action( "manage_users_custom_column", array( $this, 'manage_value_callback' ), 100, 3 );
42
- ob_start();
43
- do_action( "manage_users_custom_column", $column, $id );
44
- $contents = ob_get_clean();
45
- add_action( "manage_users_custom_column", array( $this, 'manage_value_callback' ), 100, 3 );
46
-
47
- return $contents;
48
- }
49
-
50
- /**
51
- * @see CPAC_Type::get_default_columns()
52
- */
53
- public function get_default_columns() {
54
-
55
- if ( ! function_exists( '_get_list_table' ) ) {
56
- return array();
57
- }
58
-
59
- // You can use this filter to add third_party columns by hooking into this.
60
- do_action( "cac/columns/default/storage_key={$this->key}" );
61
-
62
- // get columns
63
- $table = _get_list_table( 'WP_Users_List_Table', array( 'screen' => 'users' ) );
64
- $columns = (array) $table->get_columns();
65
-
66
- if ( cac_is_setting_screen() ) {
67
- $columns = array_merge( get_column_headers( 'users' ), $columns );
68
- }
69
-
70
- return $columns;
71
- }
72
-
73
- /**
74
- * @since 2.4.4
75
- */
76
- public function get_default_column_names() {
77
- return array( 'cb', 'username', 'name', 'email', 'role', 'posts' );
78
- }
79
-
80
- /**
81
- * @since 2.5
82
- */
83
- protected function get_default_column_widths() {
84
- return array(
85
- 'role' => array( 'width' => 15 ),
86
- 'posts' => array( 'width' => 74, 'unit' => 'px' ),
87
- );
88
- }
89
-
90
- /**
91
- * @since 2.0.2
92
- */
93
- public function manage_value( $column_name, $user_id, $value = '' ) {
94
- if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
95
- return $value;
96
- }
97
- $custom_value = $column->get_display_value( $user_id );
98
-
99
- // make sure it absolutely empty and check for (string) 0
100
- if ( ! empty( $custom_value ) || '0' === $custom_value ) {
101
- $value = $custom_value;
102
- }
103
-
104
- // filters
105
- $value = apply_filters( "cac/column/value", $value, $user_id, $column, $this->key );
106
- $value = apply_filters( "cac/column/value/{$this->type}", $value, $user_id, $column, $this->key );
107
-
108
- return $value;
109
- }
110
-
111
- public function manage_value_callback( $value, $column_name, $user_id ) {
112
- return $this->manage_value( $column_name, $user_id, $value );
113
- }
114
-
115
- public function get_meta() {
116
- global $wpdb;
117
-
118
- return $wpdb->get_results( "SELECT DISTINCT meta_key FROM {$wpdb->usermeta} ORDER BY 1", ARRAY_N );
119
- }
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/third_party.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- require_once CPAC_DIR . 'classes/third_party/acf.php';
3
- require_once CPAC_DIR . 'classes/third_party/ninja_forms.php';
4
- require_once CPAC_DIR . 'classes/third_party/woocommerce.php';
5
- require_once CPAC_DIR . 'classes/third_party/wpml.php';
 
 
 
 
 
classes/third_party/acf.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Fix which remove the Advanced Custom Fields Type (acf) from the admin columns settings page
5
- *
6
- * @since 2.0
7
- *
8
- * @return array Posttypes
9
- */
10
- function cpac_remove_acf_from_cpac_post_types( $post_types ) {
11
- if ( class_exists( 'Acf', false ) ) {
12
- if ( isset( $post_types['acf'] ) ) {
13
- unset( $post_types['acf'] );
14
- }
15
- if ( isset( $post_types['acf-field-group'] ) ) {
16
- unset( $post_types['acf-field-group'] );
17
- }
18
- }
19
-
20
- return $post_types;
21
- }
22
- add_filter( 'cac/post_types', 'cpac_remove_acf_from_cpac_post_types' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/third_party/ninja_forms.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Fix for Ninja Forms
5
- *
6
- * @since 2.0
7
- *
8
- * @return array Posttypes
9
- */
10
- function cpac_remove_ninja_forms_from_cpac_post_types( $post_types ) {
11
- if ( class_exists( 'Ninja_Forms', false ) ) {
12
- if ( isset( $post_types['nf_sub'] ) ) {
13
- unset( $post_types['nf_sub'] );
14
- }
15
- }
16
-
17
- return $post_types;
18
- }
19
- add_filter( 'cac/post_types', 'cpac_remove_ninja_forms_from_cpac_post_types' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/third_party/woocommerce.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- function cpac_remove_webhook_from_post_types( $post_types ) {
4
- if ( class_exists( 'WooCommerce', false ) ) {
5
- if ( isset( $post_types['shop_webhook'] ) ) {
6
- unset( $post_types['shop_webhook'] );
7
- }
8
- }
9
- return $post_types;
10
- }
11
- add_filter( 'cac/post_types', 'cpac_remove_webhook_from_post_types' );
 
 
 
 
 
 
 
 
 
 
 
classes/third_party/wpml.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * WPML: display correct flags on the overview screens
5
- */
6
- class CPAC_WPML_COLUMN {
7
-
8
- CONST COLUMN_NAME = 'icl_translations';
9
-
10
- private $column;
11
-
12
- function __construct( $post_type ) {
13
- add_filter( "manage_{$post_type}_posts_columns", array( $this, 'store_wpml_column' ), 11 ); // prio just after WPML set's it's column
14
- add_filter( "manage_edit-{$post_type}_columns", array( $this, 'replace_wpml_column' ), 201 ); // prio just after AC overwrite all columns
15
- }
16
-
17
- public function store_wpml_column( $columns ) {
18
- if ( empty( $this->column ) && isset( $columns[ self::COLUMN_NAME ] ) ) {
19
- $this->column = $columns[ self::COLUMN_NAME ];
20
- }
21
-
22
- return $columns;
23
- }
24
-
25
- public function replace_wpml_column( $columns ) {
26
- if ( $this->column && isset( $columns[ self::COLUMN_NAME ] ) ) {
27
- $columns[ self::COLUMN_NAME ] = $this->column;
28
- }
29
-
30
- return $columns;
31
- }
32
- }
33
-
34
- /**
35
- * WPML compatibility
36
- */
37
- class CPAC_WPML {
38
-
39
- function __construct() {
40
-
41
- // display correct flags on the overview screens
42
- add_action( 'cac/loaded', array( $this, 'replace_flags' ) );
43
-
44
- // enable the translation of the column labels
45
- add_action( 'wp_loaded', array( $this, 'register_column_labels' ), 99 );
46
-
47
- // enable the WPML translation of column headings
48
- add_filter( 'cac/headings/label', array( $this, 'register_translated_label' ), 10, 4 );
49
-
50
- // set WPML to be a columns screen for translation so that storage models are loaded
51
- add_filter( 'cac/is_cac_screen', array( $this, 'is_cac_screen' ) );
52
- }
53
-
54
- public function replace_flags( $cac ) {
55
- if ( ! class_exists( 'SitePress', false ) ) {
56
- return;
57
- }
58
- if ( ! $cac->is_columns_screen() ) {
59
- return;
60
- }
61
-
62
- $settings = get_option( 'icl_sitepress_settings' );
63
- if ( ! isset( $settings['custom_posts_sync_option'] ) ) {
64
- return;
65
- }
66
- $post_types = (array) $settings['custom_posts_sync_option'];
67
- $post_types['post'] = 1;
68
- $post_types['page'] = 1;
69
- foreach ( $post_types as $post_type => $value ) {
70
- if ( $value ) {
71
- new CPAC_WPML_COLUMN( $post_type );
72
- }
73
- }
74
- }
75
-
76
- // Create translatable column labels
77
- public function register_column_labels() {
78
-
79
- // don't load this unless required by WPML
80
- if ( ! isset( $_GET['page'] ) || 'wpml-string-translation/menu/string-translation.php' !== $_GET['page'] ) {
81
- return;
82
- }
83
-
84
- foreach ( cpac()->get_storage_models() as $storage_model ) {
85
- foreach ( $storage_model->get_stored_columns() as $column_name => $options ) {
86
- icl_register_string( 'Admin Columns', $storage_model->key . '_' . $column_name, stripslashes( $options['label'] ) );
87
- }
88
- }
89
- }
90
-
91
- public function register_translated_label( $label, $column_name, $column_options, $storage_model ) {
92
- if ( function_exists( 'icl_t' ) ) {
93
- $name = $storage_model->key . '_' . $column_name;
94
- $label = icl_t( 'Admin Columns', $name, $label );
95
- }
96
-
97
- return $label;
98
- }
99
-
100
- public function is_cac_screen( $is_columns_screen ) {
101
- if ( isset( $_GET['page'] ) && 'wpml-string-translation/menu/string-translation.php' == $_GET['page'] ) {
102
- return true;
103
- }
104
-
105
- return $is_columns_screen;
106
- }
107
- }
108
-
109
- new CPAC_WPML;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/utility.php DELETED
@@ -1,145 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Admin message
5
- *
6
- * @since 1.5.0
7
- *
8
- * @param string $message Message.
9
- * @param string $type Update Type.
10
- */
11
- function cpac_admin_message( $message = '', $type = 'updated' ) {
12
- $GLOBALS['cpac_messages'][] = '<div class="cpac_message ' . $type . '"><p>' . $message . '</p></div>';
13
-
14
- add_action( 'admin_notices', 'cpac_admin_notice' );
15
- add_action( 'network_admin_notices', 'cpac_admin_notice' );
16
- }
17
-
18
- /**
19
- * Admin Notice
20
- *
21
- * This uses the standard CSS styling from WordPress, no additional CSS have to be loaded.
22
- *
23
- * @since 1.5.0
24
- *
25
- * @return string Message.
26
- */
27
- function cpac_admin_notice() {
28
- echo implode( $GLOBALS['cpac_messages'] );
29
- }
30
-
31
- function cpac_settings_message( $message = '', $type = 'updated' ) {
32
- $GLOBALS['cpac_settings_messages'][] = '<div class="cpac_message inline ' . $type . '"><p>' . $message . '</p></div>'; // .inline prevents JS from placing it below h2
33
- }
34
-
35
- /**
36
- * Is doing ajax
37
- *
38
- * @since 2.3.4
39
- */
40
- function cac_is_doing_ajax() {
41
- if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
42
- return false;
43
- }
44
-
45
- $is_doing_ajax = cac_wp_is_doing_ajax() || isset( $_REQUEST['storage_model'] );
46
-
47
- return apply_filters( 'cac/is_doing_ajax', $is_doing_ajax );
48
- }
49
-
50
- /**
51
- * Is WordPress doing ajax
52
- *
53
- * @since 2.5
54
- */
55
- function cac_wp_is_doing_ajax() {
56
- $storage_model = false;
57
-
58
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
59
-
60
- switch ( filter_input( INPUT_POST, 'action' ) ) {
61
- case 'inline-save' : // Quick edit
62
- $storage_model = filter_input( INPUT_POST, 'post_type' );
63
- break;
64
- case 'add-tag' : // Adding term
65
- case 'inline-save-tax' : // Quick edit term
66
- $storage_model = 'wp-taxonomy_' . filter_input( INPUT_POST, 'taxonomy' );
67
- break;
68
- case 'edit-comment' : // Quick edit comment
69
- case 'replyto-comment' : // Inline reply on comment
70
- $storage_model = 'wp-comments';
71
- break;
72
- }
73
- }
74
-
75
- return $storage_model;
76
- }
77
-
78
- /**
79
- * Returns true if the installed version of WooCommerce is version X or greater
80
- *
81
- * @since 2.3.4
82
- * @return boolean true if the installed version of WooCommerce is version X or greater
83
- */
84
- function cpac_is_wc_version_gte( $version = '1.0' ) {
85
- $wc_version = defined( 'WC_VERSION' ) && WC_VERSION ? WC_VERSION : null;
86
-
87
- return $wc_version && version_compare( $wc_version, $version, '>=' );
88
- }
89
-
90
- function cpac_is_acf_active() {
91
- return class_exists( 'acf', false );
92
- }
93
-
94
- function cpac_is_woocommerce_active() {
95
- return class_exists( 'WooCommerce', false );
96
- }
97
-
98
- function cpac_is_pro_active() {
99
- return class_exists( 'CAC_Addon_Pro', false );
100
- }
101
-
102
- /**
103
- * Whether the current screen is the Admin Columns settings screen
104
- *
105
- * @since 2.4.8
106
- *
107
- * @param strong $tab Specifies a tab screen (optional)
108
- *
109
- * @return bool True if the current screen is the settings screen, false otherwise
110
- */
111
- function cac_is_setting_screen( $tab = '' ) {
112
- global $pagenow;
113
-
114
- if ( ! ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && ( 'codepress-admin-columns' === $_GET['page'] ) ) ) {
115
- return false;
116
- }
117
-
118
- if ( $tab && ( empty( $_GET['tab'] ) || ( isset( $_GET['tab'] ) && $tab !== $_GET['tab'] ) ) ) {
119
- return false;
120
- }
121
-
122
- return true;
123
- }
124
-
125
- /**
126
- * Get the url where the Admin Columns website is hosted
127
- *
128
- * @return string
129
- */
130
- function ac_get_site_url( $path = '' ) {
131
- $url = 'https://www.admincolumns.com';
132
-
133
- if ( ! empty( $path ) ) {
134
- $url .= '/' . trim( $path, '/' ) . '/';
135
- }
136
-
137
- return $url;
138
- }
139
-
140
- /**
141
- * @see ac_get_site_url()
142
- */
143
- function ac_site_url( $path = '' ) {
144
- echo ac_get_site_url( $path );
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
codepress-admin-columns.php CHANGED
@@ -1,651 +1,608 @@
1
- <?php
2
- /*
3
- Plugin Name: Admin Columns
4
- Version: 2.5.6.4
5
- Description: Customize columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
6
- Author: AdminColumns.com
7
- Author URI: https://www.admincolumns.com
8
- Plugin URI: https://www.admincolumns.com
9
- Text Domain: codepress-admin-columns
10
- Domain Path: /languages
11
- License: GPLv2
12
-
13
- Copyright 2011-2016 AdminColumns.com info@admincolumns.com
14
-
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License version 2 as published by
17
- the Free Software Foundation.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
- */
28
-
29
- // Exit if accessed directly
30
- if ( ! defined( 'ABSPATH' ) ) {
31
- exit;
32
- }
33
-
34
- // Plugin information
35
- define( 'CPAC_VERSION', '2.5.6.4' ); // Current plugin version
36
- define( 'CPAC_UPGRADE_VERSION', '2.0.0' ); // Latest version which requires an upgrade
37
- define( 'CPAC_URL', plugin_dir_url( __FILE__ ) );
38
- define( 'CPAC_DIR', plugin_dir_path( __FILE__ ) );
39
-
40
- // Only run plugin in the admin interface
41
- if ( ! is_admin() ) {
42
- return false;
43
- }
44
-
45
- /**
46
- * Dependencies
47
- *
48
- * @since 1.3.0
49
- */
50
- require_once CPAC_DIR . 'classes/utility.php';
51
- require_once CPAC_DIR . 'classes/third_party.php';
52
- require_once CPAC_DIR . 'includes/arrays.php';
53
-
54
- /**
55
- * The Admin Columns Class
56
- *
57
- * @since 1.0
58
- */
59
- class CPAC {
60
-
61
- /**
62
- * Admin Columns add-ons class instance
63
- *
64
- * @since 2.2
65
- * @access private
66
- * @var CPAC_Addons
67
- */
68
- private $_addons;
69
-
70
- /**
71
- * Admin Columns settings class instance
72
- *
73
- * @since 2.2
74
- * @access private
75
- * @var CPAC_Settings
76
- */
77
- private $_settings;
78
-
79
- /**
80
- * Admin Columns plugin upgrade class instance
81
- *
82
- * @since 2.2.7
83
- * @access private
84
- * @var CPAC_Upgrade
85
- */
86
- private $_upgrade;
87
-
88
- /**
89
- * Registered storage model class instances
90
- * Array of CPAC_Storage_Model instances, with the storage model keys (e.g. post, page, wp-users) as keys
91
- *
92
- * @since 2.0
93
- * @var array
94
- */
95
- private $storage_models;
96
-
97
- /**
98
- * @since 2.4.9
99
- */
100
- private $current_storage_model;
101
-
102
- /**
103
- * @since 2.5
104
- */
105
- protected static $_instance = null;
106
-
107
- /**
108
- * @since 2.5
109
- */
110
- public static function instance() {
111
- if ( is_null( self::$_instance ) ) {
112
- self::$_instance = new self();
113
- }
114
-
115
- return self::$_instance;
116
- }
117
-
118
- /**
119
- * @since 1.0
120
- */
121
- function __construct() {
122
-
123
- register_activation_hook( __FILE__, array( $this, 'set_capabilities' ) );
124
-
125
- // Hooks
126
- add_action( 'init', array( $this, 'localize' ) );
127
- add_action( 'wp_loaded', array( $this, 'after_setup' ) ); // Setup callback, important to load after set_storage_models
128
- add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
129
- add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
130
- add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ), 20, 1 );
131
-
132
- // Populating columns
133
- add_action( 'admin_init', array( $this, 'set_columns' ) );
134
-
135
- // Settings
136
- include_once CPAC_DIR . 'classes/settings.php';
137
- $this->_settings = new CPAC_Settings( $this );
138
-
139
- // Addons
140
- include_once CPAC_DIR . 'classes/addons.php';
141
- $this->_addons = new CPAC_Addons( $this );
142
-
143
- // Upgrade
144
- require_once CPAC_DIR . 'classes/upgrade.php';
145
- $this->_upgrade = new CPAC_Upgrade( $this );
146
-
147
- // Settings
148
- include_once CPAC_DIR . 'classes/review_notice.php';
149
- new CPAC_Review_Notice( $this );
150
- }
151
-
152
- /**
153
- * Fire callbacks for admin columns setup completion
154
- *
155
- * @since 2.2
156
- */
157
- public function after_setup() {
158
-
159
- /**
160
- * Fires when Admin Columns is fully loaded
161
- * Use this for setting up addon functionality
162
- *
163
- * @since 2.0
164
- *
165
- * @param CPAC $cpac_instance Main Admin Columns plugin class instance
166
- */
167
- do_action( 'cac/loaded', $this );
168
-
169
- // Current listings page storage model
170
- if ( $storage_model = $this->get_current_storage_model() ) {
171
- do_action( 'cac/current_storage_model', $storage_model );
172
- }
173
- }
174
-
175
- /**
176
- * @since 2.2
177
- * @uses load_plugin_textdomain()
178
- */
179
- public function localize() {
180
- load_plugin_textdomain( 'codepress-admin-columns', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
181
- }
182
-
183
- /**
184
- * @since 2.2.4
185
- */
186
- public function scripts() {
187
-
188
- $minified = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
189
-
190
- wp_register_script( 'cpac-admin-columns', CPAC_URL . "assets/js/admin-columns{$minified}.js", array( 'jquery', 'jquery-qtip2' ), CPAC_VERSION );
191
- wp_register_script( 'jquery-qtip2', CPAC_URL . "external/qtip2/jquery.qtip{$minified}.js", array( 'jquery' ), CPAC_VERSION );
192
- wp_register_style( 'jquery-qtip2', CPAC_URL . "external/qtip2/jquery.qtip{$minified}.css", array(), CPAC_VERSION, 'all' );
193
- wp_register_style( 'cpac-columns', CPAC_URL . "assets/css/column{$minified}.css", array(), CPAC_VERSION, 'all' );
194
-
195
- if ( $this->get_current_storage_model() ) {
196
- add_filter( 'admin_body_class', array( $this, 'admin_class' ) );
197
- add_action( 'admin_head', array( $this, 'admin_scripts' ) );
198
-
199
- wp_enqueue_script( 'cpac-admin-columns' );
200
- wp_enqueue_style( 'jquery-qtip2' );
201
- wp_enqueue_style( 'cpac-columns' );
202
- }
203
- }
204
-
205
- /**
206
- * Add capabilty to administrator to manage admin columns.
207
- * You can use the capability 'manage_admin_columns' to grant other roles this privilidge as well.
208
- *
209
- * @since 2.0.4
210
- */
211
- public function set_capabilities() {
212
- if ( $role = get_role( 'administrator' ) ) {
213
- $role->add_cap( 'manage_admin_columns' );
214
- }
215
- }
216
-
217
- /**
218
- * Set the primary columns for the Admin Columns columns
219
- *
220
- * @since 2.5.5
221
- */
222
- public function set_primary_column( $default ) {
223
- if ( $storage_model = $this->get_current_storage_model() ) {
224
- if ( ! $storage_model->get_column_by_name( $default ) ) {
225
- $default = key( $storage_model->get_columns() );
226
- }
227
- }
228
-
229
- return $default;
230
- }
231
-
232
- /**
233
- * @since 2.5.6.3
234
- */
235
- public function suppress_site_wide_notices() {
236
- return apply_filters( 'cac/suppress_site_wide_notices', false );
237
- }
238
-
239
- /**
240
- * Get registered storage models
241
- *
242
- * @since 2.5
243
- */
244
- public function get_storage_models() {
245
- if ( empty( $this->storage_models ) ) {
246
-
247
- $storage_models = array();
248
-
249
- // Load storage model class files and column base class files
250
- require_once CPAC_DIR . 'classes/storage_model.php';
251
- require_once CPAC_DIR . 'classes/storage_model/post.php';
252
- require_once CPAC_DIR . 'classes/storage_model/user.php';
253
- require_once CPAC_DIR . 'classes/storage_model/media.php';
254
- require_once CPAC_DIR . 'classes/storage_model/comment.php';
255
-
256
- // Create a storage model per post type
257
- foreach ( $this->get_post_types() as $post_type ) {
258
- $storage_model = new CPAC_Storage_Model_Post( $post_type );
259
- $storage_models[ $storage_model->key ] = $storage_model;
260
- }
261
-
262
- // Create other storage models
263
- $storage_model = new CPAC_Storage_Model_User();
264
- $storage_models[ $storage_model->key ] = $storage_model;
265
-
266
- $storage_model = new CPAC_Storage_Model_Media();
267
- $storage_models[ $storage_model->key ] = $storage_model;
268
-
269
- $storage_model = new CPAC_Storage_Model_Comment();
270
- $storage_models[ $storage_model->key ] = $storage_model;
271
-
272
- if ( apply_filters( 'pre_option_link_manager_enabled', false ) ) { // as of 3.5 link manager is removed
273
- require_once CPAC_DIR . 'classes/storage_model/link.php';
274
-
275
- $storage_model = new CPAC_Storage_Model_Link();
276
- $storage_models[ $storage_model->key ] = $storage_model;
277
- }
278
-
279
- /**
280
- * Filter the available storage models
281
- * Used by external plugins to add additional storage models
282
- *
283
- * @since 2.0
284
- *
285
- * @param array $storage_models List of storage model class instances ( [key] => [CPAC_Storage_Model object], where [key] is the storage key, such as "user", "post" or "my_custom_post_type")
286
- * @param object $this CPAC
287
- */
288
- $this->storage_models = apply_filters( 'cac/storage_models', $storage_models, $this );
289
- }
290
-
291
- return $this->storage_models;
292
- }
293
-
294
- /**
295
- * Retrieve a storage model object based on its key
296
- *
297
- * @since 2.0
298
- *
299
- * @param string $key Storage model key (e.g. post, page, wp-users)
300
- *
301
- * @return bool|CPAC_Storage_Model Storage Model object (or false, on failure)
302
- */
303
- public function get_storage_model( $key ) {
304
- $models = $this->get_storage_models();
305
-
306
- return isset( $models[ $key ] ) ? $models[ $key ] : false;
307
- }
308
-
309
- /**
310
- * Only set columns on current screens or on specific ajax calls
311
- *
312
- * @since 2.4.9
313
- */
314
- public function set_columns() {
315
-
316
- // Listings screen
317
- $storage_model = $this->get_current_storage_model();
318
-
319
- // WP Ajax calls (not AC)
320
- if ( $model = cac_wp_is_doing_ajax() ) {
321
- $storage_model = $this->get_storage_model( $model );
322
- }
323
-
324
- if ( $storage_model ) {
325
- $storage_model->init_listings_layout();
326
- $storage_model->init_manage_columns();
327
- }
328
- }
329
-
330
- /**
331
- * Get column object
332
- *
333
- * @since 2.5.4
334
- *
335
- * @param $storage_key CPAC_Storage_Model->key
336
- * @param $layout_id CPAC_Storage_Model->layout
337
- * @param $column_name CPAC_Column->name
338
- *
339
- * @return object CPAC_Column Column onject
340
- */
341
- public function get_column( $storage_key, $layout_id, $column_name ) {
342
- $column = false;
343
- if ( $storage_model = $this->get_storage_model( $storage_key ) ) {
344
- $storage_model->set_layout( $layout_id );
345
- $column = $storage_model->get_column_by_name( $column_name );
346
- }
347
-
348
- return $column;
349
- }
350
-
351
- /**
352
- * Get storage model object of currently active storage model
353
- * On the users overview page, for example, this returns the CPAC_Storage_Model_User object
354
- *
355
- * @since 2.2.4
356
- *
357
- * @return CPAC_Storage_Model
358
- */
359
- public function get_current_storage_model() {
360
- if ( ! $this->current_storage_model && $this->is_columns_screen() && $this->get_storage_models() ) {
361
- foreach ( $this->get_storage_models() as $storage_model ) {
362
- if ( $storage_model->is_current_screen() ) {
363
- $this->current_storage_model = $storage_model;
364
- break;
365
- }
366
- }
367
- }
368
-
369
- return $this->current_storage_model;
370
- }
371
-
372
- /**
373
- * Get a list of post types for which Admin Columns is active
374
- *
375
- * @since 1.0
376
- *
377
- * @return array List of post type keys (e.g. post, page)
378
- */
379
- private function get_post_types() {
380
- $post_types = array();
381
-
382
- if ( post_type_exists( 'post' ) ) {
383
- $post_types['post'] = 'post';
384
- }
385
- if ( post_type_exists( 'page' ) ) {
386
- $post_types['page'] = 'page';
387
- }
388
-
389
- $post_types = array_merge( $post_types, get_post_types( array(
390
- '_builtin' => false,
391
- 'show_ui' => true,
392
- ) ) );
393
-
394
- /**
395
- * Filter the post types for which Admin Columns is active
396
- *
397
- * @since 2.0
398
- *
399
- * @param array $post_types List of active post type names
400
- */
401
- return apply_filters( 'cac/post_types', $post_types );
402
- }
403
-
404
- /**
405
- * Get a list of taxonomies supported by Admin Columns
406
- *
407
- * @since 1.0
408
- *
409
- * @return array List of taxonomies
410
- */
411
- public function get_taxonomies() {
412
- $taxonomies = get_taxonomies( array( 'show_ui' => true ) );
413
- if ( isset( $taxonomies['post_format'] ) ) {
414
- unset( $taxonomies['post_format'] );
415
- }
416
-
417
- /**
418
- * Filter the post types for which Admin Columns is active
419
- *
420
- * @since 2.0
421
- *
422
- * @param array $post_types List of active post type names
423
- */
424
- return apply_filters( 'cac/taxonomies', $taxonomies );
425
- }
426
-
427
- /**
428
- * Add a settings link to the Admin Columns entry in the plugin overview screen
429
- *
430
- * @since 1.0
431
- * @see filter:plugin_action_links
432
- */
433
- public function add_settings_link( $links, $file ) {
434
-
435
- if ( $file != plugin_basename( __FILE__ ) ) {
436
- return $links;
437
- }
438
-
439
- array_unshift( $links, '<a href="' . esc_url( admin_url( "options-general.php?page=codepress-admin-columns" ) ) . '">' . __( 'Settings' ) . '</a>' );
440
-
441
- return $links;
442
- }
443
-
444
- /**
445
- * Adds a body class which is used to set individual column widths
446
- *
447
- * @since 1.4.0
448
- *
449
- * @param string $classes body classes
450
- *
451
- * @return string
452
- */
453
- public function admin_class( $classes ) {
454
- if ( $storage_model = $this->get_current_storage_model() ) {
455
- $classes .= " cp-{$storage_model->key}";
456
- }
457
-
458
- return $classes;
459
- }
460
-
461
- /**
462
- * Admin CSS for Column width and Settings Icon
463
- *
464
- * @since 1.4.0
465
- */
466
- public function admin_scripts() {
467
- if ( ! ( $storage_model = $this->get_current_storage_model() ) ) {
468
- return;
469
- }
470
-
471
- $css_column_width = '';
472
- $edit_link = '';
473
-
474
- // CSS: columns width
475
- if ( $columns = $storage_model->get_stored_columns() ) {
476
- foreach ( $columns as $name => $options ) {
477
-
478
- if ( ! empty( $options['width'] ) && is_numeric( $options['width'] ) && $options['width'] > 0 ) {
479
- $unit = isset( $options['width_unit'] ) ? $options['width_unit'] : '%';
480
- $css_column_width .= ".cp-{$storage_model->key} .wrap table th.column-{$name} { width: {$options['width']}{$unit} !important; }";
481
- }
482
-
483
- // Load custom column scripts, used by 3rd party columns
484
- if ( $column = $storage_model->get_column_by_name( $name ) ) {
485
- $column->scripts();
486
- }
487
- }
488
- }
489
-
490
- // JS: edit button
491
- $general_options = get_option( 'cpac_general_options' );
492
- if ( current_user_can( 'manage_admin_columns' ) && ( ! isset( $general_options['show_edit_button'] ) || '1' === $general_options['show_edit_button'] ) ) {
493
- $edit_link = $storage_model->get_edit_link();
494
- }
495
-
496
- ?>
497
- <?php if ( $css_column_width ) : ?>
498
- <style type="text/css">
499
- <?php echo $css_column_width; ?>
500
- </style>
501
- <?php endif; ?>
502
- <?php if ( $edit_link ) : ?>
503
- <script type="text/javascript">
504
- jQuery( document ).ready( function() {
505
- jQuery( '.tablenav.top .actions:last' ).append( '<a href="<?php echo $edit_link; ?>" class="cpac-edit add-new-h2"><?php _e( 'Edit columns', 'codepress-admin-columns' ); ?></a>' );
506
- } );
507
- </script>
508
- <?php endif; ?>
509
-
510
- <?php
511
-
512
- /**
513
- * Add header scripts that only apply to column screens.
514
- * @since 2.3.5
515
- *
516
- * @param object CPAC Main Class
517
- */
518
- do_action( 'cac/admin_head', $storage_model, $this );
519
- }
520
-
521
- public function get_first_storage_model_key() {
522
- $keys = array_keys( (array) $this->get_storage_models() );
523
-
524
- return array_shift( $keys );
525
- }
526
-
527
- public function get_first_storage_model() {
528
- $models = array_values( $this->get_storage_models() );
529
-
530
- return isset( $models[0] ) ? $models[0] : false;
531
- }
532
-
533
- /**
534
- * @since 2.5
535
- */
536
- public function use_delete_confirmation() {
537
- return apply_filters( 'ac/delete_confirmation', true );
538
- }
539
-
540
- /**
541
- * Whether this request is a columns screen (i.e. a content overview page)
542
- *
543
- * @since 2.2
544
- * @return bool Returns true if the current screen is a columns screen, false otherwise
545
- */
546
- public function is_columns_screen() {
547
- global $pagenow;
548
- $columns_screen = in_array( $pagenow, array( 'edit.php', 'upload.php', 'link-manager.php', 'edit-comments.php', 'users.php', 'edit-tags.php' ) );
549
-
550
- /**
551
- * Filter whether the current screen is a columns screen (i.e. a content overview page)
552
- * Useful for advanced used with custom content overview pages
553
- *
554
- * @since 2.2
555
- *
556
- * @param bool $columns_screen Whether the current request is a columns screen
557
- */
558
- return apply_filters( 'cac/is_columns_screen', $columns_screen );
559
- }
560
-
561
- /**
562
- * Whether the current screen is the Admin Columns settings screen
563
- *
564
- * @since 2.2
565
- *
566
- * @param strong $tab Specifies a tab screen (optional)
567
- *
568
- * @return bool True if the current screen is the settings screen, false otherwise
569
- */
570
- public function is_settings_screen( $tab = '' ) {
571
- return cac_is_setting_screen( $tab );
572
- }
573
-
574
- /**
575
- * Whether the current screen is a screen in which Admin Columns is used
576
- * Used to quickly check whether storage models should be loaded
577
- *
578
- * @since 2.2
579
- * @return bool Whether the current screen is an Admin Columns screen
580
- */
581
- public function is_cac_screen() {
582
-
583
- /**
584
- * Filter whether the current screen is a screen in which Admin Columns is active
585
- *
586
- * @since 2.2
587
- *
588
- * @param bool $is_cac_screen Whether the current screen is an Admin Columns screen
589
- */
590
- return apply_filters( 'cac/is_cac_screen', $this->is_columns_screen() || cac_is_doing_ajax() || $this->is_settings_screen() );
591
- }
592
-
593
- /**
594
- * Get admin columns settings class instance
595
- *
596
- * @since 2.2
597
- * @return CPAC_Settings Settings class instance
598
- */
599
- public function settings() {
600
- return $this->_settings;
601
- }
602
-
603
- /**
604
- * Get admin columns add-ons class instance
605
- *
606
- * @since 2.2
607
- * @return CPAC_Addons Add-ons class instance
608
- */
609
- public function addons() {
610
- return $this->_addons;
611
- }
612
-
613
- /**
614
- * Get admin columns upgrade class instance
615
- *
616
- * @since 2.2.7
617
- * @return CPAC_Upgrade Upgrade class instance
618
- */
619
- public function upgrade() {
620
- return $this->_upgrade;
621
- }
622
-
623
- /**
624
- * Check whether the Advanced Custom Fields plugin is active
625
- *
626
- * @since 2.4.9
627
- *
628
- * @return bool Whether the Advanced Custom Fields plugin is active
629
- */
630
- public function is_plugin_acf_active() {
631
- return class_exists( 'acf', false );
632
- }
633
-
634
- /**
635
- * Check whether the WooCommerce plugin is active
636
- *
637
- * @since 2.4.9
638
- *
639
- * @return bool Whether the WooCommerce plugin is active
640
- */
641
- public function is_plugin_woocommerce_active() {
642
- return class_exists( 'WooCommerce', false );
643
- }
644
- }
645
-
646
- function cpac() {
647
- return CPAC::instance();
648
- }
649
-
650
- // Global for backwards compatibility.
651
- $GLOBALS['cpac'] = cpac();
1
+ <?php
2
+ /*
3
+ Plugin Name: Admin Columns
4
+ Version: 3.0
5
+ Description: Customize columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
6
+ Author: AdminColumns.com
7
+ Author URI: https://www.admincolumns.com
8
+ Plugin URI: https://www.admincolumns.com
9
+ Text Domain: codepress-admin-columns
10
+ Domain Path: /languages
11
+ License: GPL v3
12
+
13
+ Admin Columns Plugin
14
+ Copyright (C) 20011-2017, Admin Columns - info@admincolumns.com
15
+ This program is free software: you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License as published by
17
+ the Free Software Foundation, either version 3 of the License, or
18
+ (at your option) any later version.
19
+
20
+ This program is distributed in the hope that it will be useful,
21
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ GNU General Public License for more details.
24
+
25
+ You should have received a copy of the GNU General Public License
26
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
27
+ */
28
+
29
+ if ( ! defined( 'ABSPATH' ) ) {
30
+ exit;
31
+ }
32
+
33
+ // Only run plugin in the admin
34
+ if ( ! is_admin() ) {
35
+ return false;
36
+ }
37
+
38
+ /**
39
+ * The Admin Columns Class
40
+ *
41
+ * @since 1.0
42
+ */
43
+ class CPAC {
44
+
45
+ /**
46
+ * Basename of the plugin, retrieved through plugin_basename function
47
+ *
48
+ * @since 1.0
49
+ * @var string
50
+ */
51
+ private $plugin_basename;
52
+
53
+ /**
54
+ * Admin Columns settings class instance
55
+ *
56
+ * @since 2.2
57
+ * @access private
58
+ * @var AC_Admin
59
+ */
60
+ private $admin;
61
+
62
+ /**
63
+ * @var AC_Groups Column Groups
64
+ */
65
+ private $column_groups;
66
+
67
+ /**
68
+ * @var AC_Groups Listscreen Groups
69
+ */
70
+ private $list_screen_groups;
71
+
72
+ /**
73
+ * @var AC_TableScreen
74
+ */
75
+ private $table_screen;
76
+
77
+ /**
78
+ * @since 3.0
79
+ * @var null|string $version Version number
80
+ */
81
+ private $version = null;
82
+
83
+ /**
84
+ * @since 3.0
85
+ * @var AC_Helper
86
+ */
87
+ private $helper;
88
+
89
+ /**
90
+ * @since 3.0
91
+ * @var AC_ListScreen[]
92
+ */
93
+ private $list_screens;
94
+
95
+ /**
96
+ * @var array $notices
97
+ */
98
+ private $notices;
99
+
100
+ /**
101
+ * @var AC_API
102
+ */
103
+ private $api;
104
+
105
+ /**
106
+ * @var AC_Addons
107
+ */
108
+ private $addons;
109
+
110
+ /**
111
+ * @since 2.5
112
+ */
113
+ private static $_instance = null;
114
+
115
+ /**
116
+ * @since 2.5
117
+ */
118
+ public static function instance() {
119
+ if ( null === self::$_instance ) {
120
+ self::$_instance = new self();
121
+ }
122
+
123
+ return self::$_instance;
124
+ }
125
+
126
+ /**
127
+ * @since 1.0
128
+ */
129
+ private function __construct() {
130
+ $this->plugin_basename = plugin_basename( __FILE__ );
131
+
132
+ // Backwards compatibility
133
+ define( 'CPAC_VERSION', $this->get_version() );
134
+ define( 'CPAC_URL', $this->get_plugin_url() );
135
+ define( 'CPAC_DIR', $this->get_plugin_dir() );
136
+
137
+ // Autoload classes
138
+ $this->autoloader()->register_prefix( 'AC_', $this->get_plugin_dir() . 'classes/' );
139
+
140
+ require_once $this->get_plugin_dir() . 'api.php';
141
+
142
+ // Third Party
143
+ new AC_ThirdParty_ACF();
144
+ new AC_ThirdParty_NinjaForms();
145
+ new AC_ThirdParty_WooCommerce();
146
+ new AC_ThirdParty_WPML();
147
+
148
+ // Init
149
+ $this->addons = new AC_Addons();
150
+ $this->admin = new AC_Admin();
151
+ $this->table_screen = new AC_TableScreen();
152
+