acf_third_party

Acf_third_party.

Defined (1)

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

/core/controllers/third_party.php  
  1. class acf_third_party 
  2. /** 
  3. * __construct 
  4. * @description:  
  5. * @since 3.1.8 
  6. * @created: 23/06/12 
  7. */ 
  8.  
  9. function __construct() 
  10. // Tabify Edit Screen - http://wordpress.org/extend/plugins/tabify-edit-screen/ 
  11. add_action('admin_head-settings_page_tabify-edit-screen', array($this, 'admin_head_tabify')); 
  12.  
  13.  
  14. // Duplicate Post - http://wordpress.org/extend/plugins/duplicate-post/ 
  15. add_action('dp_duplicate_page', array($this, 'dp_duplicate_page'), 11, 2); 
  16.  
  17.  
  18. // Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/ 
  19. add_filter('pts_post_type_filter', array($this, 'pts_post_type_filter')); 
  20.  
  21.  
  22.  
  23. /** 
  24. * pts_allowed_pages 
  25. * @description:  
  26. * @since 3.5.3 
  27. * @created: 19/11/12 
  28. */ 
  29.  
  30. function pts_post_type_filter( $args ) 
  31.  
  32. // global 
  33. global $typenow; 
  34.  
  35. if( $typenow == "acf" ) 
  36. $args = array( 
  37. 'public' => false,  
  38. 'show_ui' => true 
  39. ); 
  40.  
  41.  
  42. // return 
  43. return $args; 
  44.  
  45.  
  46. /** 
  47. * admin_head_tabify 
  48. * @description:  
  49. * @since 3.5.1 
  50. * @created: 9/10/12 
  51. */ 
  52.  
  53. function admin_head_tabify() 
  54. // remove ACF from the tabs 
  55. add_filter('tabify_posttypes', array($this, 'tabify_posttypes')); 
  56.  
  57.  
  58. // add acf metaboxes to list 
  59. add_action('tabify_add_meta_boxes' , array($this, 'tabify_add_meta_boxes')); 
  60.  
  61.  
  62.  
  63. /** 
  64. * tabify_posttypes 
  65. * @description:  
  66. * @since 3.5.1 
  67. * @created: 9/10/12 
  68. */ 
  69.  
  70. function tabify_posttypes( $posttypes ) 
  71. if( isset($posttypes['acf']) ) 
  72. unset( $posttypes['acf'] ); 
  73.  
  74. return $posttypes; 
  75.  
  76.  
  77. /** 
  78. * tabify_add_meta_boxes 
  79. * @description:  
  80. * @since 3.5.1 
  81. * @created: 9/10/12 
  82. */ 
  83.  
  84. function tabify_add_meta_boxes( $post_type ) 
  85. // get acf's 
  86. $acfs = apply_filters('acf/get_field_groups', array()); 
  87.  
  88. if($acfs) 
  89. foreach($acfs as $acf) 
  90. // add meta box 
  91. add_meta_box( 
  92. 'acf_' . $acf['id'],  
  93. $acf['title'],  
  94. array($this, 'dummy'),  
  95. $post_type 
  96. ); 
  97.  
  98. // foreach($acfs as $acf) 
  99. // if($acfs) 
  100.  
  101. function dummy() { /** Do Nothing */ } 
  102.  
  103.  
  104.  
  105. /** 
  106. * dp_duplicate_page 
  107. * @description:  
  108. * @since 3.5.1 
  109. * @created: 9/10/12 
  110. */ 
  111.  
  112. function dp_duplicate_page( $new_post_id, $old_post_object ) 
  113. // only for acf 
  114. if( $old_post_object->post_type != "acf" ) 
  115. return; 
  116.  
  117.  
  118. // update keys 
  119. $metas = get_post_custom( $new_post_id ); 
  120.  
  121.  
  122. if( $metas ) 
  123. foreach( $metas as $field_key => $field ) 
  124. if( strpos($field_key, 'field_') !== false ) 
  125. $field = $field[0]; 
  126. $field = maybe_unserialize( $field ); 
  127. $field = maybe_unserialize( $field ); // just to be sure! 
  128.  
  129. // delete old field 
  130. delete_post_meta($new_post_id, $field_key); 
  131.  
  132.  
  133. // set new keys (recursive for sub fields) 
  134. $this->create_new_field_keys( $field ); 
  135.  
  136.  
  137. // save it! 
  138. update_post_meta($new_post_id, $field['key'], $field); 
  139.  
  140. // if( strpos($field_key, 'field_') !== false ) 
  141. // foreach( $metas as $field_key => $field ) 
  142. // if( $metas ) 
  143.  
  144.  
  145.  
  146. /** 
  147. * create_new_field_keys 
  148. * @description:  
  149. * @since 3.5.1 
  150. * @created: 9/10/12 
  151. */ 
  152.  
  153. function create_new_field_keys( &$field ) 
  154. // update key 
  155. $field['key'] = 'field_' . uniqid(); 
  156.  
  157.  
  158. if( isset($field['sub_fields']) && is_array($field['sub_fields']) ) 
  159. foreach( $field['sub_fields'] as $f ) 
  160. $this->create_new_field_keys( $f ); 
  161. elseif( isset($field['layouts']) && is_array($field['layouts']) ) 
  162. foreach( $field['layouts'] as $layout ) 
  163. if( isset($layout['sub_fields']) && is_array($layout['sub_fields']) ) 
  164. foreach( $layout['sub_fields'] as $f ) 
  165. $this->create_new_field_keys( $f ); 
  166.  
  167.  
  168.  
  169.