ay $headers * @param string $verb `GET` `POST` `PUT` `DELETE` `PATCH` * @param string $url full url with scheme * @param array $args argument sent to this function */ $headers = apply_filters( 'hustle_addon_mautic_api_request_headers', $headers, $verb, $url, $args ); $_args = array( 'method' => $verb, 'headers' => $headers, ); $request_data = $args; ksort( $request_data ); /** * Filter mautic request data to be used on sending api request * * @since 4.0.2 * * @param array $request_data * @param string $verb `GET` `POST` `PUT` `DELETE` `PATCH` * @param string $url full url with scheme */ $args = apply_filters( 'hustle_addon_mautic_api_request_data', $request_data, $verb, $url ); if ( 'GET' === $verb ) { $url .= ( '?' . http_build_query( $args ) ); } else { $_args['body'] = wp_json_encode( $args ); } /** * Filter mautic wp_remote_request args * * @since 4.0.2 * * @param array $_args */ $_args = apply_filters( 'hustle_addon_mautic_api_remote_request_args', $_args ); $res = wp_remote_request( $url, $_args ); // logging data. $utils = Hustle_Provider_Utils::get_instance(); $utils->last_url_request = $url; $utils->last_data_sent = $_args; $utils->last_data_received = $res; $wp_response = $res; remove_filter( 'http_headers_useragent', array( $this, 'filter_user_agent' ) ); if ( is_wp_error( $res ) || ! $res ) { throw new Exception( esc_html__( 'Failed to process request, make sure your API URL is correct and your server has internet connection.', 'hustle' ) ); } if ( isset( $res['response']['code'] ) ) { $status_code = $res['response']['code']; $msg = ''; if ( $status_code >= 400 ) { if ( isset( $res['response']['message'] ) ) { $msg = $res['response']['message']; } $body_json = wp_remote_retrieve_body( $res ); $res_json = json_decode( $body_json ); if ( ! is_null( $res_json ) && is_object( $res_json ) && isset( $res_json->error ) && isset( $res_json->error->message ) ) { $msg = $res_json->error->message; } if ( 404 === $status_code ) { /* translators: error message */ throw new Exception( sprintf( esc_html__( 'Failed to processing request : %s', 'hustle' ), esc_html( $msg ) ) ); } } } $body = wp_remote_retrieve_body( $res ); // probably silent mode. if ( ! empty( $body ) ) { $res = json_decode( $body ); // fallback to parse args when fail. if ( empty( $res ) ) { $res = wp_parse_args( $body, array() ); // json-ify to make same format as json response (which is object not array). $res = wp_json_encode( $res ); $res = json_decode( $res ); } } $response = $res; /** * Filter mautic api response returned to addon * * @since 4.0.2 * * @param mixed $response original wp remote request response or decoded body if available * @param string $body original content of http response's body * @param array|WP_Error $wp_response original wp remote request response */ $res = apply_filters( 'hustle_addon_mautic_api_response', $response, $body, $wp_response ); return $res; } /** * Sends rest GET request * * @param string $action Action. * @param array $args Args. * @return array|mixed|object|WP_Error */ private function get( $action, $args = array() ) { return $this->request( $action, 'GET', $args ); } /** * Sends rest POST request * * @param string $action Action. * @param array $args Args. * @return array|mixed|object|WP_Error */ private function post( $action, $args = array() ) { return $this->request( $action, 'POST', $args ); } /** * Sends rest PUT request * * @param string $action Action. * @param array $args Args. * @return array|mixed|object|WP_Error */ private function patch( $action, $args = array() ) { return $this->request( $action, 'PATCH', $args ); } /** * Retrieve the list of segments from Mautic installation. * * @param int $offset Offset. **/ public function get_segments( $offset = 0 ) { try { $segments = $this->get( 'segments' ); if ( ! empty( $segments ) && isset( $segments->lists ) ) { return $segments; } } catch ( Exception $e ) { return false; } return false; } /** * Add contact to Mautic installation. * * @param (associative_array) $data An array of contact details to add. * @return Returns contact ID on success or WP_Error. **/ public function add_contact( $data ) { $err = new WP_Error(); try { $res = $this->post( 'contacts/new', $data ); if ( $res && ! empty( $res->contact ) ) { $contact = $res->contact; return $contact->id; } else { $err->add( 'subscribe_error', __( 'Something went wrong. Please try again', 'hustle' ) ); } } catch ( Exception $e ) { $error = $e->getMessage(); $err = new WP_Error(); $err->add( 'subscribe_error', $error ); } return $err; } /** * Add contact to Mautic installation. * * @param string $id ID. * @param array $data An array of contact details to add. * @return Returns contact ID on success or WP_Error. **/ public function update_contact( $id, $data ) { $err = new WP_Error(); try { $res = $this->patch( 'contacts/' . $id . '/edit', $data ); if ( $res && ! empty( $res->contact ) ) { $contact = $res->contact; return $contact->id; } else { $err->add( 'subscribe_error', __( 'Something went wrong. Please try again', 'hustle' ) ); } } catch ( Exception $e ) { $error = $e->getMessage(); $err = new WP_Error(); $err->add( 'subscribe_error', $error ); } return $err; } /** * Check if an email is already used. * * @param (string) $email Email. * @return Returns true if the given email already in use otherwise false. **/ public function email_exist( $email ) { $err = new WP_Error(); try { $args = array( 'search' => $email, 'limit' => 1000, ); $res = $this->get( 'contacts', $args ); $contact_id = ''; if ( $res && ! empty( $res->contacts ) ) { $contact_id = wp_list_pluck( (array) $res->contacts, 'id' ); } return ! empty( $contact_id ) ? key( $contact_id ) : false; } catch ( Exception $e ) { $err->add( 'server_error', $e->getMessage() ); } return $err; } /** * Add contact to segment list. * * @param (int) $segment_id Segment ID. * @param (int) $contact_id Contact ID. **/ public function add_contact_to_segment( $segment_id, $contact_id ) { $err = new WP_Error(); try { $add = $this->post( 'segments/' . $segment_id . '/contact/' . $contact_id . '/add' ); return $add; } catch ( Exception $e ) { $err->add( 'subscribe_error', $e->getMessage() ); } return $err; } /** * Delete subscriber from the list * * @param string $list_id List ID. * @param string $email Email. * * @return bool */ public function delete_email( $list_id, $email ) { $contact_id = $this->email_exist( $email ); if ( false === $contact_id || is_wp_error( $contact_id ) ) { return false; } $res = $this->post( 'segments/' . $list_id . '/contact/' . $contact_id . '/remove' ); return ! is_wp_error( $res ); } /** * Get the list of available contact custom fields. **/ public function get_custom_fields() { $fields = $this->get( 'contacts/list/fields' ); return $fields; } /** * Add custom contact field. * * @param (array) $field Field. **/ public function add_custom_field( $field ) { $res = $this->post( 'fields/contact/new', $field ); return ! empty( $res ) && ! empty( $res->field ); } } endif; stories – Super Digital Workshop https://superdigitalworkshop.com Thu, 21 Apr 2022 01:56:40 +0000 en-US hourly 1 https://wordpress.org/?v=7.1.3 https://superdigitalworkshop.com/wp-content/uploads/2022/04/cropped-sdw-ico-1-32x32.png stories – Super Digital Workshop https://superdigitalworkshop.com 32 32 205977178 Penny Lane https://superdigitalworkshop.com/blog/280/ Sun, 15 Jan 2017 16:55:59 +0000 https://superdigitalworkshop.com/blog/2017/01/15/280/ Sisters Lily and Hopie Stockman are in the business of teaching others how to work with their hands. Aside from creating their own eye-catching, geometric printed textiles through their label Block Shop, the Stockmans also host a series of printing workshops at an enviable offsite studio and home in Joshua Tree, California. In a serene, well-appointed setting, visitors come to learn about the art of block printing, a craft that these sisters fell in love with back in 2010 after Lily met a master dyer in Jaipur while she was in art school there studying painting.

She worked with the craftsman, Vijendra (Viju) Chhipa, on several pieces she then sent over to her sister who was back home. Hopie was so moved by the paintings that she traveled to meet Viju herself several months later and from there, they formed a textile business that would see all of its materials printed by Viju and his fellow local artisans.

Wreaths are usually associated with Christmas and might make people think of overly craft-y, slightly tacky creations. But the true prime time for front door wreath hanging is arguably the fall. A welcoming garland ushers in the cozy sentiments of the season, and the creative varieties are seemingly endless.At home with photographer Penny Lane in The Design Files

]]>
4152