Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing or updating fails #21844

Open
6 of 11 tasks
iBook140 opened this issue Nov 20, 2024 · 5 comments
Open
6 of 11 tasks

Publishing or updating fails #21844

iBook140 opened this issue Nov 20, 2024 · 5 comments

Comments

@iBook140
Copy link

iBook140 commented Nov 20, 2024

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

Posted on WordPress Plugin support forum also:
https://wordpress.org/support/topic/publishing-or-updating-failed/

If creating a new page or updating an existing page, publishing/updating fails message is shown but page is published/updated. Error in console says:

[Error] Failed to load resource: the server responded with a status of 500 () 
https://lolyo.local/wp-json/wp/v2/pages/30264?_locale=user

If page is set to private (instead of public) or YOAST plugin is disabled, this error message is not displayed.
But also if my custom PHP block is not used, this error also doesn’t occur.

Problem seems to make the bottom part (highlighted bold). I tried removing and saving/updating works. I also tried to remove the whole JS (<script></script>), error is still there

<div class="gruenBg innerpadding">
	<div class="container">
		<div class="row mb-5">
			<div class="col-12 text-center">
				<?php 
				the_field('home-23-magische-zahlen-einleitung'); 
				$home_23_wert_1 = get_field('home-23-magische-zahlen-wert-1');
				$home_23_wert_2 = get_field('home-23-magische-zahlen-wert-2');
				$home_23_wert_3 = get_field('home-23-magische-zahlen-wert-3');
				?>
			</div>
		</div>
		<div class="row magischeZahlen counter text-center">
			<div class="col-md-4">
				<div class="single-chart mb-4">
					<svg viewBox="0 0 36 36" class="circular-chart orange">
					  <path class="circle-bg"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <path class="circle"
						stroke-dasharray="<?php echo $home_23_wert_1; ?>, 100"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <text x="18" y="20.75" class="percentage count"><?php echo $home_23_wert_1; ?></text>
					</svg>
				  </div>
				  
				  <p><?php the_field('home-23-magische-zahlen-content-wert-1'); ?></p>
				 <?php
				   if( get_field('home-23-magische-zahlen-hinweis-1') ):
				   ?>
				   <p class="hinweistext"><?php the_field('home-23-magische-zahlen-hinweis-1'); ?></p>
				   <?php endif; ?>
			</div>
			<div class="col-md-4">
				<div class="single-chart mb-4">
					<svg viewBox="0 0 36 36" class="circular-chart orange">
					  <path class="circle-bg"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <path class="circle"
						stroke-dasharray="<?php echo $home_23_wert_2; ?>, 100"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <text x="18" y="20.75" class="percentage count"><?php echo $home_23_wert_2; ?></text>
					</svg>
				  </div>
				  
				  <p><?php the_field('home-23-magische-zahlen-content-wert-2'); ?></p>
				  <?php
					if( get_field('home-23-magische-zahlen-hinweis-2') ):
					?>
					<p class="hinweistext"><?php the_field('home-23-magische-zahlen-hinweis-2'); ?></p>
					<?php endif; ?>
			</div>
			<div class="col-md-4">
				<div class="single-chart mb-4">
					<svg viewBox="0 0 36 36" class="circular-chart orange">
					  <path class="circle-bg"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <path class="circle"
						stroke-dasharray="<?php echo $home_23_wert_3; ?>, 100"
						d="M18 2.0845
						  a 15.9155 15.9155 0 0 1 0 31.831
						  a 15.9155 15.9155 0 0 1 0 -31.831"
					  />
					  <text x="18" y="20.75" class="percentage count"><?php echo $home_23_wert_3; ?><text>
					</svg>
				  </div>
				  
				  <p><?php the_field('home-23-magische-zahlen-content-wert-3'); ?></p>
				  <?php
				  if( get_field('home-23-magische-zahlen-hinweis-3') ):
				  ?>
				  <p class="hinweistext"><?php the_field('home-23-magische-zahlen-hinweis-3'); ?></p>
				  <?php endif; ?>
			</div>
		</div>
	</div>
</div>

**<?php

 function lolyo_home23_zaehler() {
	?>
	<script type="text/javascript">
		$(document).ready(function () {

  // zaehler
$(function($, win) {
	$.fn.inViewport = function(cb) {
	  return this.each(function(i,el){
		function visPx(){
		  var H = $(this).height(),
			  r = el.getBoundingClientRect(), t=r.top, b=r.bottom;
		  return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H)));  
		} visPx();
		$(win).on("resize scroll", visPx);
	  });
	};
  }(jQuery, window));
  var prefix = " %";
	  
  jQuery(function($) { // DOM ready and $ in scope
  
	$(".count").inViewport(function(px) { // Make use of the px argument!!!
	  // if element entered V.port ( px>0 ) and
	  // if prop initNumAnim flag is not yet set
	  //  = Animate numbers
	  if(px>0 && !this.initNumAnim) { 
		this.initNumAnim = true; // Set flag to true to prevent re-running the same animation
		$(this).prop('Counter',0).animate({
		  Counter: $(this).text()
		}, {
		  duration: 2000,
		  step: function (now) {
			$(this).text(parseFloat(now.toFixed(0))+prefix);
		  }
		});         
	  }
	});
  
  });
  // /zaehler
  
  
// Animation im Viewport
function isScrolledIntoView(elem) {
	var docViewTop = $(window).scrollTop();
	var docViewBottom = docViewTop + $(window).height();

	var elemTop = $(elem).offset().top;
	var elemBottom = elemTop + $(elem).height();

	return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}

$(window).scroll(function (e) {
	$('.circle').each(function () {
		if (isScrolledIntoView(this) === true) {
		$(this).addClass('circleAnimation');
		}
	});

});

// /Animation im Viewport
  
			});
  </script>

<?php
	  }
	  add_action( 'wp_footer', 'lolyo_home23_zaehler' );
	  
  ?>**

To Reproduce

Step-by-step reproduction instructions

  1. Create new page or update existing
  2. Use custom PHP block (see code above)
  3. Try to save page

Expected results

  1. No error message is displayed

Actual results

  1. Error message is displayed

Screenshots, screen recording, code snippet

If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.
thumbnail_image003

Technical info

  • If relevant, which editor is affected (or editors):
  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other:
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari
  • Other:

Used versions

  • Device you are using: MacBook Pro, Mac Studio, PC Laptop
  • Operating system: macOS 15.1, Windows 11
  • PHP version: PHP 8.2.24-nmm1, PHP 8.3.8
  • WordPress version: 6.7
  • WordPress Theme: Custom
  • Yoast SEO version: 23.9
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:
@josevarghese
Copy link
Contributor

Hi @iBook140

Thanks for using the Yoast SEO plugin. I didn't get a clear idea of how to reproduce the issue. So, can you please share the step-by-step instructions for reproducing this or with a screencast to reproduce this?

Also, have you tried a conflict check to confirm whether the issue persists only with the Yoast SEO plugin and a default theme like Twenty Twenty-Four or whether you have noticed this working when only deactivating the Yoast SEO plugin?

We look forward to hearing from you.

@iBook140
Copy link
Author

Hello @josevarghese

thank you very much for your reply!

The problem occurs in combination with my custom PHP code and YOAST (and latest WordPress update 6.7 I think).

Here is a screencast on changing page settings to private – here I assume YOAST is disabled? (problem disappears)
https://share.cleanshot.com/8fShqS9J

And this here is another one with YOAST plugin disabled. The problem does not occur here either
https://share.cleanshot.com/szxDyynm

On my custom PHP code the bottom lines seems to make problems:

<?php

 function lolyo_home23_zaehler() {
	?>
	<script type="text/javascript">
		$(document).ready(function () {

  // zaehler
$(function($, win) {
	$.fn.inViewport = function(cb) {
	  return this.each(function(i,el){
		function visPx(){
		  var H = $(this).height(),
			  r = el.getBoundingClientRect(), t=r.top, b=r.bottom;
		  return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H)));  
		} visPx();
		$(win).on("resize scroll", visPx);
	  });
	};
  }(jQuery, window));
  var prefix = " %";
	  
  jQuery(function($) { // DOM ready and $ in scope
  
	$(".count").inViewport(function(px) { // Make use of the px argument!!!
	  // if element entered V.port ( px>0 ) and
	  // if prop initNumAnim flag is not yet set
	  //  = Animate numbers
	  if(px>0 && !this.initNumAnim) { 
		this.initNumAnim = true; // Set flag to true to prevent re-running the same animation
		$(this).prop('Counter',0).animate({
		  Counter: $(this).text()
		}, {
		  duration: 2000,
		  step: function (now) {
			$(this).text(parseFloat(now.toFixed(0))+prefix);
		  }
		});         
	  }
	});
  
  });
  // /zaehler
  
  
// Animation im Viewport
function isScrolledIntoView(elem) {
	var docViewTop = $(window).scrollTop();
	var docViewBottom = docViewTop + $(window).height();

	var elemTop = $(elem).offset().top;
	var elemBottom = elemTop + $(elem).height();

	return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}

$(window).scroll(function (e) {
	$('.circle').each(function () {
		if (isScrolledIntoView(this) === true) {
		$(this).addClass('circleAnimation');
		}
	});

});

// /Animation im Viewport
  
			});
  </script>

<?php
	  }
	  add_action( 'wp_footer', 'lolyo_home23_zaehler' );
	  
  ?>

Hope my explanation is more understandable now?

Thanks and kind regards
René

@josevarghese
Copy link
Contributor

Hi Rene,

Thanks for the video, but you haven't shared where I need to add the code to check this behavior. Is this added within your block editor or within the theme? Can you share detailed steps to help me replicate it?

@iBook140
Copy link
Author

Hello @josevarghese

this is a custom page block registered in function.php of theme:

add_action('acf/init', 'my_acf_init');
function my_acf_init() {
	
	// check function exists
	if( function_exists('acf_register_block') ) {
		acf_register_block_type(array(
			'name'				=> 'home-23-magische-zahlen',
			'title'				=> __('Home-23 magische Zahlen Erfolge'),
			'render_callback'	=> 'my_acf_block_render_callback',
			'category'			=> 'layout',
			'icon'				=> 'art',
			'keywords'			=> array( 'lolyo' ),
			'mode'				=> 'edit'
		));
}

And fields are added using ACF Pro (Advanced Custom Fields).

Kind regardrs
René

@iBook140
Copy link
Author

Hello again,

just updated WordPress to latest version 6.7.1 but unfortunately problem still exists ☹️

Kind regards
René

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants