Helpers
11 months ago
Integrations
1 week ago
RestApi
2 weeks ago
abilities
2 weeks ago
abstracts
2 weeks ago
admin
2 weeks ago
blocks
1 year ago
elementor
2 years ago
export
2 months ago
fields
2 weeks ago
interfaces
8 years ago
libraries
2 years ago
log-handlers
1 year ago
shortcodes
2 weeks ago
stats
5 months ago
templates
3 months ago
traits
2 weeks ago
class-everest-forms.php
1 week ago
class-evf-addon-upsell.php
2 weeks ago
class-evf-ajax.php
2 weeks ago
class-evf-autoloader.php
7 years ago
class-evf-background-process-import-entries.php
1 year ago
class-evf-background-updater.php
7 years ago
class-evf-cache-helper.php
2 months ago
class-evf-cron.php
2 years ago
class-evf-deprecated-action-hooks.php
6 years ago
class-evf-deprecated-filter-hooks.php
5 years ago
class-evf-email-entries-report.php
3 months ago
class-evf-emails.php
2 weeks ago
class-evf-fields.php
2 weeks ago
class-evf-form-handler.php
2 weeks ago
class-evf-form-task.php
2 weeks ago
class-evf-forms-features.php
2 weeks ago
class-evf-frontend-scripts.php
2 weeks ago
class-evf-install.php
2 months ago
class-evf-integrations.php
3 months ago
class-evf-log-levels.php
8 years ago
class-evf-logger.php
5 years ago
class-evf-post-types.php
1 year ago
class-evf-privacy.php
6 years ago
class-evf-report-cron.php
2 months ago
class-evf-reporting.php
2 months ago
class-evf-session-handler.php
7 years ago
class-evf-shortcodes.php
1 year ago
class-evf-smart-tags.php
9 months ago
class-evf-template-loader.php
1 year ago
class-evf-validation.php
6 years ago
evf-conditional-functions.php
6 years ago
evf-core-functions.php
2 weeks ago
evf-deprecated-functions.php
6 years ago
evf-entry-functions.php
4 months ago
evf-formatting-functions.php
4 years ago
evf-notice-functions.php
4 years ago
evf-template-functions.php
4 years ago
evf-template-hooks.php
7 years ago
evf-update-functions.php
5 years ago
evf-deprecated-functions.php
203 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Deprecated Functions |
| 4 | * |
| 5 | * Where functions come to die. |
| 6 | * |
| 7 | * @package EverestForms\Functions |
| 8 | * @version 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | /** |
| 14 | * Runs a deprecated action with notice only if used. |
| 15 | * |
| 16 | * @since 1.0.0 |
| 17 | * @param string $tag The name of the action hook. |
| 18 | * @param array $args Array of additional function arguments to be passed to do_action(). |
| 19 | * @param string $version The version of EverestForms that deprecated the hook. |
| 20 | * @param string $replacement The hook that should have been used. |
| 21 | * @param string $message A message regarding the change. |
| 22 | */ |
| 23 | function evf_do_deprecated_action( $tag, $args, $version, $replacement = null, $message = null ) { |
| 24 | if ( ! has_action( $tag ) ) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | evf_deprecated_hook( $tag, $version, $replacement, $message ); |
| 29 | do_action_ref_array( $tag, $args ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Wrapper for deprecated functions so we can apply some extra logic. |
| 34 | * |
| 35 | * @since 1.0.0 |
| 36 | * @param string $function Function used. |
| 37 | * @param string $version Version the message was added in. |
| 38 | * @param string $replacement Replacement for the called function. |
| 39 | */ |
| 40 | function evf_deprecated_function( $function, $version, $replacement = null ) { |
| 41 | // @codingStandardsIgnoreStart |
| 42 | if ( is_ajax() ) { |
| 43 | do_action( 'deprecated_function_run', $function, $replacement, $version ); |
| 44 | $log_string = "The {$function} function is deprecated since version {$version}."; |
| 45 | $log_string .= $replacement ? " Replace with {$replacement}." : ''; |
| 46 | error_log( $log_string ); |
| 47 | } else { |
| 48 | _deprecated_function( $function, $version, $replacement ); |
| 49 | } |
| 50 | // @codingStandardsIgnoreEnd |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Wrapper for deprecated hook so we can apply some extra logic. |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | * @param string $hook The hook that was used. |
| 58 | * @param string $version The version of WordPress that deprecated the hook. |
| 59 | * @param string $replacement The hook that should have been used. |
| 60 | * @param string $message A message regarding the change. |
| 61 | */ |
| 62 | function evf_deprecated_hook( $hook, $version, $replacement = null, $message = null ) { |
| 63 | // @codingStandardsIgnoreStart |
| 64 | if ( is_ajax() ) { |
| 65 | do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); |
| 66 | |
| 67 | $message = empty( $message ) ? '' : ' ' . $message; |
| 68 | $log_string = "{$hook} is deprecated since version {$version}"; |
| 69 | $log_string .= $replacement ? "! Use {$replacement} instead." : ' with no alternative available.'; |
| 70 | |
| 71 | error_log( $log_string . $message ); |
| 72 | } else { |
| 73 | _deprecated_hook( $hook, $version, $replacement, $message ); |
| 74 | } |
| 75 | // @codingStandardsIgnoreEnd |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * When catching an exception, this allows us to log it if unexpected. |
| 80 | * |
| 81 | * @since 1.0.0 |
| 82 | * @param Exception $exception_object The exception object. |
| 83 | * @param string $function The function which threw exception. |
| 84 | * @param array $args The args passed to the function. |
| 85 | */ |
| 86 | function evf_caught_exception( $exception_object, $function = '', $args = array() ) { |
| 87 | // @codingStandardsIgnoreStart |
| 88 | $message = $exception_object->getMessage(); |
| 89 | $message .= '. Args: ' . print_r( $args, true ) . '.'; |
| 90 | |
| 91 | do_action( 'everest_forms_caught_exception', $exception_object, $function, $args ); |
| 92 | error_log( "Exception caught in {$function}. {$message}." ); |
| 93 | // @codingStandardsIgnoreEnd |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Wrapper for evf_doing_it_wrong. |
| 98 | * |
| 99 | * @since 1.0.0 |
| 100 | * @param string $function Function used. |
| 101 | * @param string $message Message to log. |
| 102 | * @param string $version Version the message was added in. |
| 103 | */ |
| 104 | function evf_doing_it_wrong( $function, $message, $version ) { |
| 105 | // @codingStandardsIgnoreStart |
| 106 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
| 107 | |
| 108 | if ( is_ajax() ) { |
| 109 | do_action( 'doing_it_wrong_run', $function, $message, $version ); |
| 110 | error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
| 111 | } else { |
| 112 | _doing_it_wrong( $function, $message, $version ); |
| 113 | } |
| 114 | // @codingStandardsIgnoreEnd |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Wrapper for deprecated arguments so we can apply some extra logic. |
| 119 | * |
| 120 | * @since 1.0.0 |
| 121 | * @param string $argument Argument used. |
| 122 | * @param string $version Version the message was added in. |
| 123 | * @param string $message A message regarding the change. |
| 124 | */ |
| 125 | function evf_deprecated_argument( $argument, $version, $message = null ) { |
| 126 | // @codingStandardsIgnoreStart |
| 127 | if ( is_ajax() ) { |
| 128 | do_action( 'deprecated_argument_run', $argument, $message, $version ); |
| 129 | error_log( "The {$argument} argument is deprecated since version {$version}. {$message}" ); |
| 130 | } else { |
| 131 | _deprecated_argument( $argument, $version, $message ); |
| 132 | } |
| 133 | // @codingStandardsIgnoreEnd |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * @deprecated 1.1.6 |
| 138 | */ |
| 139 | function evf_sender_name() { |
| 140 | evf_deprecated_function( 'evf_sender_name', '1.1.6' ); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * @deprecated 1.1.6 |
| 145 | */ |
| 146 | function evf_sender_address() { |
| 147 | evf_deprecated_function( 'evf_sender_address', '1.1.6' ); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @deprecated 1.2.0 |
| 152 | */ |
| 153 | function get_form_data_by_meta_key( $form_id, $meta_key ) { |
| 154 | evf_deprecated_function( 'get_form_data_by_meta_key', '1.2.0', 'evf_get_form_data_by_meta_key' ); |
| 155 | return evf_get_form_data_by_meta_key( $form_id, $meta_key ); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * @deprecated 1.2.0 |
| 160 | */ |
| 161 | function evf_query_string_form_fields( $values = null, $exclude = array(), $current_key = '', $return = false ) { |
| 162 | evf_deprecated_function( 'evf_sender_address', '1.2.0' ); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * @deprecated 1.2.0 |
| 167 | */ |
| 168 | function everest_forms_sanitize_textarea_field( $string ) { |
| 169 | evf_deprecated_function( 'everest_forms_sanitize_textarea_field', '1.2.0', 'evf_sanitize_textarea_field' ); |
| 170 | return evf_sanitize_textarea_field( $string ); |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * @deprecated 1.3.0 |
| 175 | */ |
| 176 | function evf_get_us_states() { |
| 177 | evf_deprecated_function( 'evf_get_us_states', '1.3.0' ); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * @deprecated 1.3.0 |
| 182 | */ |
| 183 | function get_all_email_fields_by_form_id( $form_id ) { |
| 184 | evf_deprecated_function( 'get_all_email_fields_by_form_id', '1.3.0', 'evf_get_all_email_fields_by_form_id' ); |
| 185 | return evf_get_all_email_fields_by_form_id( $form_id ); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @deprecated 1.3.0 |
| 190 | */ |
| 191 | function get_all_form_fields_by_form_id( $form_id ) { |
| 192 | evf_deprecated_function( 'get_all_form_fields_by_form_id', '1.3.0', 'evf_get_all_form_fields_by_form_id' ); |
| 193 | return evf_get_all_form_fields_by_form_id( $form_id ); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @deprecated 1.5.7 |
| 198 | */ |
| 199 | function evf_has_date_field( $form_id ) { |
| 200 | evf_deprecated_function( 'evf_has_date_field', '1.5.7', 'evf_is_field_exists' ); |
| 201 | return evf_is_field_exists( $form_id, 'date-time' ); |
| 202 | } |
| 203 |