acf_field_groups

Acf_field_groups.

Defined (1)

The class is defined in the following location(s).

/core/controllers/field_groups.php  
  1. class acf_field_groups  
  2.  
  3. /** 
  4. * __construct 
  5. * @description:  
  6. * @since 3.1.8 
  7. * @created: 23/06/12 
  8. */ 
  9.  
  10. function __construct() 
  11. // actions 
  12. add_action('admin_menu', array($this, 'admin_menu')); 
  13.  
  14.  
  15. /** 
  16. * admin_menu 
  17. * @description:  
  18. * @created: 2/08/12 
  19. */ 
  20.  
  21. function admin_menu() 
  22.  
  23. // validate page 
  24. if( ! $this->validate_page() ) 
  25. return; 
  26.  
  27.  
  28. // actions 
  29. add_action('admin_print_scripts', array($this, 'admin_print_scripts')); 
  30. add_action('admin_print_styles', array($this, 'admin_print_styles')); 
  31. add_action('admin_footer', array($this, 'admin_footer')); 
  32.  
  33.  
  34. // columns 
  35. add_filter( 'manage_edit-acf_columns', array($this, 'acf_edit_columns'), 10, 1 ); 
  36. add_action( 'manage_acf_posts_custom_column' , array($this, 'acf_columns_display'), 10, 2 ); 
  37.  
  38.  
  39.  
  40. /** 
  41. * validate_page 
  42. * @description: returns true | false. Used to stop a function from continuing 
  43. * @since 3.2.6 
  44. * @created: 23/06/12 
  45. */ 
  46.  
  47. function validate_page() 
  48. // global 
  49. global $pagenow; 
  50.  
  51.  
  52. // vars 
  53. $return = false; 
  54.  
  55.  
  56. // validate page 
  57. if( in_array( $pagenow, array('edit.php') ) ) 
  58.  
  59. // validate post type 
  60. if( isset($_GET['post_type']) && $_GET['post_type'] == 'acf' ) 
  61. $return = true; 
  62.  
  63.  
  64. if( isset($_GET['page']) ) 
  65. $return = false; 
  66.  
  67.  
  68.  
  69. // return 
  70. return $return; 
  71.  
  72.  
  73. /** 
  74. * admin_print_scripts 
  75. * @description:  
  76. * @since 3.1.8 
  77. * @created: 23/06/12 
  78. */ 
  79.  
  80. function admin_print_scripts() 
  81. wp_enqueue_script(array( 
  82. 'jquery',  
  83. 'thickbox',  
  84. )); 
  85.  
  86.  
  87. /** 
  88. * admin_print_styles 
  89. * @description:  
  90. * @since 3.1.8 
  91. * @created: 23/06/12 
  92. */ 
  93.  
  94. function admin_print_styles() 
  95. wp_enqueue_style(array( 
  96. 'thickbox',  
  97. 'acf-global',  
  98. 'acf',  
  99. )); 
  100.  
  101.  
  102. /** 
  103. * acf_edit_columns 
  104. * @description:  
  105. * @created: 2/08/12 
  106. */ 
  107.  
  108. function acf_edit_columns( $columns ) 
  109. $columns = array( 
  110. 'cb' => '<input type="checkbox" />',  
  111. 'title' => __("Title"),  
  112. 'fields' => __("Fields", 'acf') 
  113. ); 
  114.  
  115. return $columns; 
  116.  
  117.  
  118. /** 
  119. * acf_columns_display 
  120. * @description:  
  121. * @created: 2/08/12 
  122. */ 
  123.  
  124. function acf_columns_display( $column, $post_id ) 
  125. // vars 
  126. switch ($column) 
  127. case "fields": 
  128.  
  129. // vars 
  130. $count =0; 
  131. $keys = get_post_custom_keys( $post_id ); 
  132.  
  133. if($keys) 
  134. foreach($keys as $key) 
  135. if(strpos($key, 'field_') !== false) 
  136. $count++; 
  137.  
  138. echo $count; 
  139.  
  140. break; 
  141.  
  142.  
  143. /** 
  144. * admin_footer 
  145. * @description:  
  146. * @since 3.1.8 
  147. * @created: 23/06/12 
  148. */ 
  149.  
  150. function admin_footer() 
  151. // vars 
  152. $version = apply_filters('acf/get_info', 'version'); 
  153. $dir = apply_filters('acf/get_info', 'dir'); 
  154. $path = apply_filters('acf/get_info', 'path'); 
  155. $show_tab = isset($_GET['info']); 
  156. $tab = isset($_GET['info']) ? $_GET['info'] : 'changelog'; 
  157.  
  158. ?> 
  159. <script type="text/html" id="tmpl-acf-column-2"> 
  160. <div class="acf-column-2"> 
  161. <div class="wp-box"> 
  162. <div class="inner"> 
  163. <h2><?php _e("Advanced Custom Fields", 'acf'); ?> <?php echo $version; ?></h2> 
  164.  
  165. <h3><?php _e("Changelog", 'acf'); ?></h3> 
  166. <p><?php printf(__('See what\'s new in %1$sversion %2$s%3$s', 'acf'), '<a href="'.admin_url('edit.php?post_type=acf&info=changelog').'">', $version, '</a>'); ?></p> 
  167.  
  168. <h3><?php _e("Resources", 'acf'); ?></h3> 
  169. <ul> 
  170. <li><a href="http://www.advancedcustomfields.com/resources/#getting-started" target="_blank"><?php _e("Getting Started", 'acf'); ?></a></li> 
  171. <li><a href="http://www.advancedcustomfields.com/resources/#field-types" target="_blank"><?php _e("Field Types", 'acf'); ?></a></li> 
  172. <li><a href="http://www.advancedcustomfields.com/resources/#functions" target="_blank"><?php _e("Functions", 'acf'); ?></a></li> 
  173. <li><a href="http://www.advancedcustomfields.com/resources/#actions" target="_blank"><?php _e("Actions", 'acf'); ?></a></li> 
  174. <li><a href="http://www.advancedcustomfields.com/resources/#filters" target="_blank"><?php _e("Filters", 'acf'); ?></a></li> 
  175. <li><a href="http://www.advancedcustomfields.com/resources/#how-to" target="_blank"><?php _e("'How to' guides", 'acf'); ?></a></li> 
  176. <li><a href="http://www.advancedcustomfields.com/resources/#tutorials" target="_blank"><?php _e("Tutorials", 'acf'); ?></a></li> 
  177. </ul> 
  178. </div> 
  179. <div class="footer footer-blue"> 
  180. <ul class="hl"> 
  181. <li><?php _e("Created by", 'acf'); ?> Elliot Condon</li> 
  182. </ul> 
  183. </div> 
  184. </div> 
  185. </div> 
  186. </script> 
  187. <script type="text/html" id="tmpl-acf-about"> 
  188. <!-- acf-about --> 
  189. <div id="acf-about" class="acf-content"> 
  190.  
  191. <!-- acf-content-title --> 
  192. <div class="acf-content-title"> 
  193. <h1><?php _e("Welcome to Advanced Custom Fields", 'acf'); ?> <?php echo $version; ?></h1> 
  194. <h2><?php _e("Thank you for updating to the latest version!", 'acf'); ?> <br /><?php printf(__('ACF %s is more polished and enjoyable than ever before. We hope you like it.', 'acf'), $version); ?></h2> 
  195. </div> 
  196. <!-- / acf-content-title --> 
  197.  
  198. <!-- acf-content-body --> 
  199. <div class="acf-content-body"> 
  200. <h2 class="nav-tab-wrapper"> 
  201. <a class="acf-tab-toggle nav-tab <?php if( $tab == 'whats-new' ) { echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=whats-new'); ?>"><?php _e("What*s New", 'acf'); ?></a> 
  202. <a class="acf-tab-toggle nav-tab <?php if( $tab == 'changelog' ) { echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>"><?php _e("Changelog", 'acf'); ?></a> 
  203. <?php if( $tab == 'download-add-ons' ): ?> 
  204. <a class="acf-tab-toggle nav-tab nav-tab-active" href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>"><?php _e("Download Add-ons", 'acf'); ?></a> 
  205. <?php endif; ?> 
  206. </h2> 
  207.  
  208. <?php if( $tab == 'whats-new' ):  
  209.  
  210. $activation_codes = array( 
  211. 'repeater' => get_option('acf_repeater_ac', ''),  
  212. 'gallery' => get_option('acf_gallery_ac', ''),  
  213. 'options_page' => get_option('acf_options_page_ac', ''),  
  214. 'flexible_content' => get_option('acf_flexible_content_ac', '') 
  215. ); 
  216.  
  217. $active = array( 
  218. 'repeater' => class_exists('acf_field_repeater'),  
  219. 'gallery' => class_exists('acf_field_gallery'),  
  220. 'options_page' => class_exists('acf_options_page_plugin'),  
  221. 'flexible_content' => class_exists('acf_field_flexible_content') 
  222. ); 
  223.  
  224. $update_required = false; 
  225. $update_complete = true; 
  226.  
  227. foreach( $activation_codes as $k => $v ) 
  228. if( $v ) 
  229. $update_required = true; 
  230.  
  231. if( !$active[ $k ] ) 
  232. $update_complete = false; 
  233.  
  234.  
  235. ?> 
  236.  
  237. <table id="acf-add-ons-table" class="alignright"> 
  238. <tr> 
  239. <td><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" /></td> 
  240. <td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td> 
  241. </tr> 
  242. <tr> 
  243. <td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td> 
  244. <td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td> 
  245. </tr> 
  246. </table> 
  247.  
  248. <div style="margin-right: 300px;"> 
  249.  
  250. <h3><?php _e("Add-ons", 'acf'); ?></h3> 
  251.  
  252. <h4><?php _e("Activation codes have grown into plugins!", 'acf'); ?></h4> 
  253. <p><?php _e("Add-ons are now activated by downloading and installing individual plugins. Although these plugins will not be hosted on the wordpress.org repository, each Add-on will continue to receive updates in the usual way.", 'acf'); ?></p> 
  254.  
  255.  
  256. <?php if( $update_required ): ?> 
  257. <?php if( $update_complete ): ?> 
  258. <div class="acf-alert acf-alert-success"> 
  259. <p><?php _e("All previous Add-ons have been successfully installed", 'acf'); ?></p> 
  260. </div> 
  261. <?php else: ?> 
  262. <div class="acf-alert acf-alert-success"> 
  263. <p><?php _e("This website uses premium Add-ons which need to be downloaded", 'acf'); ?> <a href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>" class="acf-button" style="display: inline-block;"><?php _e("Download your activated Add-ons", 'acf'); ?></a></p> 
  264. </div> 
  265. <?php endif; ?> 
  266. <?php else: ?> 
  267. <div class="acf-alert acf-alert-success"> 
  268. <p><?php _e("This website does not use premium Add-ons and will not be affected by this change.", 'acf'); ?></p> 
  269. </div> 
  270. <?php endif; ?> 
  271.  
  272. </div> 
  273.  
  274. <div class="clear"></div> 
  275.  
  276. <hr /> 
  277.  
  278. <h3><?php _e("Easier Development", 'acf'); ?></h3> 
  279.  
  280. <h4><?php _e("New Field Types", 'acf'); ?></h4> 
  281. <ul> 
  282. <li><?php _e("Taxonomy Field", 'acf'); ?></li> 
  283. <li><?php _e("User Field", 'acf'); ?></li> 
  284. <li><?php _e("Email Field", 'acf'); ?></li> 
  285. <li><?php _e("Password Field", 'acf'); ?></li> 
  286. </ul> 
  287. <h4><?php _e("Custom Field Types", 'acf'); ?></h4> 
  288. <p><?php _e("Creating your own field type has never been easier! Unfortunately, version 3 field types are not compatible with version 4.", 'acf'); ?><br /> 
  289. <?php printf(__('Migrating your field types is easy, please %sfollow this tutorial%s to learn more.', 'acf'), '<a href="http://www.advancedcustomfields.com/docs/tutorials/creating-a-new-field-type/" target="_blank">', '</a>'); ?></p> 
  290.  
  291. <h4><?php _e("Actions & Filters", 'acf'); ?></h4> 
  292. <p><?php printf(__('All actions & filters have received a major facelift to make customizing ACF even easier! Please %sread this guide%s to find the updated naming convention.', 'acf'), '<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">', '</a>'); ?></p> 
  293.  
  294. <h4><?php _e("Preview draft is now working!", 'acf'); ?></h4> 
  295. <p><?php _e("This bug has been squashed along with many other little critters!", 'acf'); ?> <a class="acf-tab-toggle" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>" data-tab="2"><?php _e("See the full changelog", 'acf'); ?></a></p> 
  296.  
  297. <hr /> 
  298.  
  299. <h3><?php _e("Important", 'acf'); ?></h3> 
  300.  
  301. <h4><?php _e("Database Changes", 'acf'); ?></h4> 
  302. <p><?php _e("Absolutely <strong>no</strong> changes have been made to the database between versions 3 and 4. This means you can roll back to version 3 without any issues.", 'acf'); ?></p> 
  303.  
  304. <h4><?php _e("Potential Issues", 'acf'); ?></h4> 
  305. <p><?php printf(__('Due to the sizable changes surrounding Add-ons, field types and action/filters, your website may not operate correctly. It is important that you read the full %sMigrating from v3 to v4%s guide to view the full list of changes.', 'acf'), '<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">', '</a>'); ?></p> 
  306.  
  307. <div class="acf-alert acf-alert-error"> 
  308. <p><strong><?php _e("Really Important!", 'acf'); ?></strong> <?php printf(__('If you updated the ACF plugin without prior knowledge of such changes, please roll back to the latest %sversion 3%s of this plugin.', 'acf'), '<a href="http://wordpress.org/extend/plugins/advanced-custom-fields/developers/">', '</a>'); ?></p> 
  309. </div> 
  310.  
  311. <hr /> 
  312.  
  313. <h3><?php _e("Thank You", 'acf'); ?></h3> 
  314. <p><?php _e("A <strong>BIG</strong> thank you to everyone who has helped test the version 4 beta and for all the support I have received.", 'acf'); ?></p> 
  315. <p><?php _e("Without you all, this release would not have been possible!", 'acf'); ?></p> 
  316.  
  317. <?php elseif( $tab == 'changelog' ): ?> 
  318.  
  319. <h3><?php _e("Changelog for", 'acf'); ?> <?php echo $version; ?></h3> 
  320. <?php 
  321.  
  322. $items = file_get_contents( $path . 'readme.txt' ); 
  323. $items = explode('= ' . $version . ' =', $items); 
  324.  
  325. $items = end( $items ); 
  326. $items = current( explode("\n\n", $items) ); 
  327. $items = array_filter( array_map('trim', explode("*", $items)) ); 
  328.  
  329. ?> 
  330. <ul class="acf-changelog"> 
  331. <?php foreach( $items as $item ):  
  332.  
  333. $item = explode('http', $item); 
  334.  
  335. ?> 
  336. <li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank"><?php _e("Learn more", 'acf'); ?></a><?php endif; ?></li> 
  337. <?php endforeach; ?> 
  338. </ul> 
  339.  
  340. <?php elseif( $tab == 'download-add-ons' ): ?> 
  341.  
  342. <h3><?php _e("Overview", 'acf'); ?></h3> 
  343.  
  344. <p><?php _e("Previously, all Add-ons were unlocked via an activation code (purchased from the ACF Add-ons store). New to v4, all Add-ons act as separate plugins which need to be individually downloaded, installed and updated.", 'acf'); ?></p> 
  345.  
  346. <p><?php _e("This page will assist you in downloading and installing each available Add-on.", 'acf'); ?></p> 
  347.  
  348. <h3><?php _e("Available Add-ons", 'acf'); ?></h3> 
  349.  
  350. <p><?php _e("The following Add-ons have been detected as activated on this website.", 'acf'); ?></p> 
  351.  
  352. <?php  
  353.  
  354. $ac_repeater = get_option('acf_repeater_ac', ''); 
  355. $ac_options_page = get_option('acf_options_page_ac', ''); 
  356. $ac_flexible_content = get_option('acf_flexible_content_ac', ''); 
  357. $ac_gallery = get_option('acf_gallery_ac', ''); 
  358.  
  359. ?> 
  360. <table class="widefat" id="acf-download-add-ons-table"> 
  361. <thead> 
  362. <tr> 
  363. <th colspan="2"><?php _e("Name", 'acf'); ?></th> 
  364. <th><?php _e("Activation Code", 'acf'); ?></th> 
  365. <th><?php _e("Download", 'acf'); ?></th> 
  366. </tr> 
  367. </thead> 
  368. <tbody> 
  369. <?php if( $ac_repeater ): ?> 
  370. <tr> 
  371. <td class="td-image"><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" style="width:50px" /></td> 
  372. <th class="td-name"><?php _e("Repeater Field", 'acf'); ?></th> 
  373. <td class="td-code">XXXX-XXXX-XXXX-<?php echo substr($ac_repeater, -4); ?></td> 
  374. <td class="td-download"><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_repeater; ?>/trunk"><?php _e("Download", 'acf'); ?></a></td> 
  375. </tr> 
  376. <?php endif; ?> 
  377. <?php if( $ac_gallery ): ?> 
  378. <tr> 
  379. <td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td> 
  380. <th><?php _e("Gallery Field", 'acf'); ?></th> 
  381. <td>XXXX-XXXX-XXXX-<?php echo substr($ac_gallery, -4); ?></td> 
  382. <td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_gallery; ?>/trunk"><?php _e("Download", 'acf'); ?></a></td> 
  383. </tr>  
  384. <?php endif; ?> 
  385. <?php if( $ac_options_page ): ?> 
  386. <tr> 
  387. <td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td> 
  388. <th><?php _e("Options Page", 'acf'); ?></th> 
  389. <td>XXXX-XXXX-XXXX-<?php echo substr($ac_options_page, -4); ?></td> 
  390. <td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_options_page; ?>/trunk"><?php _e("Download", 'acf'); ?></a></td> 
  391. </tr> 
  392. <?php endif; ?> 
  393. <?php if($ac_flexible_content): ?> 
  394. <tr> 
  395. <td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td> 
  396. <th><?php _e("Flexible Content", 'acf'); ?></th> 
  397. <td>XXXX-XXXX-XXXX-<?php echo substr($ac_flexible_content, -4); ?></td> 
  398. <td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_flexible_content; ?>/trunk"><?php _e("Download", 'acf'); ?></a></td> 
  399. </tr> 
  400. <?php endif; ?> 
  401. </tbody> 
  402. </table> 
  403.  
  404.  
  405.  
  406. <h3><?php _e("Installation", 'acf'); ?></h3> 
  407.  
  408. <p><?php _e("For each Add-on available, please perform the following:", 'acf'); ?></p> 
  409. <ol> 
  410. <li><?php _e("Download the Add-on plugin (.zip file) to your desktop", 'acf'); ?></li> 
  411. <li><?php printf(__('Navigate to %sPlugins > Add New > Upload%s', 'acf'), '<a target="_blank" href="'.admin_url('plugin-install.php?tab=upload').'">', '</a>'); ?></li> 
  412. <li><?php _e("Use the uploader to browse, select and install your Add-on (.zip file)", 'acf'); ?></li> 
  413. <li><?php _e("Once the plugin has been uploaded and installed, click the 'Activate Plugin' link", 'acf'); ?></li> 
  414. <li><?php _e("The Add-on is now installed and activated!", 'acf'); ?></li> 
  415. </ol> 
  416.  
  417.  
  418. <?php endif; ?> 
  419.  
  420.  
  421. </div> 
  422. <!-- / acf-content-body --> 
  423.  
  424.  
  425. <!-- acf-content-footer --> 
  426. <div class="acf-content-footer"> 
  427. <ul class="hl clearfix"> 
  428. <li><a class="acf-button acf-button-big" href="<?php echo admin_url('edit.php?post_type=acf'); ?>"><?php _e("Awesome. Let's get to work", 'acf'); ?></a></li> 
  429. </ul> 
  430. </div> 
  431. <!-- / acf-content-footer --> 
  432.  
  433.  
  434.  
  435. </div> 
  436. <!-- / acf-about --> 
  437. </script> 
  438. <script type="text/javascript"> 
  439. (function($) { 
  440.  
  441. // wrap 
  442. $('#wpbody .wrap').attr('id', 'acf-field-group-wrap'); 
  443.  
  444.  
  445. // wrap column main 
  446. $('#acf-field-group-wrap').wrapInner('<div class="acf-columns-2" />'); 
  447.  
  448.  
  449. // add column main 
  450. $('#posts-filter').addClass('acf-column-1'); 
  451.  
  452.  
  453. // add column side 
  454. $('#posts-filter').after( $('#tmpl-acf-column-2').html() ); 
  455.  
  456.  
  457. <?php if( $show_tab ): ?> 
  458. // add about copy 
  459. $('#wpbody-content').prepend( $('#tmpl-acf-about').html() ); 
  460. $('#acf-field-group-wrap').hide(); 
  461. $('#screen-meta-links').hide(); 
  462. <?php endif; ?> 
  463.  
  464. })(jQuery); 
  465. </script> 
  466. <?php 
  467.