admin
2 years ago
ajax
2 years ago
api
2 years ago
fields
2 years ago
forms
2 years ago
legacy
2 years ago
locations
2 years ago
post-types
2 years ago
rest-api
2 years ago
walkers
2 years ago
acf-bidirectional-functions.php
2 years ago
acf-field-functions.php
2 years ago
acf-field-group-functions.php
2 years ago
acf-form-functions.php
2 years ago
acf-helper-functions.php
2 years ago
acf-hook-functions.php
2 years ago
acf-input-functions.php
2 years ago
acf-internal-post-type-functions.php
2 years ago
acf-meta-functions.php
2 years ago
acf-post-functions.php
4 years ago
acf-post-type-functions.php
2 years ago
acf-taxonomy-functions.php
2 years ago
acf-user-functions.php
2 years ago
acf-utility-functions.php
2 years ago
acf-value-functions.php
2 years ago
acf-wp-functions.php
2 years ago
assets.php
2 years ago
class-acf-data.php
2 years ago
class-acf-internal-post-type.php
2 years ago
compatibility.php
2 years ago
deprecated.php
2 years ago
fields.php
2 years ago
l10n.php
2 years ago
local-fields.php
2 years ago
local-json.php
2 years ago
local-meta.php
2 years ago
locations.php
2 years ago
loop.php
2 years ago
media.php
2 years ago
rest-api.php
4 years ago
revisions.php
2 years ago
third-party.php
2 years ago
upgrades.php
2 years ago
validation.php
2 years ago
wpml.php
2 years ago
third-party.php
152 lines
| 1 | <?php |
| 2 | /** |
| 3 | * ACF 3rd Party Compatibility Class |
| 4 | * |
| 5 | * All the logic for 3rd party functionality |
| 6 | * |
| 7 | * @package ACF |
| 8 | * @subpackage Core |
| 9 | */ |
| 10 | |
| 11 | if ( ! class_exists( 'acf_third_party' ) ) : |
| 12 | |
| 13 | /** |
| 14 | * ACF 3rd Party Compatibility Class |
| 15 | */ |
| 16 | class acf_third_party { |
| 17 | |
| 18 | /** |
| 19 | * This function will setup the class functionality |
| 20 | * |
| 21 | * @since 5.0.0 |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | // Tabify Edit Screen - http://wordpress.org/extend/plugins/tabify-edit-screen/ |
| 25 | if ( class_exists( 'Tabify_Edit_Screen' ) ) { |
| 26 | add_filter( 'tabify_posttypes', array( $this, 'tabify_posttypes' ) ); |
| 27 | add_action( 'tabify_add_meta_boxes', array( $this, 'tabify_add_meta_boxes' ) ); |
| 28 | } |
| 29 | |
| 30 | // Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/ |
| 31 | if ( class_exists( 'Post_Type_Switcher' ) ) { |
| 32 | add_filter( 'pts_allowed_pages', array( $this, 'pts_allowed_pages' ) ); |
| 33 | } |
| 34 | |
| 35 | // Event Espresso - https://wordpress.org/plugins/event-espresso-decaf/ |
| 36 | if ( function_exists( 'espresso_version' ) ) { |
| 37 | add_filter( 'acf/get_post_types', array( $this, 'ee_get_post_types' ), 10, 2 ); |
| 38 | } |
| 39 | |
| 40 | // Dark Mode |
| 41 | if ( class_exists( 'Dark_Mode' ) ) { |
| 42 | add_action( 'doing_dark_mode', array( $this, 'doing_dark_mode' ) ); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Event Espresso post types do not use the native post.php edit page, but instead render their own. |
| 48 | * Show the EE post types in lists where 'show_ui' is used. |
| 49 | * |
| 50 | * @date 24/2/18 |
| 51 | * @since 5.6.9 |
| 52 | * |
| 53 | * @param array $post_types Post types array. |
| 54 | * @param array $args Other arguments array. |
| 55 | * @return array |
| 56 | */ |
| 57 | public function ee_get_post_types( $post_types, $args ) { |
| 58 | if ( ! empty( $args['show_ui'] ) ) { |
| 59 | $ee_post_types = get_post_types( array( 'show_ee_ui' => 1 ) ); |
| 60 | $ee_post_types = array_keys( $ee_post_types ); |
| 61 | $post_types = array_merge( $post_types, $ee_post_types ); |
| 62 | $post_types = array_unique( $post_types ); |
| 63 | } |
| 64 | |
| 65 | return $post_types; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * This function removes ACF post types from the tabify edit screen (post type selection sidebar) |
| 70 | * |
| 71 | * @since 3.5.1 |
| 72 | * |
| 73 | * @param array $posttypes An array of post types supported by tabify. |
| 74 | * @return array |
| 75 | */ |
| 76 | public function tabify_posttypes( $posttypes ) { |
| 77 | // unset ACF post types |
| 78 | unset( $posttypes['acf-field-group'] ); |
| 79 | unset( $posttypes['acf-field'] ); |
| 80 | |
| 81 | return $posttypes; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * This function creates dummy metaboxes on the tabify edit screen page |
| 87 | * |
| 88 | * @since 3.5.1 |
| 89 | * |
| 90 | * @param string $post_type The name of the displayed post type. |
| 91 | */ |
| 92 | public function tabify_add_meta_boxes( $post_type ) { |
| 93 | // get field groups |
| 94 | $field_groups = acf_get_field_groups(); |
| 95 | |
| 96 | if ( ! empty( $field_groups ) ) { |
| 97 | foreach ( $field_groups as $field_group ) { |
| 98 | |
| 99 | // vars |
| 100 | $id = "acf-{$field_group['key']}"; |
| 101 | $title = 'ACF: ' . $field_group['title']; |
| 102 | |
| 103 | // add meta box |
| 104 | add_meta_box( $id, acf_esc_html( $title ), '__return_true', $post_type ); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | |
| 110 | /** |
| 111 | * This filter will prevent PTS from running on the field group page |
| 112 | * |
| 113 | * @since 5.0.0 |
| 114 | * |
| 115 | * @param array $pages An array of pages PTS should run on. |
| 116 | * @return array |
| 117 | */ |
| 118 | public function pts_allowed_pages( $pages ) { |
| 119 | |
| 120 | // vars |
| 121 | $post_type = ''; |
| 122 | |
| 123 | // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Verified elsewhere. |
| 124 | // check $_GET because it is too early to use functions / global vars. |
| 125 | if ( ! empty( $_GET['post_type'] ) ) { |
| 126 | $post_type = sanitize_text_field( $_GET['post_type'] ); |
| 127 | } elseif ( ! empty( $_GET['post'] ) ) { |
| 128 | $post_type = get_post_type( $_GET['post'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized when get_post_type() calls get_post(). |
| 129 | } |
| 130 | // phpcs:enable WordPress.Security.NonceVerification.Recommended |
| 131 | // check post type |
| 132 | if ( $post_type == 'acf-field-group' ) { |
| 133 | $pages = array(); |
| 134 | } |
| 135 | |
| 136 | // return |
| 137 | return $pages; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Runs during 'admin_enqueue_scripts' if dark mode is enabled |
| 142 | * |
| 143 | * @since 5.7.3 |
| 144 | */ |
| 145 | public function doing_dark_mode() { |
| 146 | wp_enqueue_style( 'acf-dark', acf_get_url( 'assets/css/acf-dark.css' ), array(), ACF_VERSION ); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | new acf_third_party(); |
| 151 | endif; |
| 152 |