$css_scheme['caption'] => 'color: {{VALUE}}', ), ), 25 ); $this->_add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'caption_typography', 'selector' => '{{WRAPPER}} ' . $css_scheme['caption'], 'global' => array( 'default' => Global_Typography::TYPOGRAPHY_TEXT, ), ), 50 ); $this->_add_responsive_control( 'caption_padding', array( 'label' => __( 'Padding', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['caption'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 100 ); $this->_add_responsive_control( 'caption_margin', array( 'label' => __( 'Margin', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['caption'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 50 ); $this->_end_controls_section(); /** * Meta Style Section */ $this->_start_controls_section( 'section_meta_style', array( 'label' => esc_html__( 'Meta', 'jet-elements' ), 'tab' => Controls_Manager::TAB_STYLE, 'show_label' => false, ) ); $this->_add_responsive_control( 'meta_alignment', array( 'label' => esc_html__( 'Alignment', 'jet-elements' ), 'type' => Controls_Manager::CHOOSE, 'default' => 'center', 'options' => array( 'flex-start' => array( 'title' => esc_html__( 'Start', 'jet-elements' ), 'icon' => ! is_rtl() ? 'eicon-h-align-left' : 'eicon-h-align-right', ), 'center' => array( 'title' => esc_html__( 'Center', 'jet-elements' ), 'icon' => 'eicon-h-align-center', ), 'flex-end' => array( 'title' => esc_html__( 'End', 'jet-elements' ), 'icon' => ! is_rtl() ? 'eicon-h-align-right' : 'eicon-h-align-left', ), ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta'] => 'align-self: {{VALUE}};', ), ), 25 ); $this->_add_control( 'comments_icon', array( 'label' => esc_html__( 'Comments Icon', 'jet-elements' ), 'type' => Controls_Manager::ICON, 'label_block' => true, 'file' => '', 'default' => 'fa fa-comment', ), 50 ); $this->_add_control( 'likes_icon', array( 'label' => esc_html__( 'Likes Icon', 'jet-elements' ), 'type' => Controls_Manager::ICON, 'label_block' => true, 'file' => '', 'default' => 'fa fa-heart', ), 50 ); $this->_add_control( 'meta_icon_color', array( 'label' => esc_html__( 'Icon Color', 'jet-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta_icon'] => 'color: {{VALUE}}', ), ), 25 ); $this->_add_responsive_control( 'meta_icon_size', array( 'label' => esc_html__( 'Icon Size', 'jet-elements' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px', 'em', 'rem', 'custom' ), 'range' => array( 'px' => array( 'min' => 1, 'max' => 100, ), ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta_icon'] . ' i' => 'font-size: {{SIZE}}{{UNIT}}', ), ), 25 ); $this->_add_control( 'meta_label_color', array( 'label' => esc_html__( 'Text Color', 'jet-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta_label'] => 'color: {{VALUE}}', ), ), 25 ); $this->_add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'meta_label_typography', 'selector' => '{{WRAPPER}} ' . $css_scheme['meta_label'], 'global' => array( 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, ), ), 50 ); $this->_add_group_control( Group_Control_Background::get_type(), array( 'name' => 'meta_background', 'selector' => '{{WRAPPER}} ' . $css_scheme['meta'], ), 100 ); $this->_add_responsive_control( 'meta_padding', array( 'label' => __( 'Padding', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta'] => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 100 ); $this->_add_responsive_control( 'meta_margin', array( 'label' => __( 'Margin', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 50 ); $this->_add_responsive_control( 'meta_item_margin', array( 'label' => __( 'Item Margin', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta_item'] => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 50 ); $this->_add_group_control( Group_Control_Border::get_type(), array( 'name' => 'meta_border', 'label' => esc_html__( 'Border', 'jet-elements' ), 'placeholder' => '1px', 'default' => '1px', 'selector' => '{{WRAPPER}} ' . $css_scheme['meta'], ), 100 ); $this->_add_responsive_control( 'meta_radius', array( 'label' => __( 'Border Radius', 'jet-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%', 'custom' ), 'selectors' => array( '{{WRAPPER}} ' . $css_scheme['meta'] => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ), 100 ); $this->_add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'meta_shadow', 'selector' => '{{WRAPPER}} ' . $css_scheme['meta'], ), 100 ); $this->_end_controls_section(); } protected function render() { $this->_context = 'render'; $this->_open_wrap(); include $this->_get_global_template( 'index' ); $this->_close_wrap(); } /** * Render gallery html. * * @return void */ public function render_gallery() { $settings = $this->get_settings_for_display(); if ( 'hashtag' === $settings['endpoint'] ) { if ( empty( $settings['hashtag'] ) ) { $this->print_notice( esc_html__( 'Please, enter #hashtag.', 'jet-elements' ) ); return; } if ( ! empty( $settings['use_insta_graph_api'] ) ) { $business_account_config = $this->get_business_account_config(); if ( empty( $business_account_config['token'] || empty( $business_account_config['user_id'] ) ) ) { $this->print_notice( esc_html__( 'Please, enter Business Access Token and User ID.', 'jet-elements' ) ); return; } } } if ( 'self' === $settings['endpoint'] && ! $this->get_access_token() ) { $this->print_notice( esc_html__( 'Please, enter Access Token.', 'jet-elements' ) ); return; } $html = ''; $col_class = ''; // Endpoint. $endpoint = $this->sanitize_endpoint(); switch ( $settings['cache_timeout'] ) { case 'none': $cache_timeout = 1; break; case 'minute': $cache_timeout = MINUTE_IN_SECONDS; break; case 'hour': $cache_timeout = HOUR_IN_SECONDS; break; case 'day': $cache_timeout = DAY_IN_SECONDS; break; case 'week': $cache_timeout = WEEK_IN_SECONDS; break; default: $cache_timeout = HOUR_IN_SECONDS; break; } $this->config = array( 'endpoint' => $endpoint, 'target' => ( 'hashtag' === $endpoint ) ? sanitize_text_field( $settings[ $endpoint ] ) : 'users', 'posts_counter' => $settings['posts_counter'], 'post_link' => filter_var( $settings['post_link'], FILTER_VALIDATE_BOOLEAN ), 'post_link_type' => $settings['post_link_type'], 'photo_size' => $settings['photo_size'], 'post_caption' => filter_var( $settings['post_caption'], FILTER_VALIDATE_BOOLEAN ), 'post_caption_length' => ! empty( $settings['post_caption_length'] ) ? $settings['post_caption_length'] : 50, 'post_comments_count' => filter_var( $settings['post_comments_count'], FILTER_VALIDATE_BOOLEAN ), 'post_likes_count' => filter_var( $settings['post_likes_count'], FILTER_VALIDATE_BOOLEAN ), 'cache_timeout' => $cache_timeout, 'use_graph_api' => isset( $settings['use_insta_graph_api'] ) ? filter_var( $settings['use_insta_graph_api'], FILTER_VALIDATE_BOOLEAN ) : false, 'order_by' => ! empty( $settings['order_by'] ) ? $settings['order_by'] : 'recent_media', ); $posts = $this->get_posts( $this->config ); if ( ! empty( $posts ) && ! is_wp_error( $posts ) ) { foreach ( $posts as $post_data ) { $item_html = ''; $link = ( 'hashtag' === $endpoint && ! $this->config['use_graph_api'] ) ? sprintf( $this->get_post_url(), $post_data['link'] ) : $post_data['link']; $the_image = $this->the_image( $post_data ); $the_caption = $this->the_caption( $post_data ); $the_meta = $this->the_meta( $post_data ); $item_html = sprintf( '', $the_image, $the_caption, $the_meta ); if ( $this->config['post_link'] ) { $link_format = '%2$s'; $link_format = apply_filters( 'jet-elements/instagram-gallery/link-format', $link_format ); $attr = ''; if ( 'lightbox' === $this->config['post_link_type'] ) { $lightbox_desc = $lightbox_desc = isset( $settings['lightbox_show_desc'] ) ? $settings['lightbox_show_desc'] : 'false'; $img_data = $this->get_image_data( $post_data, 'high' ); $link = $img_data['src']; $attr = ' data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="' . $this->get_id() . '"'; if ( 'true' === $lightbox_desc ) { $attr .= ' data-elementor-lightbox-description="' . wp_strip_all_tags( $post_data['caption'] ) . '"'; } } $item_html = sprintf( $link_format, esc_url( $link ), $item_html, $attr ); } if ( 'grid' === $settings['layout_type'] ) { $col_class = jet_elements_tools()->col_classes( array( 'desk' => $settings['columns'], 'tab' => $settings['columns_tablet'], 'mob' => $settings['columns_mobile'], ) ); } $html .= sprintf( '', $col_class, $item_html ); } } else { $message = is_wp_error( $posts ) ? $posts->get_error_message() : esc_html__( 'Posts not found', 'jet-elements' ); $html .= sprintf( '', $message ); } echo $html; } /** * Print widget notice. * * @param $notice */ public function print_notice( $notice ) { if ( ! is_user_logged_in() ) { return; } printf( '', $notice ); } /** * Display a HTML link with image. * * @since 1.0.0 * @param array $item Item photo data. * @return string */ public function the_image( $item ) { $size = $this->get_settings_for_display( 'photo_size' ); $img_data = $this->get_image_data( $item, $size ); $width = $img_data['width']; $height = $img_data['height']; $post_photo_url = $img_data['src']; if ( empty( $post_photo_url ) ) { return ''; } $attr = ''; if ( ! empty( $width ) && ! empty( $height ) ) { $attr = ' width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '"'; } $photo_format = '%3$s'; $photo_format = apply_filters( 'jet-elements/instagram-gallery/photo-format', $photo_format ); $image = sprintf( $photo_format, esc_url( $post_photo_url ), $attr, esc_attr( $item['caption'] ) ); return $image; } /** * Get image data * * @param array $item Item photo data. * @param string $size Image size. * @return array */ public function get_image_data( $item, $size = 'high' ) { $thumbnail_resources = $item['thumbnail_resources']; if ( ! empty( $thumbnail_resources[ $size ] ) ) { $width = $thumbnail_resources[ $size ]['config_width']; $height = $thumbnail_resources[ $size ]['config_height']; $post_photo_url = $thumbnail_resources[ $size ]['src']; } else { $width = isset( $item['dimensions']['width'] ) ? $item['dimensions']['width'] : ''; $height = isset( $item['dimensions']['height'] ) ? $item['dimensions']['height'] : ''; $post_photo_url = isset( $item['image'] ) ? $item['image'] : ''; } return array( 'width' => $width, 'height' => $height, 'src' => $post_photo_url, ); } /** * Display a caption. * * @since 1.0.0 * @param array $item Item photo data. * @return string */ public function the_caption( $item ) { if ( ! $this->config['post_caption'] || empty( $item['caption'] ) ) { return; } $format = apply_filters( 'jet-elements/instagram-gallery/the-caption-format', '' ); return sprintf( $format, $item['caption'] ); } /** * Display a meta. * * @since 1.0.0 * @param array $item Item photo data. * @return string */ public function the_meta( $item ) { if ( ! $this->config['post_comments_count'] && ! $this->config['post_likes_count'] ) { return; } $meta_html = ''; if ( $this->config['post_comments_count'] ) { $meta_html .= sprintf( '', $this->get_settings_for_display( 'comments_icon' ), $item['comments'] ); } if ( $this->config['post_likes_count'] ) { $meta_html .= sprintf( '', $this->get_settings_for_display( 'likes_icon' ), $item['likes'] ); } $format = apply_filters( 'jet-elements/instagram-gallery/the-meta-format', '' ); return sprintf( $format, $meta_html ); } /** * Retrieve a photos. * * @since 1.0.0 * @param array $config Set of configuration. * @return array */ public function get_posts( $config ) { $transient_key = md5( $this->get_transient_key() ); $data = get_transient( $transient_key ); if ( ! empty( $data ) && 1 !== $config['cache_timeout'] && array_key_exists( 'thumbnail_resources', $data[0] ) ) { return $data; } if ( $config['use_graph_api'] ) { $response = $this->remote_get_from_qraph_api( $config ); } else { $response = $this->remote_get( $config ); } if ( is_wp_error( $response ) ) { return $response; } if ( 'hashtag' === $config['endpoint'] && ! $config['use_graph_api'] ) { $data = $this->get_response_data( $response ); } else { $data = $this->get_response_data_from_official_api( $response ); } if ( empty( $data ) ) { return array(); } set_transient( $transient_key, $data, $config['cache_timeout'] ); return $data; } /** * Retrieve the raw response from the HTTP request using the GET method from Graph API. * * @param array $config * * @return mixed|string|void|\WP_Error */ public function remote_get_from_qraph_api( $config ) { $account_config = $this->get_business_account_config(); $access_token = $account_config['token']; $user_id = $account_config['user_id']; $url = add_query_arg( array( 'user_id' => $user_id, 'q' => $config['target'], 'access_token' => $access_token, ), $this->graph_api_url . 'ig_hashtag_search' ); $response = wp_remote_get( $url, array( 'timeout' => 10 ) ); $body = wp_remote_retrieve_body( $response ); $body = json_decode( $body, true ); if ( ! is_array( $body ) ) { return new \WP_Error( 'invalid-data', esc_html__( 'Invalid data', 'jet-elements' ) ); } if ( isset( $body['error']['message'] ) ) { return new \WP_Error( 'invalid-data', $body['error']['message'] ); } if ( empty( $body['data'][0]['id'] ) ) { return new \WP_Error( 'invalid-data', esc_html__( 'Can\'t find the tag ID.', 'jet-elements' ) ); } $tag_id = $body['data'][0]['id']; $url = add_query_arg( array( 'user_id' => $user_id, 'access_token' => $access_token, 'limit' => 50, 'fields' => 'id,media_type,media_url,caption,comments_count,like_count,permalink,children{media_url,id,media_type,permalink}', ), $this->graph_api_url . $tag_id . '/' . $config['order_by'] ); $response = wp_remote_get( $url, array( 'timeout' => 10 ) ); $body = wp_remote_retrieve_body( $response ); $body = json_decode( $body, true ); if ( ! is_array( $body ) ) { return new \WP_Error( 'invalid-data', esc_html__( 'Invalid data', 'jet-elements' ) ); } if ( isset( $body['error']['message'] ) ) { return new \WP_Error( 'invalid-data', $body['error']['message'] ); } return $body; } /** * Retrieve the raw response from the HTTP request using the GET method. * * @since 1.0.0 * @return array|object */ public function remote_get( $config ) { $url = $this->get_grab_url( $config ); $response = wp_remote_get( $url, array( 'timeout' => 60, ) ); $response_code = wp_remote_retrieve_response_code( $response ); if ( 200 !== $response_code ) { $body = json_decode( wp_remote_retrieve_body( $response ), true ); if ( is_array( $body ) && isset( $body['error']['message'] ) ) { $message = $body['error']['message']; } else { $message = esc_html__( 'Posts not found', 'jet-elements' ); } return new \WP_Error( $response_code, $message ); } $result = json_decode( wp_remote_retrieve_body( $response ), true ); if ( ! is_array( $result ) ) { return new \WP_Error( 'invalid-data', esc_html__( 'Invalid data', 'jet-elements' ) ); } return $result; } /** * Get prepared response data. * * @param $response * * @return array */ public function get_response_data( $response ) { $key = 'hashtag' == $this->config['endpoint'] ? 'hashtag' : 'user'; if ( 'hashtag' === $key ) { $response = isset( $response['graphql'] ) ? $response['graphql'] : $response; } $response_items = ( 'hashtag' === $key ) ? $response[ $key ]['edge_hashtag_to_media']['edges'] : $response['graphql'][ $key ]['edge_owner_to_timeline_media']['edges']; if ( empty( $response_items ) ) { return array(); } $data = array(); $nodes = array_slice( $response_items, 0, $this->config['posts_counter'], true ); foreach ( $nodes as $post ) { $_post = array(); $_post['link'] = $post['node']['shortcode']; $_post['image'] = $post['node']['thumbnail_src']; $_post['caption'] = isset( $post['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ? wp_html_excerpt( $post['node']['edge_media_to_caption']['edges'][0]['node']['text'], $this->config['post_caption_length'], '…' ) : ''; $_post['comments'] = $post['node']['edge_media_to_comment']['count']; $_post['likes'] = $post['node']['edge_liked_by']['count']; $_post['dimensions'] = $post['node']['dimensions']; $_post['thumbnail_resources'] = $this->_generate_thumbnail_resources( $post ); array_push( $data, $_post ); } return $data; } /** * Get prepared response data from official api. * * @param $response * * @return array */ public function get_response_data_from_official_api( $response ) { if ( ! isset( $response['data'] ) ) { return array(); } $response_items = $response['data']; if ( empty( $response_items ) ) { return array(); } if ( $this->config['use_graph_api'] ) { $response_items = $this->remove_video_items( $response_items ); } $data = array(); $nodes = array_slice( $response_items, 0, $this->config['posts_counter'], true ); foreach ( $nodes as $post ) { $media_url = ! empty( $post['media_url'] ) ? $post['media_url'] : ''; switch ( $post['media_type'] ) { case 'VIDEO': $media_url = ! empty( $post['thumbnail_url'] ) ? $post['thumbnail_url'] : ''; break; case 'CAROUSEL_ALBUM': $media_url = ! empty( $post['children']['data'][0]['media_url'] ) ? $post['children']['data'][0]['media_url'] : $media_url; break; } $_post = array(); $_post['link'] = $post['permalink']; $_post['image'] = $media_url; $_post['caption'] = ! empty( $post['caption'] ) ? wp_html_excerpt( $post['caption'], $this->config['post_caption_length'], '…' ) : ''; $_post['comments'] = ! empty( $post['comments_count'] ) ? $post['comments_count'] : 0; // TODO: available only for Graph Api $_post['likes'] = ! empty( $post['like_count'] ) ? $post['like_count'] : 0; // TODO: available only for Graph Api $_post['thumbnail_resources'] = $this->_generate_thumbnail_resources_from_official_api( $post ); // TODO: this data now not available array_push( $data, $_post ); } return $data; } /** * Remove video items. * * @param array $data * @return array */ public function remove_video_items( $data ) { $result = array(); foreach ( $data as $item ) { if ( ! empty( $item['media_type'] ) && 'VIDEO' === $item['media_type'] ) { continue; } if ( ! empty( $item['children']['data'] ) ) { $item['children']['data'] = $this->remove_video_items( $item['children']['data'] ); if ( empty( $item['children']['data'] ) ) { continue; } } $result[] = $item; } return $result; } /** * Generate thumbnail resources. * * @param $post_data * * @return array */ public function _generate_thumbnail_resources( $post_data ) { $post_data = $post_data['node']; $thumbnail_resources = array( 'thumbnail' => false, 'low' => false, 'standard' => false, 'high' => false, ); if ( ! empty( $post_data['thumbnail_resources'] ) && is_array( $post_data['thumbnail_resources'] ) ) { foreach ( $post_data['thumbnail_resources'] as $key => $resources_data ) { if ( 150 === $resources_data['config_width'] ) { $thumbnail_resources['thumbnail'] = $resources_data; continue; } if ( 320 === $resources_data['config_width'] ) { $thumbnail_resources['low'] = $resources_data; continue; } if ( 640 === $resources_data['config_width'] ) { $thumbnail_resources['standard'] = $resources_data; continue; } } } if ( ! empty( $post_data['display_url'] ) ) { $thumbnail_resources['high'] = array( 'src' => $post_data['display_url'], 'config_width' => $post_data['dimensions']['width'], 'config_height' => $post_data['dimensions']['height'], ) ; } return $thumbnail_resources; } /** * Generate thumbnail resources from official api. * * @param $post_data * * @return array */ public function _generate_thumbnail_resources_from_official_api( $post_data ) { $thumbnail_resources = array( 'thumbnail' => false, 'low' => false, 'standard' => false, 'high' => false, ); if ( ! empty( $post_data['images'] ) && is_array( $post_data['images'] ) ) { $thumbnails_data = $post_data['images']; $thumbnail_resources['thumbnail'] = array( 'src' => $thumbnails_data['thumbnail']['url'], 'config_width' => $thumbnails_data['thumbnail']['width'], 'config_height' => $thumbnails_data['thumbnail']['height'], ); $thumbnail_resources['low'] = array( 'src' => $thumbnails_data['low_resolution']['url'], 'config_width' => $thumbnails_data['low_resolution']['width'], 'config_height' => $thumbnails_data['low_resolution']['height'], ); $thumbnail_resources['standard'] = array( 'src' => $thumbnails_data['standard_resolution']['url'], 'config_width' => $thumbnails_data['standard_resolution']['width'], 'config_height' => $thumbnails_data['standard_resolution']['height'], ); $thumbnail_resources['high'] = $thumbnail_resources['standard']; } return $thumbnail_resources; } /** * Retrieve a grab URL. * * @since 1.0.0 * @return string */ public function get_grab_url( $config ) { if ( 'hashtag' == $config['endpoint'] ) { $url = sprintf( $this->get_tags_url(), $config['target'] ); $url = add_query_arg( array( '__a' => 1 ), $url ); } else { $url = $this->get_self_url(); $url = add_query_arg( array( 'fields' => 'id,media_type,media_url,thumbnail_url,permalink,caption', 'access_token' => $this->get_access_token(), ), $url ); } return $url; } /** * Retrieve a URL for photos by hashtag. * * @since 1.0.0 * @return string */ public function get_tags_url() { return apply_filters( 'jet-elements/instagram-gallery/get-tags-url', $this->api_url . 'explore/tags/%s/' ); } /** * Retrieve a URL for self photos. * * @since 1.0.0 * @return string */ public function get_self_url() { return apply_filters( 'jet-elements/instagram-gallery/get-self-url', $this->new_api_url . 'me/media/' ); } /** * Retrieve a URL for post. * * @since 1.0.0 * @return string */ public function get_post_url() { return apply_filters( 'jet-elements/instagram-gallery/get-post-url', $this->api_url . 'p/%s/' ); } /** * sanitize endpoint. * * @since 1.0.0 * @return string */ public function sanitize_endpoint() { return in_array( $this->get_settings( 'endpoint' ) , array( 'hashtag', 'self' ) ) ? $this->get_settings( 'endpoint' ) : 'hashtag'; } /** * Retrieve a photo sizes (in px) by option name. * * @since 1.0.0 * @param string $photo_size Photo size. * @return array */ public function _get_relation_photo_size( $photo_size ) { switch ( $photo_size ) { case 'high': $size = array(); break; case 'standard': $size = array( 640, 640 ); break; case 'low': $size = array( 320, 320 ); break; default: $size = array( 150, 150 ); break; } return apply_filters( 'jet-elements/instagram-gallery/relation-photo-size', $size, $photo_size ); } /** * Get transient key. * * @since 1.0.0 * @return string */ public function get_transient_key() { return sprintf( 'jet_elements_instagram_%s_%s%s_posts_count_%s_caption_%s', $this->config['endpoint'], $this->config['target'], $this->config['use_graph_api'] ? '_order_' . $this->config['order_by'] : '', $this->config['posts_counter'], $this->config['post_caption_length'] ); } /** * Generate setting json * * @return string */ public function generate_setting_json() { $module_settings = $this->get_settings(); $settings = array( 'layoutType' => $module_settings['layout_type'], 'columns' => $module_settings['columns'], 'columnsTablet' => $module_settings['columns_tablet'], 'columnsMobile' => $module_settings['columns_mobile'], ); $settings = json_encode( $settings ); return sprintf( 'data-settings=\'%1$s\'', $settings ); } /** * Get access token. * * @return string */ public function get_access_token() { if ( ! $this->access_token ) { $source = $this->get_settings( 'access_token_source' ); if ( 'custom' === $source ) { $this->access_token = $this->get_settings( 'custom_access_token' ); } else { $this->access_token = jet_elements_settings()->get( 'insta_access_token' ); } } return $this->access_token; } /** * Get business account config. * * @return array */ public function get_business_account_config() { if ( ! $this->business_account_config ) { $this->business_account_config['token'] = jet_elements_settings()->get( 'insta_business_access_token' ); $this->business_account_config['user_id'] = jet_elements_settings()->get( 'insta_business_user_id' ); } return $this->business_account_config; } /** * Get access token from the plugin settings. * * @return string */ public function get_access_token_from_settings() { return jet_elements_settings()->get( 'insta_access_token' ); } } Motor durability tests - Dina Motors

Engine Durability Tests

Types of motor durability tests