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

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