admin
3 months ago
field-groups
3 months ago
fields
1 week ago
fields-settings
3 months ago
forms
3 months ago
locations
3 months ago
modules
1 week ago
screens
3 months ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
3 months ago
acfe-field-group-functions.php
3 months ago
acfe-file-functions.php
1 year ago
acfe-form-functions.php
3 months ago
acfe-helper-array-functions.php
3 months ago
acfe-helper-functions.php
3 months ago
acfe-helper-multi-functions.php
3 months ago
acfe-helper-string-functions.php
3 months ago
acfe-meta-functions.php
3 months ago
acfe-post-functions.php
3 months ago
acfe-screen-functions.php
3 months ago
acfe-template-functions.php
3 months ago
acfe-term-functions.php
3 months ago
acfe-user-functions.php
3 months ago
acfe-wp-functions.php
3 years ago
assets.php
3 months ago
compatibility-acf-5.8.php
4 months ago
compatibility-acf-5.9.php
3 months ago
compatibility-acf-6.5.php
3 months ago
compatibility-acf-6.8.6.php
1 week ago
compatibility.php
3 months ago
field-extend.php
4 months ago
field.php
4 months ago
hooks.php
3 months ago
init.php
3 months ago
local-meta.php
3 years ago
media.php
3 months ago
module-acf.php
3 months ago
module-db.php
3 months ago
module-l10n.php
3 months ago
module-legacy.php
3 years ago
module-manager.php
4 months ago
module-post.php
3 months ago
module-posts.php
4 months ago
module-upgrades.php
3 years ago
module.php
3 months ago
multilang.php
3 months ago
revisions.php
4 months ago
screen.php
3 months ago
settings.php
3 months ago
template-tags.php
3 months ago
third-party.php
3 years ago
upgrades.php
3 months ago
third-party.php
255 lines
| 1 | <?php |
| 2 | |
| 3 | use WPGraphQL\AppContext; |
| 4 | use WPGraphQL\Model\Term; |
| 5 | |
| 6 | if(!defined('ABSPATH')){ |
| 7 | exit; |
| 8 | } |
| 9 | |
| 10 | if(!class_exists('acfe_third_party')): |
| 11 | |
| 12 | class acfe_third_party{ |
| 13 | |
| 14 | /** |
| 15 | * construct |
| 16 | */ |
| 17 | function __construct(){ |
| 18 | |
| 19 | add_filter('pto/posts_orderby/ignore', array($this, 'pto_posts_orderby_ignore'), 10, 3); |
| 20 | add_filter('pto/get_options', array($this, 'pto_get_options')); |
| 21 | add_action('admin_menu', array($this, 'cotto_submenu'), 999); |
| 22 | add_filter('rank_math/metabox/priority', array($this, 'rankmath_metaboxes_priority')); |
| 23 | add_filter('wpseo_metabox_prio', array($this, 'yoast_metaboxes_priority')); |
| 24 | add_filter('pll_get_post_types', array($this, 'polylang_get_post_types'), 10, 2); |
| 25 | add_action('elementor/documents/register_controls', array($this, 'elementor_register_controls')); |
| 26 | add_filter('wpgraphql_acf_supported_fields', array($this, 'wpgraphql_acf_supported_fields')); |
| 27 | add_filter('wpgraphql_acf_register_graphql_field', array($this, 'wpgraphql_acf_register_graphql_field'), 10, 4); |
| 28 | |
| 29 | } |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * pto_posts_orderby_ignore |
| 34 | * |
| 35 | * Fix Post Types Order which apply custom order to ACF Field Group Post Type |
| 36 | * https://wordpress.org/plugins/post-types-order/ |
| 37 | * |
| 38 | * @param $ignore |
| 39 | * @param $orderby |
| 40 | * @param $query |
| 41 | * |
| 42 | * @return bool|mixed |
| 43 | */ |
| 44 | function pto_posts_orderby_ignore($ignore, $orderby, $query){ |
| 45 | |
| 46 | if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group'){ |
| 47 | $ignore = true; |
| 48 | } |
| 49 | |
| 50 | return $ignore; |
| 51 | |
| 52 | } |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * pto_get_options |
| 57 | * |
| 58 | * Fix Post Types Order which apply a drag & drop UI on ACF Field Group UI |
| 59 | * https://wordpress.org/plugins/post-types-order/ |
| 60 | * |
| 61 | * @param $options |
| 62 | * |
| 63 | * @return array |
| 64 | */ |
| 65 | function pto_get_options($options){ |
| 66 | |
| 67 | $options['show_reorder_interfaces']['acf-field-group'] = 'hide'; |
| 68 | |
| 69 | return $options; |
| 70 | |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /** |
| 75 | * cotto_submenu |
| 76 | * |
| 77 | * Fix Category Order and Taxonomy Terms Order which adds an unnecessary submenu to 'Custom Fields' to order Field Group Categories |
| 78 | */ |
| 79 | function cotto_submenu(){ |
| 80 | remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group'); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
| 85 | * rankmath_metaboxes_priority |
| 86 | * |
| 87 | * Fix RankMath post metabox which is always above ACF metaboxes |
| 88 | * https://wordpress.org/plugins/seo-by-rank-math/ |
| 89 | * |
| 90 | * @return string |
| 91 | */ |
| 92 | function rankmath_metaboxes_priority(){ |
| 93 | return 'default'; |
| 94 | } |
| 95 | |
| 96 | |
| 97 | /** |
| 98 | * yoast_metaboxes_priority |
| 99 | * |
| 100 | * Fix YOAST post metabox which is always above ACF metaboxes |
| 101 | * https://wordpress.org/plugins/wordpress-seo/ |
| 102 | * |
| 103 | * @return string |
| 104 | */ |
| 105 | function yoast_metaboxes_priority(){ |
| 106 | return 'default'; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | /** |
| 111 | * polylang_get_post_types |
| 112 | * |
| 113 | * Enable Polylang translation for the form module |
| 114 | * https://polylang.pro/doc/filter-reference/ |
| 115 | * Since 0.8.3 |
| 116 | * |
| 117 | * @param $post_types |
| 118 | * @param $is_settings |
| 119 | * |
| 120 | * @return mixed |
| 121 | */ |
| 122 | function polylang_get_post_types($post_types, $is_settings){ |
| 123 | |
| 124 | if($is_settings){ |
| 125 | |
| 126 | unset($post_types['acfe-form']); |
| 127 | unset($post_types['acfe-template']); |
| 128 | |
| 129 | }else{ |
| 130 | |
| 131 | $post_types['acfe-form'] = 'acfe-form'; |
| 132 | $post_types['acfe-template'] = 'acfe-template'; |
| 133 | |
| 134 | } |
| 135 | |
| 136 | return $post_types; |
| 137 | |
| 138 | } |
| 139 | |
| 140 | |
| 141 | /** |
| 142 | * elementor_register_controls |
| 143 | * |
| 144 | * Fix Elementor listing all private ACF Extended Field Groups in Dynamic ACF Tags options list |
| 145 | * Since 0.8.8 |
| 146 | */ |
| 147 | function elementor_register_controls(){ |
| 148 | |
| 149 | // make sure we're on Elementor edit mode |
| 150 | if(acf_maybe_get_GET('action') !== 'elementor'){ |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | // hide reserved field groups in Dynamic Tags |
| 155 | add_filter('acf/load_field_groups', function($field_groups){ |
| 156 | |
| 157 | // Hidden Local Field Groups |
| 158 | $hidden = acfe_get_setting('reserved_field_groups', array()); |
| 159 | |
| 160 | foreach($field_groups as $i => $field_group){ |
| 161 | |
| 162 | if(!in_array($field_group['key'], $hidden)) continue; |
| 163 | |
| 164 | unset($field_groups[$i]); |
| 165 | |
| 166 | } |
| 167 | |
| 168 | $field_groups = array_values($field_groups); |
| 169 | |
| 170 | return $field_groups; |
| 171 | |
| 172 | }, 25); |
| 173 | |
| 174 | } |
| 175 | |
| 176 | |
| 177 | /** |
| 178 | * wpgraphql_acf_supported_fields |
| 179 | * |
| 180 | * @param $fields |
| 181 | * |
| 182 | * @since 0.8.8.2 (27/04/2021) |
| 183 | * |
| 184 | * @return mixed |
| 185 | */ |
| 186 | function wpgraphql_acf_supported_fields($fields){ |
| 187 | |
| 188 | $acfe_fields = array( |
| 189 | 'acfe_advanced_link', |
| 190 | 'acfe_code_editor', |
| 191 | 'acfe_column', |
| 192 | 'acfe_forms', |
| 193 | 'acfe_hidden', |
| 194 | 'acfe_post_statuses', |
| 195 | 'acfe_post_types', |
| 196 | 'acfe_slug', |
| 197 | 'acfe_taxonomies', |
| 198 | 'acfe_taxonomy_terms', |
| 199 | 'acfe_user_roles', |
| 200 | ); |
| 201 | |
| 202 | return array_merge($fields, $acfe_fields); |
| 203 | |
| 204 | } |
| 205 | |
| 206 | |
| 207 | /** |
| 208 | * wpgraphql_acf_register_graphql_field |
| 209 | * |
| 210 | * @param $field_config |
| 211 | * @param $type_name |
| 212 | * @param $field_name |
| 213 | * @param $config |
| 214 | * |
| 215 | * @since 0.8.8.4 (14/06/2021) |
| 216 | * |
| 217 | * @return mixed |
| 218 | */ |
| 219 | function wpgraphql_acf_register_graphql_field($field_config, $type_name, $field_name, $config){ |
| 220 | |
| 221 | $acf_field = isset($config['acf_field']) ? $config['acf_field'] : null; |
| 222 | $acf_type = isset($acf_field['type']) ? $acf_field['type'] : null; |
| 223 | |
| 224 | switch($acf_type){ |
| 225 | |
| 226 | case 'acfe_advanced_link': |
| 227 | case 'acfe_forms': |
| 228 | case 'acfe_post_statuses': |
| 229 | case 'acfe_post_types': |
| 230 | case 'acfe_taxonomies': |
| 231 | case 'acfe_taxonomy_terms': |
| 232 | case 'acfe_user_roles': { |
| 233 | $field_config['type'] = array('list_of' => 'String'); |
| 234 | break; |
| 235 | } |
| 236 | |
| 237 | case 'acfe_code_editor': |
| 238 | case 'acfe_column': |
| 239 | case 'acfe_hidden': |
| 240 | case 'acfe_slug': { |
| 241 | $field_config['type'] = 'String'; |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | } |
| 246 | |
| 247 | return $field_config; |
| 248 | |
| 249 | } |
| 250 | |
| 251 | } |
| 252 | |
| 253 | new acfe_third_party(); |
| 254 | |
| 255 | endif; |