Forum Replies Created

Viewing 15 replies - 31 through 45 (of 108 total)
  • Thread Starter rsmith4321

    (@rsmith4321)

    Thanks, that does work better, I changed it to this

    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){
    	
    	$allowed_html = array(
    	
    			'h1' => array(),
    			'h2' => array(),
    			'h3' => array(),
    			'td' => array(),
    			'tr' => array(),
    			'tbody' => array(),
    			'table' => array(),
    			'span' => array(),
    			'img' => array(),
    			'div' => array(),
    	);
    	
    	
    	return $allowed_html;
    } );

    However it still seems to strip any styles and classes from the <div> tags as well as <span> tags. Do you have any suggestions? Also, is it correct to have a comma after the last item in the array? Thanks.

    • This reply was modified 4 years ago by rsmith4321.
    • This reply was modified 4 years ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    Great, that seemed to fix it, thanks! I remember this feature was really buggy when it first came out, I think something got stuck and I didn’t notice it until now. This might be a good general recommendation to everyone that used the Optimize feature on initial launch.

    Thread Starter rsmith4321

    (@rsmith4321)

    Something interesting I noticed, if I go in and manually set the option in an individual tag metabox to “Allow search engines to show this Tag in search results?” to “No” instead of the default “No (current default for Tags).” Then the page will be set to noindex.

    Also if I create a new tag, it will be correctly set to noindex. It’s like the old tags are stuck and won’t respect the default setting, even though they are definitely set to current default. I downloaded your test helper plugin, would there be something I could reset that might remove whatever is causing this issue? I’ve been using this plugin for like a decade so there could be something old in the database.

    • This reply was modified 4 years ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    That is why I was reporting the issue, switching Tags to Not show in search results as you mentioned is not working. It does work if I set an individual page to noindex, but it doesn’t work for tags. They don’t appear in the sitemap, but they still have index set in the html.

    Also, editing an individual tag like you mentioned in the second option, it’s already set to No (current default for Tags). Thanks for the help.

    rsmith4321

    (@rsmith4321)

    I’m actually having the same issue. I have my tags taxonomies set to no just like you described. However the pages are still content=index in the source code. I’ve been using Yoast for many years and only noticed this issue recently. You can check out an example here https://www.ryansmithphotography.com/blog/tag/grande-dunes/

    Thread Starter rsmith4321

    (@rsmith4321)

    Great, that seems to work. You can check out an example here https://www.ryansmithphotography.com/blog/2021/02/14/rainy-wedding-day-at-the-grand-dunes-resort-golf-club-in-myrtle-beach/. I can see why this is going to be difficult to implement for everyone if every theme implements featured images differently.

    Thread Starter rsmith4321

    (@rsmith4321)

    The PSI LCP mobile speed is frustrating because it appears to be just the size of my main image and the limited bandwidth of the mobile test. I have a srcset on the image and it’s a webp, so I just don’t know what else Google can expect. Here is the featured image code.

    <?php
    /**
     * Featured image elements.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    if ( ! function_exists( 'generate_post_image' ) ) {
    	add_action( 'generate_after_entry_header', 'generate_post_image' );
    	/**
    	 * Prints the Post Image to post excerpts
    	 */
    	function generate_post_image() {
    		// If there's no featured image, return.
    		if ( ! has_post_thumbnail() ) {
    			return;
    		}
    
    		// If we're not on any single post/page or the 404 template, we must be showing excerpts.
    		if ( ! is_singular() && ! is_404() ) {
    
    			$attrs = array();
    
    			if ( 'microdata' === generate_get_schema_type() ) {
    				$attrs = array(
    					'itemprop' => 'image',
    				);
    			}
    
    			echo apply_filters( // phpcs:ignore
    				'generate_featured_image_output',
    				sprintf(
    					'<div class="post-image">
    						%3$s
    						<a href="%1$s">
    							%2$s
    						</a>
    					</div>',
    					esc_url( get_permalink() ),
    					get_the_post_thumbnail(
    						get_the_ID(),
    						apply_filters( 'generate_page_header_default_size', 'full' ),
    						$attrs
    					),
    					apply_filters( 'generate_inside_featured_image_output', '' )
    				)
    			);
    		}
    	}
    }
    
    if ( ! function_exists( 'generate_featured_page_header_area' ) ) {
    	/**
    	 * Build the page header.
    	 *
    	 * @since 1.0.7
    	 *
    	 * @param string $class The featured image container class.
    	 */
    	function generate_featured_page_header_area( $class ) {
    		// Don't run the function unless we're on a page it applies to.
    		if ( ! is_singular() ) {
    			return;
    		}
    
    		// Don't run the function unless we have a post thumbnail.
    		if ( ! has_post_thumbnail() ) {
    			return;
    		}
    
    		$attrs = array();
    
    		if ( 'microdata' === generate_get_schema_type() ) {
    			$attrs = array(
    				'itemprop' => 'image',
    			);
    		}
    		?>
    		<div class="featured-image <?php echo esc_attr( $class ); ?> grid-container grid-parent">
    			<?php
    				the_post_thumbnail(
    					apply_filters( 'generate_page_header_default_size', 'full' ),
    					$attrs
    				);
    			?>
    		</div>
    		<?php
    	}
    }
    
    if ( ! function_exists( 'generate_featured_page_header' ) ) {
    	add_action( 'generate_after_header', 'generate_featured_page_header', 10 );
    	/**
    	 * Add page header above content.
    	 *
    	 * @since 1.0.2
    	 */
    	function generate_featured_page_header() {
    		if ( function_exists( 'generate_page_header' ) ) {
    			return;
    		}
    
    		if ( is_page() ) {
    			generate_featured_page_header_area( 'page-header-image' );
    		}
    	}
    }
    
    if ( ! function_exists( 'generate_featured_page_header_inside_single' ) ) {
    	add_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 );
    	/**
    	 * Add post header inside content.
    	 * Only add to single post.
    	 *
    	 * @since 1.0.7
    	 */
    	function generate_featured_page_header_inside_single() {
    		if ( function_exists( 'generate_page_header' ) ) {
    			return;
    		}
    
    		if ( is_single() ) {
    			generate_featured_page_header_area( 'page-header-image-single' );
    		}
    	}
    }
    
    Thread Starter rsmith4321

    (@rsmith4321)

    Great, that all seems to be working correctly now. One other thing, I notice featured images in blog posts still do not have data-hero added, but I think that is what you are working on already. But if you want to see an example you can here https://www.ryansmithphotography.com/blog/2021/01/16/maternity-portraits-caledonia-golf-2021/

    • This reply was modified 4 years, 1 month ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    It’s added in the customizer under the Header section for my Generatepress theme. But I don’t know exactly how it’s added. I have a feeling if I get my logo and my first image preloaded and everything else ignored it will improve my LCP time.

    I will give you the code below for my header.php file in my theme.

    <?php
    /**
     * Header elements.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    if ( ! function_exists( 'generate_construct_header' ) ) {
    	add_action( 'generate_header', 'generate_construct_header' );
    	/**
    	 * Build the header.
    	 *
    	 * @since 1.3.42
    	 */
    	function generate_construct_header() {
    		?>
    		<header id="masthead" <?php generate_do_element_classes( 'header' ); ?>>
    			<div <?php generate_do_element_classes( 'inside_header' ); ?>>
    				<?php
    				/**
    				 * generate_before_header_content hook.
    				 *
    				 * @since 0.1
    				 */
    				do_action( 'generate_before_header_content' );
    
    				if ( ! generate_is_using_flexbox() ) {
    					// Add our main header items.
    					generate_header_items();
    				}
    
    				/**
    				 * generate_after_header_content hook.
    				 *
    				 * @since 0.1
    				 *
    				 * @hooked generate_add_navigation_float_right - 5
    				 */
    				do_action( 'generate_after_header_content' );
    				?>
    			</div>
    		</header>
    		<?php
    	}
    }
    
    if ( ! function_exists( 'generate_header_items' ) ) {
    	/**
    	 * Build the header contents.
    	 * Wrapping this into a function allows us to customize the order.
    	 *
    	 * @since 1.2.9.7
    	 */
    	function generate_header_items() {
    		$order = apply_filters(
    			'generate_header_items_order',
    			array(
    				'header-widget',
    				'site-branding',
    				'logo',
    			)
    		);
    
    		foreach ( $order as $item ) {
    			if ( 'header-widget' === $item ) {
    				generate_construct_header_widget();
    			}
    
    			if ( 'site-branding' === $item ) {
    				generate_construct_site_title();
    			}
    
    			if ( 'logo' === $item ) {
    				generate_construct_logo();
    			}
    		}
    	}
    }
    
    if ( ! function_exists( 'generate_construct_logo' ) ) {
    	/**
    	 * Build the logo
    	 *
    	 * @since 1.3.28
    	 */
    	function generate_construct_logo() {
    		$logo_url = ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ) : false;
    		$logo_url = ( $logo_url ) ? $logo_url[0] : generate_get_option( 'logo' );
    
    		$logo_url = esc_url( apply_filters( 'generate_logo', $logo_url ) );
    		$retina_logo_url = esc_url( apply_filters( 'generate_retina_logo', generate_get_option( 'retina_logo' ) ) );
    
    		// If we don't have a logo, bail.
    		if ( empty( $logo_url ) ) {
    			return;
    		}
    
    		/**
    		 * generate_before_logo hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_before_logo' );
    
    		$attr = apply_filters(
    			'generate_logo_attributes',
    			array(
    				'class' => 'header-image is-logo-image',
    				'alt'   => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    				'src'   => $logo_url,
    				'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    			)
    		);
    
    		if ( '' !== $retina_logo_url ) {
    			$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
    
    			// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
    			if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
    				$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
    
    				if ( ! empty( $data ) ) {
    					$attr['width'] = $data['width'];
    					$attr['height'] = $data['height'];
    				}
    			}
    		} elseif ( generate_is_using_flexbox() ) {
    			// Add this to flexbox version only until we can verify it won't conflict with existing installs.
    			if ( function_exists( 'the_custom_logo' ) && get_theme_mod( 'custom_logo' ) ) {
    				$data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
    
    				if ( ! empty( $data ) ) {
    					$attr['width'] = $data['width'];
    					$attr['height'] = $data['height'];
    				}
    			}
    		}
    
    		$attr = array_map( 'esc_attr', $attr );
    
    		$html_attr = '';
    		foreach ( $attr as $name => $value ) {
    			$html_attr .= " $name=" . '"' . $value . '"';
    		}
    
    		// Print our HTML.
    		echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    			'generate_logo_output',
    			sprintf(
    				'<div class="site-logo">
    					<a href="%1$s" title="%2$s" rel="home">
    						<img %3$s />
    					</a>
    				</div>',
    				esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
    				esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
    				$html_attr
    			),
    			$logo_url,
    			$html_attr
    		);
    
    		/**
    		 * generate_after_logo hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_after_logo' );
    	}
    }
    
    if ( ! function_exists( 'generate_construct_site_title' ) ) {
    	/**
    	 * Build the site title and tagline.
    	 *
    	 * @since 1.3.28
    	 */
    	function generate_construct_site_title() {
    		$generate_settings = wp_parse_args(
    			get_option( 'generate_settings', array() ),
    			generate_get_defaults()
    		);
    
    		// Get the title and tagline.
    		$title = get_bloginfo( 'title' );
    		$tagline = get_bloginfo( 'description' );
    
    		// If the disable title checkbox is checked, or the title field is empty, return true.
    		$disable_title = ( '1' == $generate_settings['hide_title'] || '' == $title ) ? true : false; // phpcs:ignore
    
    		// If the disable tagline checkbox is checked, or the tagline field is empty, return true.
    		$disable_tagline = ( '1' == $generate_settings['hide_tagline'] || '' == $tagline ) ? true : false;  // phpcs:ignore
    
    		$schema_type = generate_get_schema_type();
    
    		// Build our site title.
    		$site_title = apply_filters(
    			'generate_site_title_output',
    			sprintf(
    				'<%1$s class="main-title"%4$s>
    					<a href="%2$s" rel="home">
    						%3$s
    					</a>
    				</%1$s>',
    				( is_front_page() && is_home() ) ? 'h1' : 'p',
    				esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
    				get_bloginfo( 'name' ),
    				'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
    			)
    		);
    
    		// Build our tagline.
    		$site_tagline = apply_filters(
    			'generate_site_description_output',
    			sprintf(
    				'<p class="site-description"%2$s>
    					%1$s
    				</p>',
    				html_entity_decode( get_bloginfo( 'description', 'display' ) ), // phpcs:ignore
    				'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
    			)
    		);
    
    		// Site title and tagline.
    		if ( false === $disable_title || false === $disable_tagline ) {
    			if ( generate_needs_site_branding_container() ) {
    				echo '<div class="site-branding-container">';
    				generate_construct_logo();
    			}
    
    			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- outputting site title and tagline. False positive.
    			echo apply_filters(
    				'generate_site_branding_output',
    				sprintf(
    					'<div class="site-branding">
    						%1$s
    						%2$s
    					</div>',
    					( ! $disable_title ) ? $site_title : '',
    					( ! $disable_tagline ) ? $site_tagline : ''
    				)
    			);
    
    			if ( generate_needs_site_branding_container() ) {
    				echo '</div>';
    			}
    		}
    	}
    }
    
    add_filter( 'generate_header_items_order', 'generate_reorder_inline_site_branding' );
    /**
     * Remove the logo from it's usual position.
     *
     * @since 2.3
     * @param array $order Order of the header items.
     */
    function generate_reorder_inline_site_branding( $order ) {
    	if ( ! generate_get_option( 'inline_logo_site_branding' ) || ! generate_has_logo_site_branding() ) {
    		return $order;
    	}
    
    	return array(
    		'header-widget',
    		'site-branding',
    	);
    }
    
    if ( ! function_exists( 'generate_construct_header_widget' ) ) {
    	/**
    	 * Build the header widget.
    	 *
    	 * @since 1.3.28
    	 */
    	function generate_construct_header_widget() {
    		if ( is_active_sidebar( 'header' ) ) :
    			?>
    			<div class="header-widget">
    				<?php dynamic_sidebar( 'header' ); ?>
    			</div>
    			<?php
    		endif;
    	}
    }
    
    add_action( 'generate_before_header_content', 'generate_do_site_logo', 5 );
    /**
     * Add the site logo to our header.
     * Only added if we aren't using floats to preserve backwards compatibility.
     *
     * @since 3.0.0
     */
    function generate_do_site_logo() {
    	if ( ! generate_is_using_flexbox() || generate_needs_site_branding_container() ) {
    		return;
    	}
    
    	generate_construct_logo();
    }
    
    add_action( 'generate_before_header_content', 'generate_do_site_branding' );
    /**
     * Add the site branding to our header.
     * Only added if we aren't using floats to preserve backwards compatibility.
     *
     * @since 3.0.0
     */
    function generate_do_site_branding() {
    	if ( ! generate_is_using_flexbox() ) {
    		return;
    	}
    
    	generate_construct_site_title();
    }
    
    add_action( 'generate_after_header_content', 'generate_do_header_widget' );
    /**
     * Add the header widget to our header.
     * Only used when grid isn't using floats to preserve backwards compatibility.
     *
     * @since 3.0.0
     */
    function generate_do_header_widget() {
    	if ( ! generate_is_using_flexbox() ) {
    		return;
    	}
    
    	generate_construct_header_widget();
    }
    
    if ( ! function_exists( 'generate_top_bar' ) ) {
    	add_action( 'generate_before_header', 'generate_top_bar', 5 );
    	/**
    	 * Build our top bar.
    	 *
    	 * @since 1.3.45
    	 */
    	function generate_top_bar() {
    		if ( ! is_active_sidebar( 'top-bar' ) ) {
    			return;
    		}
    
    		$inside_top_bar_class = '';
    
    		if ( 'contained' === generate_get_option( 'top_bar_inner_width' ) ) {
    			$inside_top_bar_class = ' grid-container grid-parent';
    
    			if ( generate_is_using_flexbox() ) {
    				$inside_top_bar_class = ' grid-container';
    			}
    		}
    		?>
    		<div <?php generate_do_element_classes( 'top_bar' ); ?>>
    			<div class="inside-top-bar<?php echo $inside_top_bar_class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- False positive. ?>">
    				<?php dynamic_sidebar( 'top-bar' ); ?>
    			</div>
    		</div>
    		<?php
    	}
    }
    
    if ( ! function_exists( 'generate_pingback_header' ) ) {
    	add_action( 'wp_head', 'generate_pingback_header' );
    	/**
    	 * Add a pingback url auto-discovery header for singularly identifiable articles.
    	 *
    	 * @since 1.3.42
    	 */
    	function generate_pingback_header() {
    		if ( is_singular() && pings_open() ) {
    			printf( '<link rel="pingback" href="%s">' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) );
    		}
    	}
    }
    
    if ( ! function_exists( 'generate_add_viewport' ) ) {
    	add_action( 'wp_head', 'generate_add_viewport' );
    	/**
    	 * Add viewport to wp_head.
    	 *
    	 * @since 1.1.0
    	 */
    	function generate_add_viewport() {
    		echo apply_filters( 'generate_meta_viewport', '<meta name="viewport" content="width=device-width, initial-scale=1">' );  // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    	}
    }
    
    add_action( 'generate_before_header', 'generate_do_skip_to_content_link', 2 );
    /**
     * Add skip to content link before the header.
     *
     * @since 2.0
     */
    function generate_do_skip_to_content_link() {
    	printf(
    		'<a class="screen-reader-text skip-link" href="#content" title="%1$s">%2$s</a>',
    		esc_attr__( 'Skip to content', 'generatepress' ),
    		esc_html__( 'Skip to content', 'generatepress' )
    	);
    }
    
    • This reply was modified 4 years, 1 month ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    I added the above code just as is. I didn’t know if I was supposed to change the ‘blockName’ to something else? But it did seem to add the data-hero to the first image on my page. I did a test on Pagespeed insights and it lowered my lcp by .5s on the mobile test. I’m not sure how it’s doing that but that is great!

    I tried the code for the logo that doesn’t seem to be working for me.

    • This reply was modified 4 years, 1 month ago by rsmith4321.
    • This reply was modified 4 years, 1 month ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    Great, I just tried it and I can edit pages now. I had to deactivate the alpha before because of this issue, but I think I will leave it running now. If you want to check it out you can it’s live now at https://www.ryansmithphotography.com. It still adds the data-hero to an image way down the page instead of the first image. I’m going to try the manual code you gave me and see if I can get that working.

    Thread Starter rsmith4321

    (@rsmith4321)

    I also notice if I try to edit a page I get the following error, however creating a new page works.

    TypeError: Cannot read property 'type' of null
        at v (https://www.ryansmithphotography.com/wp-content/plugins/amp/assets/js/amp-block-editor.js?ver=401ab3f2d960ecfe6233b84afa6650f8:13:5950)
        at https://www.ryansmithphotography.com/wp-includes/js/dist/hooks.min.js?ver=84b89ab09cbfb4469f02183611cc0939:2:5031
        at Qt (https://www.ryansmithphotography.com/wp-includes/js/dist/blocks.min.js?ver=f4636ab86bbcd1d9adb613a053f522e7:3:114677)
        at https://www.ryansmithphotography.com/wp-includes/js/dist/block-editor.min.js?ver=ee2642fa39827fa8f0de00446089caf1:12:277174
        at we (https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:84:293)
        at zj (https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:226:496)
        at Th (https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:152:223)
        at tj (https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:152:152)
        at Te (https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:146:151)
        at https://www.ryansmithphotography.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:61:68
    • This reply was modified 4 years, 1 month ago by rsmith4321.
    Thread Starter rsmith4321

    (@rsmith4321)

    I think I might be running into the bug you mentioned or something else. It seems to add data-hero to an image way down the page but it skips my first image and some other main images on the page. I also notice this in the code

    AMP optimization could not be completed due to the following:
     - CannotPreloadImage: Not preloading the hero image because of the presence of a "srcset" attribute, which can currently only be preloaded by Chromium-based browsers (see https://web.dev/preload-responsive-images/).
    <amp-img width="900" height="600" src="https://www.ryansmithphotography.com/wp-content/uploads/2021/01/holding-hands-un…>

    Is there a way to add data hero to a wordpress block image, or would I have to do that with just html code in a block? You can check it out on the page I mentioned before I’m running the alpha now.

    The indexing finished on both my sites successfully with 14.0.4. But then, a couple of days later, the “click here to speed up your site” appeared again and the whole indexing started over. Again, this is after I had already completed the indexing on version 14.0.4, it then did it a second time.

    I’m having a similar problem. One of my sites went fine. Then the other at about 80% completion said something went wrong. Then it would let me do 24 objects at a time until the final object. It’s stuck on the very last one and just keeps popping up the speed up your site box every time I refresh the page.

Viewing 15 replies - 31 through 45 (of 108 total)