Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Render logo widget output in the editor.
- *
- * Written as a Backbone JavaScript template and used to generate the live preview.
- *
- * @since 1.0.0
- */
- protected function _content_template() {
- ?><#
- classes = Array(
- 'elementor-widget-cmsmasters-site-logo__container',
- 'cmsmasters-type-' + settings.logo_type,
- 'cmsmasters-flex-align-' + settings.logo_alignment,
- );
- if ( undefined !== settings.logo_type && 'both' === settings.logo_type ) {
- classes.push( 'cmsmasters-display-' + settings.logo_display );
- }
- if ( undefined !== settings.text_position_logo_alignment &&
- 'both' === settings.logo_type &&
- 'inline' === settings.logo_display
- ) {
- classes.push( 'cmsmasters-align-' + settings.text_position_logo_alignment );
- }
- if ( undefined !== settings.logo_subtitle_position &&
- 'both' === settings.logo_type &&
- 'inline' === settings.logo_display &&
- 'none' !== settings.logo_subtitle
- ) {
- classes.push( 'cmsmasters-subtitle-position-' + settings.logo_subtitle_position );
- }
- if ( undefined !== settings.text_position_vertical_logo_alignment &&
- 'both' === settings.logo_type &&
- 'block' === settings.logo_display
- ) {
- classes.push( 'cmsmasters-vertical-' + settings.text_position_vertical_logo_alignment );
- }
- if ( undefined !== settings.hover_animation && '' !== settings.hover_animation ) {
- classes.push( 'elementor-animation-' + settings.hover_animation );
- }
- view.addRenderAttribute('logo_classes', 'class', classes);
- var is_linked = 1,
- logo_link = settings.logo_link,
- logo_html = '';
- if ( 'none' === settings.logo_link ) {
- is_linked = 0;
- }
- if ( 'true' === settings.remove_link_on_front && '<?php echo is_front_page() ?>' ) {
- is_linked = 0;
- }
- logo_html += '<div ' + view.getRenderAttributeString( 'logo_classes' ) + '>';
- if ( is_linked ) {
- if ( 'home' === logo_link ) {
- logo_html += '<a' +
- ' href="/"' +
- ' class="elementor-widget-cmsmasters-site-logo__wrapper"' +
- ( settings.open_in_new_window ? ' target="_blank"' : '' ) +
- ( settings.add_nofollow ? ' rel="nofollow"' : '' ) +
- '>';
- } else if ( 'custom' === logo_link ) {
- logo_html += '<a' +
- ' href="' + settings.logo_custom_url + '"' +
- ' class="elementor-widget-cmsmasters-site-logo__wrapper"' +
- ( settings.logo_custom_url.is_external ? ' target="_blank"' : '' ) +
- ( settings.logo_custom_url.nofollow ? ' rel="nofollow"' : '' ) +
- '>';
- }
- } else {
- logo_html += '<div class="elementor-widget-cmsmasters-site-logo__wrapper">';
- }
- var getLogoImage = function() {
- if ( 'default' === settings.logo_source ) {
- var image_data = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ),
- image_logo['url'] = $image_data[0];
- } else {
- $image_data = wp_get_attachment_image_src( $image['id'], 'full' );
- $image_logo['url'] = $image_data[0];
- }
- if ( 'text' === $type || ( ! $image && 'image' === $logo_image_type ) ) {
- return;
- }
- if ( empty( $image_logo['url'] ) && 'image' === $logo_image_type ) {
- return;
- }
- $out = '';
- if ( 'image' === $logo_image_type ) {
- $width = isset( $image_data[1] ) ? ' width="' . $image_data[1] . '"' : '';
- $height = isset( $image_data[2] ) ? ' height="' . $image_data[2] . '"' : '';
- $image_2x = '';
- if ( isset( $settings['logo_image_2x'] ) && ! empty( $settings['logo_image_2x']['url'] ) ) {
- $image_2x = ' srcset="' . $image_logo['url'] . ' 1x, ' . $settings['logo_image_2x']['url'] . ' 2x"';
- }
- $out .= '<img' .
- ' src="' . $image_logo['url'] . '"' .
- ' class="elementor-widget-cmsmasters-site-logo__img"' .
- ' alt="' . get_bloginfo( 'name' ) . '"' .
- "{$width}{$height}{$image_2x} />";
- } else {
- $out .= '<div class="elementor-widget-cmsmasters-site-logo__icon">' .
- '<i class="' . $settings['logo_icon']['value'] . '"></i>' .
- '</div>';
- }
- return $out;
- }
- if ( 'default' === settings.logo_subtitle_position ) {
- logo_html += $this->get_logo_image() .
- '<div class="elementor-widget-cmsmasters-site-logo__wrapper-text">' .
- $this->get_logo_text() .
- $this->get_logo_subtitle() .
- '</div>';
- } else {
- echo '<div class="cmsmasters-logo__title-wrapper">' .
- $this->get_logo_image() .
- '<div class="elementor-widget-cmsmasters-site-logo__wrapper-text">' .
- $this->get_logo_text() .
- '</div>' .
- '</div>' .
- $this->get_logo_subtitle();
- }
- echo ( is_linked ? '</a>' : '</div>' ) .
- '</div>';
- #><?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement