Code Duplication    Length = 25-26 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

@@ 923-948 (lines=26) @@
920
    }
921
922
923
    protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
924
    {
925
        $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : false;
926
927
        // loop thru venues
928
        if ($VNU_ID) {
929
            // clean status
930
            $venue_status = sanitize_key($venue_status);
931
            // grab status
932
            if (! empty($venue_status)) {
933
                $success = $this->_change_venue_status($VNU_ID, $venue_status);
934
            } else {
935
                $success = false;
936
                $msg = __(
937
                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
938
                    'event_espresso'
939
                );
940
                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
941
            }
942
        } else {
943
            $success = false;
944
            $msg = __(
945
                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
946
                'event_espresso'
947
            );
948
            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
949
        }
950
        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
951

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 1954-1978 (lines=25) @@
1951
     * @param  string $event_status
1952
     * @param bool    $redirect_after
1953
     */
1954
    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1955
    {
1956
        // determine the event id and set to array.
1957
        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1958
        // loop thru events
1959
        if ($EVT_ID) {
1960
            // clean status
1961
            $event_status = sanitize_key($event_status);
1962
            // grab status
1963
            if (! empty($event_status)) {
1964
                $success = $this->_change_event_status($EVT_ID, $event_status);
1965
            } else {
1966
                $success = false;
1967
                $msg = esc_html__(
1968
                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1969
                    'event_espresso'
1970
                );
1971
                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1972
            }
1973
        } else {
1974
            $success = false;
1975
            $msg = esc_html__(
1976
                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1977
                'event_espresso'
1978
            );
1979
            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1980
        }
1981
        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';