deprecated.php
| 1 | <?php |
| 2 | |
| 3 | if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 | |
| 5 | if( ! class_exists('acf_deprecated') ) : |
| 6 | |
| 7 | class acf_deprecated { |
| 8 | |
| 9 | /* |
| 10 | * __construct |
| 11 | * |
| 12 | * This function will setup the class functionality |
| 13 | * |
| 14 | * @type function |
| 15 | * @date 30/1/17 |
| 16 | * @since 5.5.6 |
| 17 | * |
| 18 | * @param n/a |
| 19 | * @return n/a |
| 20 | */ |
| 21 | |
| 22 | function __construct() { |
| 23 | |
| 24 | // settings |
| 25 | add_filter('acf/settings/show_admin', array($this, 'acf_settings_show_admin'), 5, 1); // 5.0.0 |
| 26 | add_filter('acf/settings/l10n_textdomain', array($this, 'acf_settings_l10n_textdomain'), 5, 1); // 5.3.3 |
| 27 | add_filter('acf/settings/l10n_field', array($this, 'acf_settings_l10n_field'), 5, 1); // 5.3.3 |
| 28 | add_filter('acf/settings/l10n_field_group', array($this, 'acf_settings_l10n_field'), 5, 1); // 5.3.3 |
| 29 | add_filter('acf/settings/url', array($this, 'acf_settings_url'), 5, 1); // 5.6.8 |
| 30 | add_filter('acf/validate_setting', array($this, 'acf_validate_setting'), 5, 1); // 5.6.8 |
| 31 | |
| 32 | |
| 33 | // filters |
| 34 | add_filter('acf/validate_field', array($this, 'acf_validate_field'), 10, 1); // 5.5.6 |
| 35 | add_filter('acf/validate_field_group', array($this, 'acf_validate_field_group'), 10, 1); // 5.5.6 |
| 36 | add_filter('acf/validate_post_id', array($this, 'acf_validate_post_id'), 10, 2); // 5.5.6 |
| 37 | |
| 38 | } |
| 39 | |
| 40 | |
| 41 | /* |
| 42 | * acf_settings_show_admin |
| 43 | * |
| 44 | * This function will add compatibility for previously named hooks |
| 45 | * |
| 46 | * @type function |
| 47 | * @date 19/05/2014 |
| 48 | * @since 5.0.0 |
| 49 | * |
| 50 | * @param n/a |
| 51 | * @return n/a |
| 52 | */ |
| 53 | |
| 54 | function acf_settings_show_admin( $setting ) { |
| 55 | |
| 56 | // 5.0.0 - removed ACF_LITE |
| 57 | return ( defined('ACF_LITE') && ACF_LITE ) ? false : $setting; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | |
| 62 | /* |
| 63 | * acf_settings_l10n_textdomain |
| 64 | * |
| 65 | * This function will add compatibility for previously named hooks |
| 66 | * |
| 67 | * @type function |
| 68 | * @date 19/05/2014 |
| 69 | * @since 5.0.0 |
| 70 | * |
| 71 | * @param n/a |
| 72 | * @return n/a |
| 73 | */ |
| 74 | |
| 75 | function acf_settings_l10n_textdomain( $setting ) { |
| 76 | |
| 77 | // 5.3.3 - changed filter name |
| 78 | return acf_get_setting( 'export_textdomain', $setting ); |
| 79 | |
| 80 | } |
| 81 | |
| 82 | |
| 83 | /* |
| 84 | * acf_settings_l10n_field |
| 85 | * |
| 86 | * This function will add compatibility for previously named hooks |
| 87 | * |
| 88 | * @type function |
| 89 | * @date 19/05/2014 |
| 90 | * @since 5.0.0 |
| 91 | * |
| 92 | * @param n/a |
| 93 | * @return n/a |
| 94 | */ |
| 95 | |
| 96 | function acf_settings_l10n_field( $setting ) { |
| 97 | |
| 98 | // 5.3.3 - changed filter name |
| 99 | return acf_get_setting( 'export_translate', $setting ); |
| 100 | |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /** |
| 105 | * acf_settings_url |
| 106 | * |
| 107 | * This function will add compatibility for previously named hooks |
| 108 | * |
| 109 | * @date 12/12/17 |
| 110 | * @since 5.6.8 |
| 111 | * |
| 112 | * @param n/a |
| 113 | * @return n/a |
| 114 | */ |
| 115 | |
| 116 | function acf_settings_url( $value ) { |
| 117 | return apply_filters( "acf/settings/dir", $value ); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * acf_validate_setting |
| 122 | * |
| 123 | * description |
| 124 | * |
| 125 | * @date 2/2/18 |
| 126 | * @since 5.6.5 |
| 127 | * |
| 128 | * @param type $var Description. Default. |
| 129 | * @return type Description. |
| 130 | */ |
| 131 | |
| 132 | function acf_validate_setting( $name ) { |
| 133 | |
| 134 | // vars |
| 135 | $changed = array( |
| 136 | 'dir' => 'url' // 5.6.8 |
| 137 | ); |
| 138 | |
| 139 | // check |
| 140 | if( isset($changed[ $name ]) ) { |
| 141 | return $changed[ $name ]; |
| 142 | } |
| 143 | |
| 144 | //return |
| 145 | return $name; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * acf_validate_field |
| 151 | * |
| 152 | * This function will add compatibility for previously named hooks |
| 153 | * |
| 154 | * @type function |
| 155 | * @date 30/1/17 |
| 156 | * @since 5.5.6 |
| 157 | * |
| 158 | * @param $post_id (int) |
| 159 | * @return $post_id (int) |
| 160 | */ |
| 161 | |
| 162 | function acf_validate_field( $field ) { |
| 163 | |
| 164 | // 5.5.6 - changed filter name |
| 165 | $field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field ); |
| 166 | $field = apply_filters( "acf/get_valid_field", $field ); |
| 167 | |
| 168 | |
| 169 | // return |
| 170 | return $field; |
| 171 | |
| 172 | } |
| 173 | |
| 174 | |
| 175 | /* |
| 176 | * acf_validate_field_group |
| 177 | * |
| 178 | * This function will add compatibility for previously named hooks |
| 179 | * |
| 180 | * @type function |
| 181 | * @date 30/1/17 |
| 182 | * @since 5.5.6 |
| 183 | * |
| 184 | * @param $post_id (int) |
| 185 | * @return $post_id (int) |
| 186 | */ |
| 187 | |
| 188 | function acf_validate_field_group( $field_group ) { |
| 189 | |
| 190 | // 5.5.6 - changed filter name |
| 191 | $field_group = apply_filters('acf/get_valid_field_group', $field_group); |
| 192 | |
| 193 | |
| 194 | // return |
| 195 | return $field_group; |
| 196 | |
| 197 | } |
| 198 | |
| 199 | |
| 200 | /* |
| 201 | * acf_validate_post_id |
| 202 | * |
| 203 | * This function will add compatibility for previously named hooks |
| 204 | * |
| 205 | * @type function |
| 206 | * @date 6/2/17 |
| 207 | * @since 5.5.6 |
| 208 | * |
| 209 | * @param $post_id (int) |
| 210 | * @return $post_id (int) |
| 211 | */ |
| 212 | |
| 213 | function acf_validate_post_id( $post_id, $_post_id ) { |
| 214 | |
| 215 | // 5.5.6 - changed filter name |
| 216 | $post_id = apply_filters('acf/get_valid_post_id', $post_id, $_post_id); |
| 217 | |
| 218 | |
| 219 | // return |
| 220 | return $post_id; |
| 221 | |
| 222 | } |
| 223 | |
| 224 | } |
| 225 | |
| 226 | |
| 227 | // initialize |
| 228 | acf()->deprecated = new acf_deprecated(); |
| 229 | |
| 230 | endif; // class_exists check |
| 231 | |
| 232 | ?> |