Esempio n. 1
0
/**
 * @param $post_id
 */
function euzakupki_sale_post_save($post_id)
{
    // Check if our nonce is set.
    if (!isset($_POST['euzakupki_sale_properties_metabox_nonce'])) {
        return;
    }
    // Verify that the nonce is valid.
    if (!wp_verify_nonce($_POST['euzakupki_sale_properties_metabox_nonce'], plugin_basename(__FILE__))) {
        return;
    }
    // If this is an autosave, our form has not been submitted, so we don't want to do anything.
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // Check the user's permissions.
    if (isset($_POST['post_type']) && 'sale' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    // Check URL metabox postdata
    if (!euzakupki_postdata_validate_url($_POST['euzakupki_sale_url'])) {
        wp_die(__('Недопустимая внешняя ссылка на акцию', 'euzakupki') . '<br/><strong>' . $_POST['euzakupki_sale_url'] . '</strong>');
    }
    /* OK, it's safe for us to save the data now. */
    euzakupki_metabox_save_postdata($post_id, 'sale', 'url');
}
Esempio n. 2
0
/**
 * @param $post_id
 */
function euzakupki_testimonial_post_save($post_id)
{
    // Check if our nonce is set.
    if (!isset($_POST['euzakupki_testimonial_properties_metabox_nonce'])) {
        return;
    }
    // Verify that the nonce is valid.
    if (!wp_verify_nonce($_POST['euzakupki_testimonial_properties_metabox_nonce'], plugin_basename(__FILE__))) {
        return;
    }
    // If this is an autosave, our form has not been submitted, so we don't want to do anything.
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // Check the user's permissions.
    if (isset($_POST['post_type']) && 'testimonial' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    /* OK, it's safe for us to save the data now. */
    euzakupki_metabox_save_postdata($post_id, 'testimonial', 'author');
    euzakupki_metabox_save_postdata($post_id, 'testimonial', 'location');
}