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

@@ 1938-1962 (lines=25) @@
1935
     * @param  string $event_status
1936
     * @param bool    $redirect_after
1937
     */
1938
    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1939
    {
1940
        // determine the event id and set to array.
1941
        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1942
        // loop thru events
1943
        if ($EVT_ID) {
1944
            // clean status
1945
            $event_status = sanitize_key($event_status);
1946
            // grab status
1947
            if (! empty($event_status)) {
1948
                $success = $this->_change_event_status($EVT_ID, $event_status);
1949
            } else {
1950
                $success = false;
1951
                $msg = esc_html__(
1952
                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1953
                    'event_espresso'
1954
                );
1955
                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1956
            }
1957
        } else {
1958
            $success = false;
1959
            $msg = esc_html__(
1960
                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1961
                'event_espresso'
1962
            );
1963
            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1964
        }
1965
        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';