Code Duplication    Length = 5-18 lines in 7 locations

core/db_classes/EE_Base_Class.class.php 1 location

@@ 1210-1224 (lines=15) @@
1207
    public function get_DateTime_object($field_name)
1208
    {
1209
        $field_settings = $this->get_model()->field_settings_for($field_name);
1210
        if (! $field_settings instanceof EE_Datetime_Field) {
1211
            EE_Error::add_error(
1212
                sprintf(
1213
                    esc_html__(
1214
                        'The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.',
1215
                        'event_espresso'
1216
                    ),
1217
                    $field_name
1218
                ),
1219
                __FILE__,
1220
                __FUNCTION__,
1221
                __LINE__
1222
            );
1223
            return false;
1224
        }
1225
        return isset($this->_fields[ $field_name ]) && $this->_fields[ $field_name ] instanceof DateTime
1226
            ? clone $this->_fields[ $field_name ]
1227
            : null;

caffeinated/modules/recaptcha_invisible/InvisibleRecaptcha.php 1 location

@@ 142-159 (lines=18) @@
139
            return $previous_recaptcha_response[ $grecaptcha_response ];
140
        }
141
        // still here but no g-recaptcha-response ? - verification failed
142
        if (! $grecaptcha_response) {
143
            EE_Error::add_error(
144
                sprintf(
145
                    /* translators: 1: missing parameter */
146
                    esc_html__(
147
                        // @codingStandardsIgnoreStart
148
                        'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.',
149
                        // @codingStandardsIgnoreEnd
150
                        'event_espresso'
151
                    ),
152
                    'g-recaptcha-response'
153
                ),
154
                __FILE__,
155
                __FUNCTION__,
156
                __LINE__
157
            );
158
            return false;
159
        }
160
        // will update to true if everything passes
161
        $previous_recaptcha_response[ $grecaptcha_response ] = false;
162
        $response                                            = wp_safe_remote_post(

core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 2 locations

@@ 1515-1519 (lines=5) @@
1512
        // if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1513
        if (strpos($guid, $wp_upload_dir['url']) === false) {
1514
            // image is located remotely. download it and place it in the uploads directory
1515
            if (! is_readable($guid)) {
1516
                $migration_stage->add_error(sprintf(esc_html__(
1517
                    "Could not create image attachment from non-existent file: %s",
1518
                    "event_espresso"
1519
                ), $guid));
1520
                return 0;
1521
            }
1522
            $contents = file_get_contents($guid);
@@ 1523-1527 (lines=5) @@
1520
                return 0;
1521
            }
1522
            $contents = file_get_contents($guid);
1523
            if ($contents === false) {
1524
                $migration_stage->add_error(sprintf(esc_html__(
1525
                    "Could not read image at %s, and therefore couldnt create an attachment post for it.",
1526
                    "event_espresso"
1527
                ), $guid));
1528
                return false;
1529
            }
1530
            $local_filepath = $wp_upload_dir['path'] . '/' . basename($guid);

modules/single_page_checkout/reg_steps/attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 1 location

@@ 1008-1019 (lines=12) @@
1005
        // grab the saved registrations from the transaction
1006
        foreach ($registrations as $registration) {
1007
            // verify EE_Registration object
1008
            if (! $registration instanceof EE_Registration) {
1009
                EE_Error::add_error(
1010
                    esc_html__(
1011
                        'An invalid Registration object was discovered when attempting to process your registration information.',
1012
                        'event_espresso'
1013
                    ),
1014
                    __FILE__,
1015
                    __FUNCTION__,
1016
                    __LINE__
1017
                );
1018
                return false;
1019
            }
1020
            /** @var string $reg_url_link */
1021
            $reg_url_link = $registration->reg_url_link();
1022
            // reg_url_link exists ?

admin_pages/registrations/Registrations_Admin_Page.core.php 1 location

@@ 2715-2729 (lines=15) @@
2712
        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2713
        // registrations on the transaction that are NOT trashed.
2714
        $TXN = $REG->get_first_related('Transaction');
2715
        if (! $TXN instanceof EE_Transaction) {
2716
            EE_Error::add_error(
2717
                sprintf(
2718
                    esc_html__(
2719
                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2720
                        'event_espresso'
2721
                    ),
2722
                    $REG->id()
2723
                ),
2724
                __FILE__,
2725
                __FUNCTION__,
2726
                __LINE__
2727
            );
2728
            return false;
2729
        }
2730
        $REGS = $TXN->get_many_related('Registration');
2731
        $all_trashed = true;
2732
        foreach ($REGS as $registration) {

core/admin/EE_Admin_Page.core.php 1 location

@@ 1420-1435 (lines=16) @@
1417
                                                             . $tour
1418
                                                             . '.class.php' : $file_path;
1419
                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1420
                    if (! is_readable($file_path)) {
1421
                        EE_Error::add_error(
1422
                            sprintf(
1423
                                esc_html__(
1424
                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1425
                                    'event_espresso'
1426
                                ),
1427
                                $file_path,
1428
                                $tour
1429
                            ),
1430
                            __FILE__,
1431
                            __FUNCTION__,
1432
                            __LINE__
1433
                        );
1434
                        return;
1435
                    }
1436
                    require_once $file_path;
1437
                    if (! class_exists($tour)) {
1438
                        $error_msg = [];