PATH:
home
/
ajwellnessmassag
/
angelictravels.online
/
wp-content
/
plugins
/
essential-blocks
/
includes
/
Blocks
<?php namespace EssentialBlocks\Blocks; use EssentialBlocks\Core\Block; use EssentialBlocks\Utils\Helper; use EssentialBlocks\Utils\Settings; use EssentialBlocks\Utils\HttpRequest; class InstagramFeed extends Block { protected $attributes = [ 'blockId' => [ 'type' => 'string' ], 'layout' => [ 'type' => 'string', 'default' => 'overlay' ], 'overlayStyle' => [ 'type' => 'string', 'default' => 'overlay__simple' ], 'cardStyle' => [ 'type' => 'string', 'default' => 'content__outter' ], 'token' => [ 'type' => 'string', 'default' => '' ], 'columns' => [ 'type' => 'number', 'default' => '4' ], 'numberOfImages' => [ 'type' => 'number', 'default' => 6 ], 'thumbs' => [ 'type' => 'array', 'default' => [ ] ], 'hasEqualImages' => [ 'type' => 'boolean', 'default' => true ], 'showCaptions' => [ 'type' => 'boolean', 'default' => true ], 'showProfileName' => [ 'type' => 'boolean', 'default' => true ], 'showProfileImg' => [ 'type' => 'boolean', 'default' => true ], 'profileImg' => [ 'type' => 'string' ], 'profileName' => [ 'type' => 'string' ], 'showMeta' => [ 'type' => 'boolean', 'default' => true ], 'enableLink' => [ 'type' => 'boolean', 'default' => false ], 'openInNewTab' => [ 'type' => 'boolean', 'default' => false ], 'sortBy' => [ 'type' => 'string', 'default' => 'most_recent' ] ]; protected $frontend_scripts = [ 'essential-blocks-isotope', 'essential-blocks-image-loaded', 'essential-blocks-instagram-feed-frontend' ]; protected static $default_attributes = [ 'blockId' => '', 'token' => '', 'layout' => 'overlay', 'cardStyle' => 'content__outter', 'overlayStyle' => 'overlay__simple', 'hasEqualImages' => true, 'numberOfImages' => 6, 'sortBy' => 'most_recent', 'showCaptions' => true, 'showProfileName' => true, 'showProfileImg' => true, 'showMeta' => true, 'enableLink' => false, 'openInNewTab' => false, 'profileName' => '', 'align' => '' ]; private $settings; public function __construct() { $this->settings = Settings::get_instance(); } public function get_default_attributes() { self::$default_attributes[ 'profileImg' ] = $this->assets_manager->icon( 'user.png' ); return self::$default_attributes; } /** * Unique name of the block. * * @return string */ public function get_name() { return 'instagram-feed'; } /** * Register all other scripts * * @return void */ public function register_scripts() { $this->assets_manager->register( 'instagram-feed-frontend', $this->path() . '/frontend.js', [ 'essential-blocks-isotope', 'essential-blocks-image-loaded' ] ); } public function render_callback( $attributes, $content ) { $attributes = wp_parse_args( $attributes, $this->get_default_attributes() ); $eb_settings = get_option( 'eb_settings', [ ] ); $token = ''; if ( ! empty( $eb_settings[ 'instagramToken' ] ) ) { $token = $eb_settings[ 'instagramToken' ]; } elseif ( ! empty( $attributes[ 'token' ] ) ) { $token = $attributes[ 'token' ]; } $numberOfImages = $attributes[ 'numberOfImages' ]; $sortBy = $attributes[ 'sortBy' ]; $url = "https://graph.instagram.com/me/media?fields=id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username&limit=500&access_token={$token}"; $key = 'eb-main-instagram-api_' . $token . '_' . $numberOfImages; $results = $this->settings->get_transient( $key ); if ( ! $results ) { $results = HttpRequest::get_instance()->get( $url ); $this->settings->set_transient( $key, $results ); } $images = isset( $results->data ) ? $results->data : [ ]; switch ( $sortBy ) { case 'most_recent': usort( $images, function ( $a, $b ) { return (int) ( strtotime( $a->timestamp ) < strtotime( $b->timestamp ) ); } ); break; case 'least_recent': usort( $images, function ( $a, $b ) { return (int) ( strtotime( $a->timestamp ) > strtotime( $b->timestamp ) ); } ); break; } ob_start(); Helper::views( 'instagram-feed', wp_parse_args( $attributes, [ 'block_object' => $this, 'classHook' => '', 'profileImg' => '', 'profileName' => '', 'images' => $images ] ) ); return ob_get_clean(); } }
[-] FlexContainer.php
[edit]
[-] ProductDetails.php
[edit]
[-] WooProductGrid.php
[edit]
[-] Timeline.php
[edit]
[-] Notice.php
[edit]
[-] AdvancedImage.php
[edit]
[-] GoogleMap.php
[edit]
[-] WPForms.php
[edit]
[-] AdvancedVideo.php
[edit]
[-] ProgressBar.php
[edit]
[-] ImageComparison.php
[edit]
[-] AdvancedHeading.php
[edit]
[-] PostGrid.php
[edit]
[-] FormTextField.php
[edit]
[-] ToggleContent.php
[edit]
[-] Text.php
[edit]
[-] PricingTable.php
[edit]
[-] DualButton.php
[edit]
[-] Accordion.php
[edit]
[-] Social.php
[edit]
[-] AdvancedNavigation.php
[edit]
[-] PopUp.php
[edit]
[-] PostBlock.php
[edit]
[-] Form.php
[edit]
[-] Icon.php
[edit]
[-] Tab.php
[edit]
[-] CountDown.php
[edit]
[-] Taxonomy.php
[edit]
[-] TypingText.php
[edit]
[-] AccordionItem.php
[edit]
[-] ProductRating.php
[edit]
[-] ProductImages.php
[edit]
[-] Row.php
[edit]
[-] ShapeDivider.php
[edit]
[-] LottieAnimation.php
[edit]
[-] AddToCart.php
[edit]
[-] FlipBox.php
[edit]
[-] price.php
[edit]
[-] SocialShare.php
[edit]
[-] Slider.php
[edit]
[-] NftGallery.php
[edit]
[-] PostMeta.php
[edit]
[-] InstagramFeed.php
[edit]
[+]
..
[-] InfoBox.php
[edit]
[-] Breadcrumbs.php
[edit]
[-] PostCarousel.php
[edit]
[-] AdvancedTabs.php
[edit]
[-] ParallaxSlider.php
[edit]
[-] Wrapper.php
[edit]
[-] Button.php
[edit]
[-] Openverse.php
[edit]
[-] ImageHotspots.php
[edit]
[-] ImageGallery.php
[edit]
[-] Testimonial.php
[edit]
[-] CallToAction.php
[edit]
[-] FeatureList.php
[edit]
[-] InteractivePromo.php
[edit]
[-] NumberCounter.php
[edit]
[-] TeamMember.php
[edit]
[-] FluentForms.php
[edit]
[-] Column.php
[edit]
[-] TableOfContents.php
[edit]
[-] ProductPrice.php
[edit]