add_filter( 'wp_insert_post_empty_content', 'check_list_post', 99, 2 );
function check_list_post($maybe_empty, $postarr)
{
global $post_type;
if ( $post_type != 'MY_POST_TYPE' ) return $maybe_empty;
if ( true === wp_is_post_revision( $postarr[ 'ID' ] ) || $postarr['post_status'] == 'auto-draft' ) {
return $maybe_empty;
}
if ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'trash' ) {
return $maybe_empty;
}
if ($something_wrong) {
// getFlashMessage()->setMessage('Error: Insert error','error'); // add error to notice
return true;
}
return $maybe_empty;
}
$myPosts = get_posts(array(
'category' => $category->term_id,
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'cinema',
'meta_query' => array(
array(
'key' => 'cinema'
)
)
));
$prev_value = -1;
if ($meta_values != $prev_value ) {
$prev_value = $meta_values;
$output = rtrim($output,', '); // Удалям последнюю запятую
$output .= '<br><span class="floor-category__floor-name">'.$string.'</span><br>'
}
$output .= '<span>'.$newText.'</span>, '
wp search-replace 'mysite.ru' 'mysite2.ru'
$container.infinitescroll({
admin-post.php?action=some/action
add_action( 'admin_post_some/action', 'some_action_post_callback' );
function some_action_post_callback() {
//do something with form data and redirect to url
}
<td><input type="checkbox" name="theme_settings[show_block_2]" id="theme_settings[show_block_2]" value="1"<?php if($options[show_block_2]=='1') echo ' checked="checked"';?> /></td>
<input type="hidden" name="theme_settings[show_block_1]" value="0">
wp_localize_script( 'img_import', 'MyAjax', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('myajax-nonce'),
'pluginsUrl' => plugins_url()
) );
wp_localize_script( 'img_import.js', 'MyAjax', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('myajax-nonce'),
'pluginsUrl' => plugins_url()
) );
<?php echo do_shortcode('[btc]'); ?>
<?php echo get_post_meta($post->ID, 'btc', true); ?>
<?php if(has_post_custom_meta('Desc')) : ?>
<div class="child_page_desc">
<?php echo get_post_meta($post->ID, 'Desc', true); ?>
</div>
<?php endif; ?>
<?php $desc = get_post_meta(get_the_ID(), 'Desc', true); ?>
<?php if(!empty($desc)) : ?>
<div class="child_page_desc">
<?php echo $desc;?>
</div>
<?php endif; ?>