Beispiel #1
0
<?php

global $post;
$pg_opts = dt_storage('page_data');
if (isset($pg_opts['page_options'])) {
    $page_opts = $pg_opts['page_options'];
} else {
    $page_opts = dt_metabox_portfolio_layout_options();
}
$add_data = dt_storage('add_data');
$layout = explode('-', $add_data['init_layout']);
if (isset($layout[1])) {
    $layout = $layout[1];
} else {
    $layout = 'list';
}
$first_class = '';
if (1 === dt_storage('post_is_first') && 'grid' != $layout) {
    $first_class = ' first';
    dt_storage('post_is_first', -1);
}
$pass_form = '';
$img_custom = 'onclick="jQuery(this).parents(\'.dt-hs-container\').find(\'.hidden-container a:first\').click(); return false;"';
if (post_password_required()) {
    $pass_form = get_the_password_form();
    $title_tag = '<h3><span class="%s">%s</span></h3>';
} else {
    $title_tag = '<h3><a class="%s" href="#"' . $img_custom . '>%s</a></h3>';
}
$type = isset($add_data['init_layout']) ? $add_data['init_layout'] : null;
$title = sprintf($title_tag, dt_portfolio_classes($type, 'head', false), get_the_title());
Beispiel #2
0
function dt_metabox_portfolio_layout_options_save($post_id)
{
    $box_name = 'dt_portfolio_layout_options';
    // verify if this is an auto save routine.
    // If it is our form has not been submitted, so we dont want to do anything
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times
    if (!isset($_POST[$box_name . '_nonce']) || !wp_verify_nonce($_POST[$box_name . '_nonce'], plugin_basename(__FILE__))) {
        return;
    }
    // Check permissions
    if (!current_user_can('edit_page', $post_id)) {
        return;
    }
    $mydata = null;
    $opts = dt_metabox_portfolio_layout_options();
    foreach ($opts as $name => $std) {
        $post_name = "{$box_name}_{$name}";
        if ('thumb_height' == $name && isset($_POST[$post_name])) {
            $mydata[$name] = empty($_POST[$post_name]) ? '' : intval($_POST[$post_name]);
            continue;
        }
        if (isset($_POST[$post_name])) {
            $mydata[$name] = esc_attr($_POST[$post_name]);
        }
    }
    update_post_meta($post_id, '_' . $box_name, $mydata);
}