admin管理员组文章数量:1134589
I need the code to replace a post to be executed when publishing, it asks me for the ''updateSaved'' function.
function actualizacionPost($condicion){
if($condicion == 0){
$args = [
'post_type' => array('page','post'),
'numberposts' => -1,
];
$posts = get_posts($args);
foreach($posts as $post){
$contenido_modificado = preg_replace_callback('/\[et_pb_section[^\]]*\]/i', function($matches) {
$seccion = $matches[0];
if (preg_match('/hover_transition_duration="/i', $seccion)) {
// Si existe
$seccion = preg_replace('/hover_transition_duration="[^"]*"/i', 'hover_transition_duration="0ms"', $seccion);
} else {
// En caso de que esté por defecto, no existe, entonces se agrega
$seccion = preg_replace('/\]/', ' hover_transition_duration="0ms"]', $seccion);
}
return $seccion;
}, $post->post_content);
$post = array(
'ID' => $post-> ID,
'post_content' => $contenido_modificado,
);
wp_update_post( $post );
}
}
else{
$args = [
'post_type' => array('page','post'),
'p' => $condicion,
];
$posts = get_posts($args);
$contenido_modificado = preg_replace_callback('/\[et_pb_section[^\]]*\]/i', function($matches) {
$seccion = $matches[0];
if (preg_match('/hover_transition_duration="/i', $seccion)) {
// Si existe
$seccion = preg_replace('/hover_transition_duration="[^"]*"/i', 'hover_transition_duration="0ms"', $seccion);
} else {
// En caso de que esté por defecto, no existe, entonces se agrega
$seccion = preg_replace('/\]/', ' hover_transition_duration="0ms"]', $seccion);
}
return $seccion;
}, $posts);
$post = array(
'ID' => $condicion,
'post_content' => $contenido_modificado,
);
wp_update_post( $post );
}
foreach($posts as $post){
$contenido_modificado = preg_replace_callback('/\[et_pb_section[^\]]*\]/i', function($matches) {
$seccion = $matches[0];
if (preg_match('/hover_transition_duration="/i', $seccion)) {
// Si existe
$seccion = preg_replace('/hover_transition_duration="[^"]*"/i', 'hover_transition_duration="0ms"', $seccion);
} else {
// En caso de que esté por defecto, no existe, entonces se agrega
$seccion = preg_replace('/\]/', ' hover_transition_duration="0ms"]', $seccion);
}
return $seccion;
}, $post->post_content);
$post = array(
'ID' => $post-> ID,
'post_content' => $contenido_modificado,
);
wp_update_post( $post );
}
}
if (false === get_transient('mi_codigo_ejecutado')) {
$condicion = 0;
actualizacionPost($condicion);
}
set_transient('mi_codigo_ejecutado', true, DAY_IN_SECONDS);
function actualizarGuardado(){
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
$url = "https://";
}else{
$url = "http://";
}
$url_actual = $url . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$mypost_id = url_to_postid ($url_actual);
actualizacionPost($mypost_id);
}
add_action('save_post','actualizarGuardado');
本文标签: postsIt tells me that I exceeded the maximum number of executions when trying to publish content
版权声明:本文标题:posts - It tells me that I exceeded the maximum number of executions when trying to publish content 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736860380a1955887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论