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

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