get_endpoint_actions() : array(); if ( ! empty( $endpoint_actions ) ) { $actions = wp_parse_args( $endpoint_actions, $actions ); } return apply_filters( 'wpmudev_blc_hub_endpoints_actions', $actions, $this ); } /** * Formats the input into json response. * When $success = false the input array needs to contain following keys: * `code` with value string and default value '' * `message` with value string and default value a generic error response message and * `data` with mixed value and default value '' * * @param array $input An array that will be transformed to json. In case of error input array needs tocontain `code`, `message` and `data` indexes. * @param bool $success When true returns wp_send_json_success when false returns wp_send_json_error. * * @return void */ protected function output_formatted_response( array $input = array(), bool $success = true ) { if ( ! empty( $input ) ) { if ( $success ) { \wp_send_json_success( $input, 200 ); } else { $input['code'] = $input['code'] ? sanitize_text_field( $input['code'] ) : 'BLC_ERROR'; $input['message'] = $input['message'] ? \wp_kses_post( $input['message'] ) : \esc_html__( 'Something went wrong with this HTTP request', 'broken-link-checker' ); $input['data'] = $input['data'] ? $this->sanitize_array( $input['data'] ) : ''; \wp_send_json_error( new \WP_Error( $input['code'], $input['message'], $input['data'] ) ); } } } /** * Returns the endpoint's actions to be used by Dash plugin. * * @return array. */ protected function get_endpoint_actions() { $this->setup_action_vars(); if ( ! empty( $this->endpoint_action_name ) && ! empty( $this->endpoint_action_callback ) ) { return array( $this->endpoint_action_name => array( $this, $this->endpoint_action_callback ), ); } return array(); } /** * Sets up the action variables. */ abstract protected function setup_action_vars(); }