• Resolved Makabe

    (@makabe)


    Hello,

    Thanks for the great plugin, I’ve been using it for almost two years πŸ™‚

    Unfortunately, I have a problem with Video Schema (and Video Sitemap with thumbnails) generation from Rank Math plugin when WP YouTube Lyte is enabled. In that case Rank Math doesn’t detect YouTube links automatically and you have to add them manually.

    Is there any way to disable the plugin only for logged in users? That could solve the problem.

    Greetings,

    Adrian

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    hmm … does that also happen when you disable the “add microdata” option (which adds the Video Schema) Adrian?

    Thread Starter Makabe

    (@makabe)

    Unfortunately yes, I checked all the options on and off (even “Add links below the embedded videos”).

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    darn … disabling will require a bit of (generic, not lyte specific) code, I’ll have a look later today/ tomorrow πŸ™‚

    Thread Starter Makabe

    (@makabe)

    Thanks! πŸ™‚ I have one more idea.

    In order for Rank Math to generate Video Schema and add it to Sitemap, there must be a direct link to YouTube video in the post content. Maybe it would be enough to add a link with a specific class under each Lyte placeholder, and then set “disable: none” to it. I have tested it now and it seems to work.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    so what would be the difference with “Add links below the embedded videos” which is inside a div with class lL?

    maybe adding div.lL a{disable:none;} could do the trick in Appearance -> Customize -> extra CSS?

    what does disable:none do, is that required for Rankmath?

    Thread Starter Makabe

    (@makabe)

    so what would be the difference with β€œAdd links below the embedded videos” which is inside a div with class lL?

    Because then the link is like this “Watch this video on YouTube”, and is not recognized by Rank Math.

    For it to work, the link should look like this https://www.youtube.*****

    Thread Starter Makabe

    (@makabe)

    And I meant “display:none”, not “disable:none” – sorry for that. This modification do the trick for me. Could you check if this don’t “break” anything? I tested it a few minutes ago.

    In wp-youtube-lyte.php I changed this code:

    $lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] . '">' . ' <a href="' . $lyteSettings['scheme'] . '://youtu.be/' . $vid . '" target="_blank">' . __( 'Watch this video on YouTube', 'wp-youtube-lyte' ) . '</a>.</div>';

    to this one:

    $lytelinks_txt = '<div class="lL" style="display:none!important;">' . __( '' . $lyteSettings['scheme'] . '://www.youtube.com/watch?v=' . $vid . '', 'wp-youtube-lyte' ) . '</div>';
    Thread Starter Makabe

    (@makabe)

    Or better this one, in that case you don’t need “Add links below the embedded videos” to be enabled:

    $lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] .'"></div>';

    to his one:

    $lytelinks_txt = '<div class="lL" style="max-width:100%;width:' . $lyteSettings[2] . 'px;' . $lyteSettings['pos'] .'">' . '<div style="display:none!important;">' . __( '' . $lyteSettings['scheme'] . '://www.youtube.com/watch?v=' . $vid . '', 'wp-youtube-lyte' ) . '</div></div>';
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    always better to try to avoid changes plugin code, as every update will override your changes.

    that being said, below code snippet hooks into LYTE’s API to add a hidden span with the link, give that a try maybe?

    add_filter( 'lyte_match_postparse_template', 
    	function( $lyte_template, $templateType, $yt_resp_array ) {
    		$vid_thumb_rexepped = preg_match( '#ytimg.com\/vi\/([a-zA-Z0-9\-\_]{11})\/#', $yt_resp_array['thumbUrl'], $matches );
    		$vid_link           = '<span style="display:none">https://www.youtube.com/watch?v='. $matches[1] . '</span>';
    		return $lyte_template . $vid_link;
    	},
    	10,
    	3
    );
    Thread Starter Makabe

    (@makabe)

    Yes, it works perfectly, thank you! πŸ™‚

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome, feel free to leave a review of the plugin and support here! πŸ™‚

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Disable plugin for logged users’ is closed to new replies.