'', 'previewImg' => '', 'advanceId' => '', 'className' => '', 'playlistIdOrUrl' => 'PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4', 'youTubeApiKey' => '', 'cacheDuration' => '0', 'sortBy' => 'date', 'layout' => 'inline', 'videosPerPage' => (object) array( 'lg' => 6 ), 'showVideoTitle' => true, 'videoTitleLength' => (object) array( 'lg' => 50, 'md' => 50, 'sm' => 50 ), 'loadMoreEnable' => true, 'moreButtonLabel' => 'More Videos', 'autoplay' => true, 'autoplayPlaylist' => false, 'loop' => false, 'mute' => false, 'showPlayerControl' => true, 'hideYoutubeLogo' => false, 'showDescription' => false, 'videoDescriptionLength' => (object) array( 'lg' => 100, 'md' => 100, 'sm' => 100 ), 'imageHeightRatio' => 'maxres', 'galleryColumn' => (object) array( 'lg' => 3, 'md' => 2, 'sm' => 1 ), 'displayType' => 'grid', 'enableListView' => false, 'playIcon' => 'youtube_logo_icon_solid', 'enableAnimation' => false, 'defaultYoutubeIcon' => true, ); } public function register() { register_block_type( 'ultimate-post/youtube-gallery', array( 'editor_script' => 'ultp-blocks-editor-script', 'editor_style' => 'ultp-blocks-editor-css', 'render_callback' => array( $this, 'content' ), ) ); } public function enqueue_scripts() { wp_enqueue_script( 'ultp-youtube-gallery-block', ULTP_URL . 'assets/js/ultp-youtube-gallery-block.js', array( 'jquery' ), ULTP_VER, true ); } public function content( $attr, $noAjax ) { $attr = wp_parse_args( $attr, $this->get_attributes() ); $content = ''; $attr['className'] = isset( $attr['className'] ) && $attr['className'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['className'] ) : ''; $attr['align'] = isset( $attr['align'] ) && $attr['align'] ? preg_replace( '/[^A-Za-z0-9_ -]/', '', $attr['align'] ) : ''; $attr['advanceId'] = isset( $attr['advanceId'] ) ? sanitize_html_class( $attr['advanceId'] ) : ''; $attr['blockId'] = isset( $attr['blockId'] ) ? sanitize_html_class( $attr['blockId'] ) : ''; $block_class = 'ultp-post-grid-block ultp-block-' . $attr['blockId']; if ( $attr['align'] ) { $block_class .= ' align' . $attr['align']; } if ( $attr['className'] ) { $block_class .= ' ' . $attr['className']; } $videos_per_page = isset( $attr['videosPerPage'] ) ? $attr['videosPerPage'] : array( 'lg' => 9, 'md' => 6, 'sm' => 3 ); $video_title_length = isset( $attr['videoTitleLength'] ) ? $attr['videoTitleLength'] : array( 'lg' => 50, 'md' => 50, 'sm' => 50 ); $video_description_length = isset( $attr['videoDescriptionLength'] ) ? $attr['videoDescriptionLength'] : array( 'lg' => 100, 'md' => 100, 'sm' => 100 ); $gallery_column = isset( $attr['galleryColumn'] ) ? $attr['galleryColumn'] : array( 'lg' => 3, 'md' => 2, 'sm' => 1 ); $block_name = 'youtube-gallery'; $content .= '
'; $content .= '
'; $content .= '
'; if ( $attr['loadMoreEnable'] && $attr['layout'] != 'playlist') { $content .= '
'; $content .= esc_html( $attr['moreButtonLabel'] ); $content .= '
'; } if($attr['playIcon']) { $content .= ''; } $content .= ''; $content .= ''; return $content; } }