session->get( 'wc_notices', array() ); if ( ! empty( $notices['error'] ) ) { $return = false; foreach ( $notices['error'] as $key => $error ) { $return = $this->add_error( $return, html_entity_decode( $error ) ); } wc_clear_notices(); return $return; } else { return false; } } /** * @param mixed|WP_Error $return * * @param string $message * @param string $code * @param string $data * * @return WP_Error */ public function add_error( $return, $message = '', $code = 'appmaker_wc_error', $data = '' ) { $message = strip_tags( $message ); $message = html_entity_decode( $message ); if ( is_wp_error( $return ) ) { $return->add( $code, $message, $data ); } else { $return = new WP_Error( $code, $message, $data ); } return $return; } /** * @param string $url * * @return string */ public function ensure_absolute_link( $url ) { if ( ! preg_match( '~^(?:f|ht)tps?://~i', $url ) ) { $url = get_site_url( null, $url ); } return $url; } /** * @param $function * @param array $params * * @return string */ public function return_data( $function, $params = array() ) { $return = ''; ob_start(); call_user_func_array( $function, $params ); $return = ob_get_clean(); return $return; } }