Ejemplo n.º 1
0
function dt_metabox_benefits_options($post)
{
    $box_name = 'dt_benefits_options';
    $defaults = array('retina_image' => '', 'retina_image_w' => 0, 'retina_image_h' => 0, 'retina_image_id' => null);
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    // image
    $img_id = '<input type="hidden" value="' . $opts['retina_image_id'] . '" class="dt-uploader-textfield dt-get-id" name="' . $box_name . '_retina_image_id" />';
    // upload button
    $upload = dt_melement('link', array('description' => _x('Upload Image', 'backend benefits', LANGUAGE_ZONE), 'class' => 'dt-uploader-opener button-primary thickbox', 'href' => get_admin_url() . 'media-upload.php?post_id=' . $post->ID . '&type=image&TB_iframe=1&width=640&height=310'));
    // delete button
    $delete = dt_melement('link', array('description' => _x('Clear', 'backend benefits', LANGUAGE_ZONE), 'class' => 'dt-uploader-delete button', 'href' => '#'));
    ?>

	<p class="dt_switcher-box"><?php 
    if ($opts['retina_image_id']) {
        $img = wp_get_attachment_image_src($opts['retina_image_id'], 'medium');
        if ($img) {
            $size = wp_constrain_dimensions($img[1], $img[2], 266, 266);
            echo '<img class="attachment-266x266 dt-thumb" src="' . $img[0] . '" ' . image_hwstring($size[0], $size[1]) . ' />';
        }
    }
    echo $img_id . $upload . $delete;
    ?>
</p>
	
	<?php 
}
Ejemplo n.º 2
0
function dt_metabox_slider_layout_options($post = null)
{
    $box_name = 'dt_slider_layout_options';
    $defaults = array('slider' => 'nivo', 'display_on' => 'everywhere', 'auto_period' => 0, 'fs_height' => 0, 'fs_bot_spacing' => 0, 'fs_hide_content' => false, 'fs_hide_footer' => false, 'fs_overlay' => false, 'fs_header' => 'home');
    if (null === $post) {
        return $defaults;
    }
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    $sliders = array('nivo' => array('desc' => _x('Nivo Slider', 'backend slider layout', LANGUAGE_ZONE), 'img' => array('slider-nivo.png', 99, 55)), 'photo_stack' => array('desc' => _x('Photo Stack Slider', 'backend slider layout', LANGUAGE_ZONE), 'img' => array('slider-photostack.png', 99, 55)), 'fancy_tyle' => array('desc' => _x('Fancy Tile Slider', 'backend slider layout', LANGUAGE_ZONE), 'img' => array('slider-jfancytile.png', 99, 55)), 'carousel' => array('desc' => _x('Carousel Slider', 'backend slider layout', LANGUAGE_ZONE), 'img' => array('slider-carousel.png', 99, 55)), 'fullscreen_slider' => array('desc' => _x('Fullscreen slider', 'backend slider layout', LANGUAGE_ZONE), 'img' => array('fs-slideshow.png', 99, 55)));
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    echo '<p><strong>' . _x('Choose slider', 'backend slider layout', LANGUAGE_ZONE) . '</strong></p>';
    echo '<div class="dt_radio-img">';
    foreach ($sliders as $val => $data) {
        $image = '';
        if (isset($data['img'])) {
            $image = sprintf('<img src="%1$s/%3$s" class="hide-if-no-js" width="%4$s" height="%5$s" style="background-image:url(%1$s/%2$s)" /><br />', esc_url(get_template_directory_uri() . '/images/admin'), esc_attr($data['img'][0]), 'blank.gif', $data['img'][1], $data['img'][2]);
        }
        echo dt_melement('radio', array('name' => $box_name . '_slider', 'description' => $data['desc'], 'checked' => $val == $opts['slider'] ? true : false, 'value' => $val, 'wrap' => '<label>' . $image . '%1$s %2$s</label>'));
    }
    echo '</div>';
    ?>
	
	<script type="text/javascript">
		jQuery( document ).ready( function ( $ ) {
			$( '#dt_page_box-slideshows_options .dt_radio-img input[type="radio"]' ).on( 'click', function () {
				var cls = '.' +  $( this ).val().replace('_', '-');
				$( '#dt_page_box-slideshows_options p.dt-slider-hide' ).not( cls ).hide();
				$( '#dt_page_box-slideshows_options p' + cls ).show();
			} );
			
			$( '#dt_page_box-slideshows_options .dt_radio-img input[type="radio"]:checked' ).click();
		} );
	</script>
	
	<?php 
    echo '<p class="dt_switcher-box dt-slider-hide fullscreen-slider" style="display: none;"><strong>' . _x('Fullscreen slideshow options', 'backend slider layout', LANGUAGE_ZONE) . '</strong>';
    echo dt_melement('checkbox', array('name' => $box_name . '_fs_hide_content', 'description' => _x('hide content area', 'backend slider layout', LANGUAGE_ZONE), 'checked' => (bool) $opts['fs_hide_content'], 'wrap' => '<br /><label>%1$s %2$s</label>'));
    echo dt_melement('checkbox', array('name' => $box_name . '_fs_hide_footer', 'description' => _x('hide footer and bottom line', 'backend slider layout', LANGUAGE_ZONE), 'checked' => (bool) $opts['fs_hide_footer'], 'wrap' => '<br /><label>%1$s %2$s</label>'));
    echo dt_melement('checkbox', array('name' => $box_name . '_fs_overlay', 'description' => _x('show overlay mask', 'backend slider layout', LANGUAGE_ZONE), 'checked' => (bool) $opts['fs_overlay'], 'wrap' => '<br /><label>%1$s %2$s</label>'));
    echo dt_melement('text', array('name' => $box_name . '_fs_height', 'description' => _x('fixed slider height', 'backend slider layout', LANGUAGE_ZONE), 'value' => $opts['fs_height'], 'wrap' => '<br /><label>%1$s %2$s</label>'));
    echo dt_melement('text', array('name' => $box_name . '_fs_bot_spacing', 'description' => _x('slider bottom spacing', 'backend slider layout', LANGUAGE_ZONE), 'value' => $opts['fs_bot_spacing'], 'wrap' => '<br /><label>%1$s %2$s</label>'));
    echo '<br /><strong>' . _x('Page header style', 'backend obo slider', LANGUAGE_ZONE) . '</strong>';
    echo dt_melement('radio', array('class' => 'dt_switcher', 'name' => $box_name . '_fs_header', 'description' => _x('homepage', 'backend slider layout', LANGUAGE_ZONE), 'value' => 'home', 'checked' => 'home' == $opts['fs_header'], 'wrap' => '<label>%1$s %2$s</label>'));
    echo dt_melement('radio', array('class' => 'dt_switcher', 'name' => $box_name . '_fs_header', 'description' => _x('inner pages', 'backend slider layout', LANGUAGE_ZONE), 'value' => 'normal', 'checked' => 'normal' == $opts['fs_header'], 'wrap' => '<label>%1$s %2$s</label>'));
    echo '</p>';
    echo '<div class="dt_hr"></div>';
    echo '<p class="dt_switcher-box"><strong>' . _x('Display slideshow', 'backend slider layout', LANGUAGE_ZONE) . '</strong>';
    echo dt_melement('radio', array('name' => $box_name . '_display_on', 'description' => _x('everywhere', 'backend slider layout', LANGUAGE_ZONE), 'checked' => 'everywhere' == $opts['display_on'], 'value' => 'everywhere', 'wrap' => '<label>%1$s %2$s</label>'));
    echo dt_melement('radio', array('name' => $box_name . '_display_on', 'description' => _x('in desktop and tablet browsers only', 'backend slider layout', LANGUAGE_ZONE), 'checked' => 'desktop_tablets' == $opts['display_on'], 'value' => 'desktop_tablets', 'wrap' => '<label>%1$s %2$s</label>'));
    echo '</p>';
    echo '<div class="dt_hr"></div>';
    echo '<p class="dt_switcher-box"><strong>' . _x('Autoslide settings', 'backend slider layout', LANGUAGE_ZONE) . '</strong>';
    echo dt_melement('text', array('name' => $box_name . '_auto_period', 'description' => _x(' milliseconds (1 second = 1000 milliseconds; to disable autoslide leave this field blank or set it to "0")', 'backend slider layout', LANGUAGE_ZONE), 'value' => $opts['auto_period'], 'wrap' => '<label>%1$s %2$s</label>'));
}
Ejemplo n.º 3
0
function dt_m_optset_orderby($opts)
{
    /* orderby chapter */
    $p_orderby = array('ID' => _x('Order by ID', 'backend orderby', LANGUAGE_ZONE), 'author' => _x('Order by author', 'backend orderby', LANGUAGE_ZONE), 'title' => _x('Order by title', 'backend orderby', LANGUAGE_ZONE), 'date' => _x('Order by date', 'backend orderby', LANGUAGE_ZONE), 'modified' => _x('Order by modified', 'backend orderby', LANGUAGE_ZONE), 'rand' => _x('Order by rand', 'backend orderby', LANGUAGE_ZONE), 'menu_order' => _x('Order by menu', 'backend orderby', LANGUAGE_ZONE));
    $orderby = dt_melement('select', array('name' => $opts['box_name'] . '_orderby', 'selected' => $opts['current'], 'description' => '', 'options' => $p_orderby, 'wrap' => '%2$s%1$s'));
    $orderby->generate_id('orderby');
    echo '<p>';
    echo $orderby;
    echo '</p>';
}
Ejemplo n.º 4
0
function dt_core_metabox_footer_options($post)
{
    $box_name = 'dt_layout_footer_options';
    $defaults = array('footer' => 'show', 'sidebar' => 'sidebar_2', 'layout' => '1/4x4');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args($opts, $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    /*    
    	$footer_layouts = array(
    		'1/4x4' 		=> array( 'desc'  => '1/4 x 4' ),
           '1/4+1/2+1/4' 	=> array( 'desc'  => '1/4+1/2+1/4' ),
           '1/2+1/4+1/4' 	=> array( 'desc'  => '1/2+1/4+1/4' ),
           '1/4+1/4+1/2' 	=> array( 'desc'  => '1/4+1/4+1/2' ),
           '1/3x3' 		=> array( 'desc'  => '1/3 x 3' ),
           '1/3+2/3' 		=> array( 'desc'  => '1/3 + 2/3' ),
           '2/3+1/3' 		=> array( 'desc'  => '2/3 + 1/3' ),
           '1/2x3' 		=> array( 'desc'  => '1/2 x 2' )
       );
    */
    $footer = array('show' => array('desc' => _x('Yes', 'backend footer options', LANGUAGE_ZONE)), 'hide' => array('desc' => _x('No', 'backend footer options', LANGUAGE_ZONE)));
    echo '<p class="dt_switcher-box">';
    echo '<strong>' . _x('Show widgetized footer', 'backend footer options', LANGUAGE_ZONE) . '</strong>';
    foreach ($footer as $val => $data) {
        echo dt_melement('radio', array('name' => $box_name . '_footer', 'checked' => $val == $opts['footer'] ? true : false, 'description' => $data['desc'], 'value' => $val, 'wrap' => '<label class="dt_switcher">%1$s %2$s</label>', 'data' => 'data-name="dt_footer-show"'));
    }
    echo '</p>';
    echo '<div class="dt_footer-show dt_container hide-if-js"><div class="dt_hr"></div>';
    /*	echo '<p><strong>' . _x('Footer layout', 'backend footer options', LANGUAGE_ZONE) . '</strong></p>';
    	echo '<div class="dt_radio-img">';
    	
    	foreach( $footer_layouts as $val=>$data ) {
    			$image = '';
    			if( isset($data['img']) ) {
    				$image = sprintf(
    					'<img src="%1$s/%3$s" class="hide-if-no-js" width="88" height="71" style="background-image:url(%1$s/%2$s)" />',
    					esc_url(get_template_directory_uri() . '/images/admin'), esc_attr($data['img']), esc_attr('blank.gif') 
    				);
    			}
    			echo dt_melement( 'radio', array(
    				'name'          => $box_name . '_layout',
    				'checked'       => $val == $opts['layout']?true:false,
    				'description'   => $data['desc'],
    				'value'         => $val,
    				'wrap'			=> '<label>'.$image.'%1$s %2$s</label>'
    			) );
    		}
    	
    	echo '</div>';
    	echo '<div class="dt_hr"></div>';
     */
    dt_core_mb_draw_sidebars_list(array('box_name' => $box_name, 'sidebar_current' => $opts['sidebar'], 'before' => sprintf('<div class="dt_inside-box"><p><strong>%s</strong></p>', _x('Footer widgetized area', 'backend footer options', LANGUAGE_ZONE)), 'after' => '</div>'));
    echo '</div>';
}
Ejemplo n.º 5
0
function dt_metabox_albums_layout_options($post = null)
{
    $box_name = 'dt_albums_layout_options';
    $defaults = array('layout' => '2_col-list', 'thumb_height' => '', 'ppp' => '', 'orderby' => 'date', 'order' => 'DESC', 'show_title' => 'on', 'show_grid_text' => 'on', 'show_excerpt' => 'on', 'show_all_pages' => 'off', 'show_cat_filter' => 'on', 'show_layout_swtch' => 'on', 'show_category' => 'on');
    // if no post
    if (empty($post)) {
        return $defaults;
    }
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    $layout = array('2_col-list' => array('desc' => _x('Two cols list', 'backend albums layout', LANGUAGE_ZONE), 'img' => array('list-2cols.png', 72, 49)), '2_col-grid' => array('desc' => _x('Two cols grid', 'backend albums layout', LANGUAGE_ZONE), 'img' => array('grid-2cols.png', 72, 49)), '3_col-list' => array('desc' => _x('Three cols list', 'backend albums layout', LANGUAGE_ZONE), 'img' => array('list-3cols.png', 72, 49)), '3_col-grid' => array('desc' => _x('Three cols grid', 'backend albums layout', LANGUAGE_ZONE), 'img' => array('grid-3cols.png', 72, 49)));
    $radio_on_off = array('on' => array('desc' => _x('on', 'backend albums layout', LANGUAGE_ZONE)), 'off' => array('desc' => _x('off', 'backend albums layout', LANGUAGE_ZONE)));
    $adv_opts = array('show_title' => array('desc' => _x('Show projects titles', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_excerpt' => array('desc' => _x('Show projects excerpts', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_category' => array('desc' => _x('Show projects categories', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_grid_text' => array('desc' => _x('Show text areas in grid layout', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_all_pages' => array('desc' => _x('Show all pages in paginator', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_cat_filter' => array('desc' => _x('Show categories filter', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off), 'show_layout_swtch' => array('desc' => _x('Show layout switcher', 'backend portfolio layout', LANGUAGE_ZONE), 'ptrn' => $radio_on_off));
    echo '<p><strong>' . _x('Albums layout', 'backend albums layout', LANGUAGE_ZONE) . '</strong></p>';
    echo '<div class="dt_radio-img">';
    foreach ($layout as $val => $data) {
        $image = '';
        if (isset($data['img'])) {
            $image = sprintf('<img src="%1$s/%3$s" class="hide-if-no-js" width="%4$s" height="%5$s" style="background-image:url(%1$s/%2$s)" /><br />', esc_url(get_template_directory_uri() . '/images/admin'), esc_attr($data['img'][0]), 'blank.gif', $data['img'][1], $data['img'][2]);
        }
        echo dt_melement('radio', array('name' => $box_name . '_layout', 'description' => $data['desc'], 'checked' => $val == $opts['layout'] ? true : false, 'value' => $val, 'wrap' => '<label>' . $image . '%1$s %2$s</label>'));
    }
    echo '</div>';
    echo '<div class="dt_hr"></div>';
    echo '<p><strong>' . _x('Thumbnail height', 'backend albums layout', LANGUAGE_ZONE) . '</strong></p>';
    echo dt_melement('text', array('name' => $box_name . '_thumb_height', 'description' => _x('(in pixels). If not specified, default value will be taken.', 'backend albums layout', LANGUAGE_ZONE), 'value' => $opts['thumb_height'], 'wrap' => '<p>%1$s <em>%2$s</em></p>'));
    echo '<div class="dt_hr"></div>';
    echo dt_melement('text', array('name' => $box_name . '_ppp', 'description' => _x('Number of photo albums to display on one page', 'backend albums layout', LANGUAGE_ZONE), 'value' => $opts['ppp'], 'wrap' => '<p><strong>%2$s</strong></p><p>%1$s</p>'));
    echo '<div class="dt_hr"></div>';
    echo '<p><strong>' . _x('Ordering settings', 'backend albums layout', LANGUAGE_ZONE) . '</strong></p>';
    dt_core_mb_draw_order_options(array('box_name' => $box_name, 'order_current' => $opts['order'], 'orderby_current' => $opts['orderby']));
    printf('<div class="hide-if-no-js"><div class="dt_hr"></div><p><a href="#advanced-options" class="dt_advanced">
			<input type="hidden" name="%1$s" data-name="%1$s" value="hide" />
			<span class="dt_advanced-show">%2$s</span>
			<span class="dt_advanced-hide">%3$s</span> 
			%4$s
		</a></p></div>', 'dt_albums-advanced', _x('+ Show', 'backend albums layout', LANGUAGE_ZONE), _x('- Hide', 'backend albums layout', LANGUAGE_ZONE), _x('advanced settings', 'backend albums layout', LANGUAGE_ZONE));
    echo '<div class="dt_albums-advanced dt_container hide-if-js"><div class="dt_hr"></div>';
    $last_opt = end(array_keys($adv_opts));
    foreach ($adv_opts as $name => $data) {
        echo '<p class="dt_switcher-box"><strong>' . $data['desc'] . '</strong>';
        dt_core_mb_draw_radio_switcher("{$box_name}_{$name}", $opts[$name], $data['ptrn']);
        echo '</p>';
        if ($last_opt == $name) {
            continue;
        }
        echo '<div class="dt_hr"></div>';
    }
    echo '</div>';
}
Ejemplo n.º 6
0
function dt_metabox_obo_slider_options($post)
{
    $box_name = 'dt_obo_slider_options';
    $defaults = array('text_top' => 0, 'text_left' => 0, 'text_width' => 100, 'animation' => 'random', 'text_depth' => 'before');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    echo '<p><strong>' . _x('Size and positioning:', 'backend obo slider', LANGUAGE_ZONE) . '</strong><br />';
    echo dt_melement('text', array('name' => $box_name . '_text_left', 'description' => _x('Left (px)', 'backend obo slider', LANGUAGE_ZONE), 'value' => $opts['text_left'], 'wrap' => '<label><strong>%2$s</strong> %1$s</label>'));
    echo dt_melement('text', array('name' => $box_name . '_text_top', 'description' => _x('Top (px)', 'backend obo slider', LANGUAGE_ZONE), 'value' => $opts['text_top'], 'wrap' => '<label><strong>%2$s</strong> %1$s</label>'));
    echo dt_melement('text', array('name' => $box_name . '_text_width', 'description' => _x('Width (px)', 'backend obo slider', LANGUAGE_ZONE), 'value' => $opts['text_width'], 'wrap' => '<label><strong>%2$s</strong> %1$s</label>'));
    echo '</p>';
    echo '<div class="dt_hr"></div>';
    echo dt_melement('select', array('name' => $box_name . '_animation', 'description' => _x('Animation', 'backend obo slider', LANGUAGE_ZONE), 'wrap' => '<p><label>%2$s&nbsp;%1$s</label></p>', 'options' => array('fadeIn' => 'fadeIn', 'fadeInUp' => 'fadeInUp', 'fadeInDown' => 'fadeInDown', 'fadeInLeft' => 'fadeInLeft', 'fadeInRight' => 'fadeInRight', 'fadeInRight' => 'fadeInRight', 'bounceIn' => 'bounceIn', 'bounceInDown' => 'bounceInDown', 'bounceInUp' => 'bounceInUp', 'bounceInLeft' => 'bounceInLeft', 'bounceInRight' => 'bounceInRight', 'rotateInDownLeft' => 'rotateInDownLeft', 'rotateInDownRight' => 'rotateInDownRight', 'rotateInUpLeft' => 'rotateInUpLeft', 'rotateInUpRight' => 'rotateInUpRight', 'random' => 'random'), 'selected' => $opts['animation']));
    echo '<div class="dt_hr"></div>';
    echo '<p class="dt_switcher-box"><strong>' . _x('Display:', 'backend obo slider', LANGUAGE_ZONE) . '</strong>';
    echo dt_melement('radio', array('name' => $box_name . '_text_depth', 'description' => _x('Before images', 'backend obo slider', LANGUAGE_ZONE), 'value' => 'before', 'checked' => 'before' == $opts['text_depth'], 'wrap' => '<label>%1$s %2$s</label>'));
    echo dt_melement('radio', array('name' => $box_name . '_text_depth', 'description' => _x('After images', 'backend obo slider', LANGUAGE_ZONE), 'value' => 'after', 'checked' => 'after' == $opts['text_depth'], 'wrap' => '<label>%1$s %2$s</label>'));
    echo '</p>';
}
Ejemplo n.º 7
0
function dt_core_mb_draw_posts_list($name, $current, array $posts, $opts = array())
{
    if (empty($posts)) {
        return false;
    }
    global $wpdb;
    $defaults = array('wrap' => '%s', 'element_wrap' => '<div class="dt_list-item"><div class="dt_item-holder">%s</div></div>', 'taxonomy' => '');
    $opts = wp_parse_args($opts, $defaults);
    $data = dt_core_get_posts_thumbnails($posts);
    if ($data) {
        $thumbs_meta = $data['thumbs_meta'];
        $uploadsdir = wp_upload_dir();
    }
    $output = '';
    foreach ($posts as $item) {
        $str = '';
        $str .= dt_melement('checkbox', array('name' => sprintf($name, $item->ID), 'value' => $item->ID, 'checked' => isset($current[$item->ID]), 'wrap' => '<label class="dt_checkbox">%1$s</label>'));
        if ($thmb_img = dt_get_thumb_meta($thumbs_meta, 'thumbnail', $item->ID)) {
            $file_name = $thmb_img[0];
        } else {
            $args = array('numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $item->ID, 'post_status' => null, 'post_type' => 'attachment');
            $attachments = get_children($args);
            if ($attachments) {
                $att = current($attachments);
                if (!($img = wp_get_attachment_image_src($att->ID, 'thumbnail'))) {
                    $img = wp_get_attachment_image_src($att->ID, 'full');
                }
                $file_name = $img[0];
            }
        }
        $cover_style = 'dt_album-cover';
        $w = $h = 88;
        if ('dt_slider' == $item->post_type) {
            $cover_style = 'dt_slider-cover';
            $w = 98;
            $h = 68;
        }
        $str .= sprintf('<div class="dt_item-cover %s"><div><img src="%s" heught="%d" width="%d" /></div></div>', $cover_style, $file_name, $h, $w);
        // may be more complex and speede
        $atts = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%%' AND post_status != 'trash' AND post_parent = %d", $item->ID)));
        $str .= '<div class="dt_item-desc">';
        $pic_text = _x('no pictures', 'backend', LANGUAGE_ZONE);
        if ($atts == 1) {
            $pic_text = _x('1 picture', 'backend', LANGUAGE_ZONE);
        } elseif ($atts > 1) {
            $pic_text = sprintf(_x('%d pictures', 'backend', LANGUAGE_ZONE), $atts);
        }
        $str .= '<strong><a href="#">' . $item->post_title . '</a> (' . $pic_text . ')</strong>';
        $terms = get_the_terms($item->ID, $opts['taxonomy']);
        if (!is_wp_error($terms) && $terms) {
            $post_type = get_post_type($item->ID);
            $term_links = array();
            foreach ($terms as $term) {
                $link = get_term_link($term, $opts['taxonomy']);
                $link = str_replace(site_url('/'), site_url('/') . 'wp-admin/edit.php', $link);
                $link = add_query_arg('post_type', $post_type, $link);
                $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
            }
            if (empty($term_links)) {
                $term_links[] = 'none';
            }
            $str .= '<p><strong>' . _x('Categories: ', 'backend', LANGUAGE_ZONE) . '</strong>' . implode(', ', $term_links) . '</p>';
        } else {
            $str .= '<p></p>';
        }
        $str .= '<strong>' . _x('Date: ', 'backend', LANGUAGE_ZONE) . '</strong>';
        $str .= '<abbr title="' . get_the_date(get_option('date_format')) . '">' . get_the_date(get_option('date_format')) . '</abbr>';
        $str .= '<div class="row-actions">';
        $str .= sprintf('<span class="edit"><a title="%s" href="%s">%s</a></span>', _x('Edit this item', 'backend', LANGUAGE_ZONE), esc_url(get_admin_url() . 'post.php?post=' . $item->ID . '&action=edit'), _x('Edit', 'backend', LANGUAGE_ZONE));
        if (current_user_can('edit_post', $item->ID)) {
            $str .= sprintf(' | <span class="trash"><a title="%s" href="%s">%s</a></span>', _x('Move this item to the Trash', 'backend', LANGUAGE_ZONE), wp_nonce_url(site_url() . "/wp-admin/post.php?action=trash&post=" . $item->ID, 'trash-' . $item->post_type . '_' . $item->ID), _x('Trash', 'backend', LANGUAGE_ZONE));
        }
        $str .= '</div>';
        $str .= '</div>';
        $str = sprintf($opts['element_wrap'], $str);
        $output .= $str;
    }
    printf($opts['wrap'], $output);
}
Ejemplo n.º 8
0
function dt_catalog_mbox_related($post)
{
    $box_name = 'dt_catalog_related';
    $defaults = array('show_related' => false, 'show_desc' => false, 'show_title' => false, 'related' => 'same');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    // show related
    $show_related = dt_melement('checkbox', array('name' => $box_name . '_show_related', 'checked' => $opts['show_related'], 'description' => _x(' Show related Catalog items', 'backend catalog', LANGUAGE_ZONE), 'class' => 'dt_admin_show_related'));
    $show_desc = dt_melement('checkbox', array('name' => $box_name . '_show_desc', 'checked' => $opts['show_desc'], 'description' => _x(' Show related Catalog items description', 'backend catalog', LANGUAGE_ZONE)));
    $show_title = dt_melement('checkbox', array('name' => $box_name . '_show_title', 'checked' => $opts['show_title'], 'description' => _x(' Show related Catalog items title', 'backend catalog', LANGUAGE_ZONE)));
    // related category
    $related_same = dt_melement('radio', array('name' => $box_name . '_related', 'checked' => 'same' == $opts['related'] ? true : false, 'description' => _x(' From the same category', 'backend catalog', LANGUAGE_ZONE), 'value' => 'same', 'class' => 'dt_admin_related_radio'));
    $related_other = dt_melement('radio', array('name' => $box_name . '_related', 'checked' => is_array($opts['related']), 'description' => _x(' Choose category(s)', 'backend catalog', LANGUAGE_ZONE), 'value' => 'other', 'class' => 'dt_admin_related_radio dt_admin_other_cat'));
    // output
    echo '<p>' . $show_related . '</p>';
    echo '<div class="dt_admin_show_related_box" style="display: none;">';
    echo '<p>' . $show_desc . '</p>';
    echo '<p>' . $show_title . '</p>';
    echo '<p>' . $related_same . '<br/>' . $related_other . '</p>';
    echo '<div class="dt_admin_cat_list" style="display: none;">';
    // terms
    $post_type_terms = get_terms('dt_catalog_category', 'hide_empty=0');
    $selected_terms = is_array($opts['related']) ? $opts['related'] : array();
    foreach ($post_type_terms as $term) {
        echo dt_melement('checkbox', array('name' => $box_name . '_related_terms[]', 'checked' => in_array($term->term_id, $selected_terms), 'description' => $term->name, 'desc_wrap' => '%2$s', 'value' => $term->term_id, 'wrap' => '<label style="display: block;">%1$s%2$s</label>'));
    }
    unset($term);
    echo '</div>';
    echo '</div>';
}
Ejemplo n.º 9
0
/**
 * Generates the options fields that are used in the form.
 */
function optionsframework_fields()
{
    global $allowedtags;
    $optionsframework_settings = get_option('optionsframework');
    // Get the theme name so we can display it up top
    $wp_ver = explode('.', get_bloginfo('version'));
    $wp_ver = array_map('intval', $wp_ver);
    $themename = wp_get_theme();
    $themename = $themename->name;
    // Gets the unique option id
    if (isset($optionsframework_settings['id'])) {
        $option_name = $optionsframework_settings['id'];
    } else {
        $option_name = 'optionsframework';
    }
    $settings = get_option($option_name);
    $options = optionsframework_options();
    // filter options for current page
    $options = array_filter($options, 'optionsframework_options_for_page_filter');
    $counter = 0;
    $menu = '';
    $output = '';
    foreach ($options as $value) {
        $counter++;
        $val = '';
        $select_value = '';
        $checked = '';
        // Wrap all options
        if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') {
            // Keep all ids lowercase with no spaces
            $value['id'] = preg_replace('/(\\W!-)/', '', strtolower($value['id']));
            $id = 'section-' . $value['id'];
            $class = 'section ';
            if (isset($value['type'])) {
                $class .= ' section-' . $value['type'];
            }
            if (isset($value['class'])) {
                $class .= ' ' . $value['class'];
            }
            $output .= '<div id="' . esc_attr($id) . '" class="' . esc_attr($class) . '">' . "\n";
            if (isset($value['name'])) {
                $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
            }
            $output .= '<div class="option">' . "\n";
            $explain_value = '';
            if (isset($value['desc'])) {
                $explain_value = $value['desc'];
            }
            $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            $output .= '<div class="controls">' . "\n";
        }
        // Set default value to $val
        if (isset($value['std'])) {
            $val = $value['std'];
        }
        // If the option is already saved, ovveride $val
        if ($value['type'] != 'heading' && $value['type'] != 'info' && $value['type'] != 'page') {
            if (isset($value['id']) && isset($settings[$value['id']])) {
                $val = $settings[$value['id']];
                // Striping slashes of non-array options
                if (!is_array($val)) {
                    $val = stripslashes($val);
                }
            }
        }
        switch ($value['type']) {
            // Basic text input
            case 'text':
                $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : '';
                $output .= '<input id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" type="text" value="' . esc_attr($val) . '"' . $maxlength . ' />';
                break;
                // Textarea
            // Textarea
            case 'textarea':
                $cols = '8';
                $ta_value = '';
                if (isset($value['options'])) {
                    $ta_options = $value['options'];
                    if (isset($ta_options['cols'])) {
                        $cols = $ta_options['cols'];
                    } else {
                        $cols = '8';
                    }
                }
                $val = stripslashes($val);
                $output .= '<textarea id="' . esc_attr($value['id']) . '" class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" cols="' . esc_attr($cols) . '" rows="24">' . esc_textarea($val) . '</textarea>';
                break;
                // Select Box
            // Select Box
            case 'select':
                $output .= '<select class="of-input" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '">';
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    if ($val != '') {
                        if ($val == $key) {
                            $selected = ' selected="selected"';
                        }
                    }
                    $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
                }
                $output .= '</select>';
                break;
                // Radio Box
            // Radio Box
            case "radio":
                $name = $option_name . '[' . $value['id'] . ']';
                foreach ($value['options'] as $key => $option) {
                    $id = $option_name . '-' . $value['id'] . '-' . $key;
                    $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr($name) . '" id="' . esc_attr($id) . '" value="' . esc_attr($key) . '" ' . checked($val, $key, false) . ' /><label for="' . esc_attr($id) . '">' . esc_html($option) . '</label>';
                }
                break;
                // Image Selectors
            // Image Selectors
            case "images":
                $name = $option_name . '[' . $value['id'] . ']';
                $dir = get_template_directory_uri();
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    $checked = '';
                    if ($val != '') {
                        if ($val == $key) {
                            $selected = ' of-radio-img-selected';
                            $checked = ' checked="checked"';
                        }
                    }
                    $img = $dir . $option;
                    $output .= '<input type="radio" id="' . esc_attr($value['id'] . '_' . $key) . '" class="of-radio-img-radio" value="' . esc_attr($key) . '" name="' . esc_attr($name) . '" ' . $checked . ' />';
                    //				$output .= '<div class="of-radio-img-label" syle="display: none;">' . esc_html( $key ) . '</div>';
                    $output .= '<img src="' . esc_url($img) . '" alt="' . $option . '" class="of-radio-img-img' . $selected . '" onclick="document.getElementById(\'' . esc_attr($value['id'] . '_' . $key) . '\').checked=true;" />';
                }
                break;
                // Checkbox
            // Checkbox
            case "checkbox":
                $classes = array();
                $classes[] = 'checkbox';
                $classes[] = 'of-input';
                if (isset($value['options']['java_hide']) && $value['options']['java_hide']) {
                    $classes[] = 'of-js-hider';
                } else {
                    if (isset($value['options']['java_hide_global']) && $value['options']['java_hide_global']) {
                        $classes[] = 'of-js-hider-global';
                    }
                }
                $classes = implode(' ', $classes);
                $output .= '<input id="' . esc_attr($value['id']) . '" class="' . $classes . '" type="checkbox" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" ' . checked($val, 1, false) . ' />';
                break;
                // Multicheck
            // Multicheck
            case "multicheck":
                foreach ($value['options'] as $key => $option) {
                    $checked = '';
                    $label = $option;
                    $option = preg_replace('/\\W/', '', strtolower($key));
                    $id = $option_name . '-' . $value['id'] . '-' . $option;
                    $name = $option_name . '[' . $value['id'] . '][' . $option . ']';
                    if (isset($val[$option])) {
                        $checked = checked($val[$option], 1, false);
                    }
                    $output .= '<input id="' . esc_attr($id) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr($name) . '" ' . $checked . ' /><label for="' . esc_attr($id) . '">' . esc_html($label) . '</label>';
                }
                break;
                // Color picker
            // Color picker
            case "color":
                $output .= '<div id="' . esc_attr($value['id'] . '_picker') . '" class="colorSelector"><div style="' . esc_attr('background-color:' . $val) . '"></div></div>';
                $output .= '<input class="of-color" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . esc_attr($value['id']) . '" type="text" value="' . esc_attr($val) . '" />';
                break;
                // Uploader
            // Uploader
            case "upload":
                $mode = isset($value['mode']) ? $value['mode'] : 'full';
                $output .= optionsframework_medialibrary_uploader($value['id'], $val, $mode);
                // New AJAX Uploader using Media Library
                break;
                // Typography
            // Typography
            case 'typography':
                $typography_stored = $val;
                // Font Size
                $output .= '<select class="of-typography of-typography-size" name="' . esc_attr($option_name . '[' . $value['id'] . '][size]') . '" id="' . esc_attr($value['id'] . '_size') . '">';
                for ($i = 9; $i < 71; $i++) {
                    $size = $i . 'px';
                    $output .= '<option value="' . esc_attr($size) . '" ' . selected($typography_stored['size'], $size, false) . '>' . esc_html($size) . '</option>';
                }
                $output .= '</select>';
                // Font Face
                $output .= '<select class="of-typography of-typography-face" name="' . esc_attr($option_name . '[' . $value['id'] . '][face]') . '" id="' . esc_attr($value['id'] . '_face') . '">';
                $faces = of_recognized_font_faces();
                foreach ($faces as $key => $face) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['face'], $key, false) . '>' . esc_html($face) . '</option>';
                }
                $output .= '</select>';
                // Font Weight
                $output .= '<select class="of-typography of-typography-style" name="' . $option_name . '[' . $value['id'] . '][style]" id="' . $value['id'] . '_style">';
                /* Font Style */
                $styles = of_recognized_font_styles();
                foreach ($styles as $key => $style) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($typography_stored['style'], $key, false) . '>' . $style . '</option>';
                }
                $output .= '</select>';
                // Font Color
                $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $typography_stored['color']) . '"></div></div>';
                $output .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($typography_stored['color']) . '" />';
                break;
                // Background
            // Background
            case 'background':
                $background = $val;
                // Background Color
                $output .= '<div id="' . esc_attr($value['id']) . '_color_picker" class="colorSelector"><div style="' . esc_attr('background-color:' . $background['color']) . '"></div></div>';
                $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr($option_name . '[' . $value['id'] . '][color]') . '" id="' . esc_attr($value['id'] . '_color') . '" type="text" value="' . esc_attr($background['color']) . '" />';
                // Background Image - New AJAX Uploader using Media Library
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
                $output .= optionsframework_medialibrary_uploader($value['id'], $background['image'], null, '', 0, 'image');
                $class = 'of-background-properties';
                if ('' == $background['image']) {
                    $class .= ' hide';
                }
                $output .= '<div class="' . esc_attr($class) . '">';
                // Background Repeat
                $output .= '<select class="of-background of-background-repeat" name="' . esc_attr($option_name . '[' . $value['id'] . '][repeat]') . '" id="' . esc_attr($value['id'] . '_repeat') . '">';
                $repeats = of_recognized_background_repeat();
                foreach ($repeats as $key => $repeat) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['repeat'], $key, false) . '>' . esc_html($repeat) . '</option>';
                }
                $output .= '</select>';
                // Background Position
                $output .= '<select class="of-background of-background-position" name="' . esc_attr($option_name . '[' . $value['id'] . '][position]') . '" id="' . esc_attr($value['id'] . '_position') . '">';
                $positions = of_recognized_background_position();
                foreach ($positions as $key => $position) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['position'], $key, false) . '>' . esc_html($position) . '</option>';
                }
                $output .= '</select>';
                // Background Attachment
                $output .= '<select class="of-background of-background-attachment" name="' . esc_attr($option_name . '[' . $value['id'] . '][attachment]') . '" id="' . esc_attr($value['id'] . '_attachment') . '">';
                $attachments = of_recognized_background_attachment();
                foreach ($attachments as $key => $attachment) {
                    $output .= '<option value="' . esc_attr($key) . '" ' . selected($background['attachment'], $key, false) . '>' . esc_html($attachment) . '</option>';
                }
                $output .= '</select>';
                $output .= '</div>';
                break;
                // Info
            // Info
            case "info":
                $class = 'section';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                $output .= '<div class="' . esc_attr($class) . '">' . "\n";
                if (isset($value['name'])) {
                    $output .= '<h4 class="heading">' . esc_html($value['name']) . '</h4>' . "\n";
                }
                if ($value['desc']) {
                    $output .= apply_filters('of_sanitize_info', $value['desc']) . "\n";
                }
                $output .= '<div class="clear"></div></div>' . "\n";
                break;
                // Editor
            // Editor
            case 'editor':
                $output .= '<div class="explain">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
                echo $output;
                $textarea_name = esc_attr($option_name . '[' . $value['id'] . ']');
                $default_editor_settings = array('textarea_name' => $textarea_name, 'media_buttons' => false, 'tinymce' => array('plugins' => 'wordpress'));
                $editor_settings = array();
                if (isset($value['settings'])) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor($val, $value['id'], $editor_settings);
                $output = '';
                break;
                // Block begin
            // Block begin
            case "block_begin":
                $class = 'section';
                $id = '';
                if (isset($value['type'])) {
                    $class .= ' section-' . $value['type'];
                }
                if (isset($value['class'])) {
                    $class .= ' ' . $value['class'];
                }
                if (isset($value['id'])) {
                    $id .= ' id="' . esc_attr($value['id']) . '"';
                }
                $output .= '<div' . $id . ' class="widgets-sortables ' . esc_attr($class) . '">' . "\n";
                if (isset($value['name']) && !empty($value['name'])) {
                    $output .= '<div class="sidebar-name"><h3>' . esc_html($value['name']) . '</h3></div>' . "\n";
                }
                break;
                // Block End
            // Block End
            case "block_end":
                $output .= '</div>' . "\n" . '<!-- block_end -->';
                break;
                // Heading for Navigation
            // Heading for Navigation
            case "heading":
                if ($counter >= 2) {
                    $output .= '</div>' . "\n";
                }
                $jquery_click_hook = preg_replace('/\\W/', '', strtolower($value['name']));
                $jquery_click_hook = "of-option-" . $jquery_click_hook;
                $menu .= '<a id="' . esc_attr($jquery_click_hook) . '-tab" class="nav-tab" title="' . esc_attr($value['name']) . '" href="' . esc_attr('#' . $jquery_click_hook) . '">' . esc_html($value['name']) . '</a>';
                $output .= '<div class="group" id="' . esc_attr($jquery_click_hook) . '">';
                //$output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
                break;
            case "page":
                break;
            case "button":
                $output .= '<input type="button" id="' . esc_attr($value['id']) . '" class="button" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" value="' . esc_attr($value['options']['title']) . '">';
                break;
                // fields generator
            // fields generator
            case "fields_generator":
                if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) {
                    break;
                }
                $del_link = '<div class="submitbox"><a href="#" class="of_fields_gen_del submitdelete">' . _x('Delete', 'backend fields', LANGUAGE_ZONE) . '</a></div>';
                $output .= '<ul class="of_fields_gen_list">';
                // saved elements
                if (is_array($val)) {
                    $i = 0;
                    // create elements
                    foreach ($val as $index => $field) {
                        $block = $b_title = '';
                        // use patterns
                        foreach ($value['options']['fields'] as $name => $data) {
                            // if only_for list isset and current index not in the list - skip this element
                            if (isset($data['only_for']) && is_array($data['only_for']) && !in_array($index, $data['only_for'])) {
                                continue;
                            }
                            // checked если поле присутствует в записи, если нет поля value в шаблоне
                            // или если оно есть и равно значению поля в записи
                            $checked = false;
                            if (isset($field[$name]) && (!isset($data['value']) || isset($data['value']) && $data['value'] == $field[$name])) {
                                $checked = true;
                            }
                            // get the title
                            if (isset($data['class']) && 'of_fields_gen_title' == $data['class']) {
                                $b_title = $field[$name];
                            }
                            $el_args = array('name' => sprintf('%s[%s][%d][%s]', $option_name, $value['id'], $index, $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'value' => 'checkbox' == $data['type'] ? '' : $field[$name], 'checked' => $checked);
                            if (isset($data['desc_wrap'])) {
                                $el_args['desc_wrap'] = $data['desc_wrap'];
                            }
                            if (isset($data['wrap'])) {
                                $el_args['wrap'] = $data['wrap'];
                            }
                            if (isset($data['style'])) {
                                $el_args['style'] = $data['style'];
                            }
                            // create form elements
                            $element = dt_melement($data['type'], $el_args);
                            $block .= $element;
                        }
                        unset($data);
                        $output .= '<li class="nav-menus-php">';
                        $output .= '<div class="of_fields_gen_title menu-item-handle" data-index="' . $index . '"><span class="dt-menu-item-title">' . esc_attr($b_title) . '</span>';
                        $output .= '<span class="item-controls"><a title="' . _x('Edit Widgetized Area', 'backend fields', LANGUAGE_ZONE) . '" class="item-edit"></a></span></div>';
                        $output .= '<div class="of_fields_gen_data menu-item-settings description" style="display: none;">' . $block;
                        if ($index > 7) {
                            $output .= $del_link;
                        }
                        $output .= '</div>';
                        $output .= '</li>';
                        $i++;
                    }
                    unset($field);
                }
                $output .= '</ul>';
                // control panel
                $output .= '<div class="of_fields_gen_controls">';
                // use pattern
                foreach ($value['options']['fields'] as $name => $data) {
                    if (isset($data['only_for'])) {
                        continue;
                    }
                    $el_args = array('name' => sprintf('%s[%s][%s]', $option_name, $value['id'], $name), 'description' => isset($data['description']) ? $data['description'] : '', 'class' => isset($data['class']) ? $data['class'] : '', 'checked' => isset($data['checked']) ? $data['checked'] : false);
                    if (isset($data['desc_wrap'])) {
                        $el_args['desc_wrap'] = $data['desc_wrap'];
                    }
                    if (isset($data['wrap'])) {
                        $el_args['wrap'] = $data['wrap'];
                    }
                    if (isset($data['style'])) {
                        $el_args['style'] = $data['style'];
                    }
                    if (isset($data['value'])) {
                        $el_args['value'] = $data['value'];
                    }
                    // create form
                    $element = dt_melement($data['type'], $el_args);
                    $output .= $element;
                }
                unset($data);
                // add button
                $button = dt_melement('button', array('name' => $option_name . '[' . $value['id'] . '][add]', 'title' => isset($value['options']['button']['title']) ? $value['options']['button']['title'] : _x('Add', 'backend fields button', LANGUAGE_ZONE), 'class' => 'of_fields_gen_add'));
                $output .= $button;
                $output .= '</div>';
                break;
                // Social icons
            // Social icons
            case 'social_icon':
                if (!isset($value['options']['fields']) || !is_array($value['options']['fields'])) {
                    continue;
                }
                $w = $h = '20';
                if (!empty($value['options']['ico_width'])) {
                    $w = intval($value['options']['ico_width']);
                }
                if (!empty($value['options']['ico_height'])) {
                    $h = intval($value['options']['ico_height']);
                }
                $ico_size = sprintf('width: %dpx;height: %dpx;', $w, $h);
                foreach ($value['options']['fields'] as $src => $desc) {
                    $clear_desc = strtolower(str_replace(' ', '', $desc));
                    $name = sprintf('%s[%s][%s]', $option_name, $value['id'], $clear_desc);
                    $soc_link = isset($val[$clear_desc]) && isset($val[$clear_desc]['link']) ? $val[$clear_desc]['link'] : '';
                    $output .= '<div class="of-soc-image" style="background: url( ' . esc_attr(get_template_directory_uri() . $src) . ' ) no-repeat 0 0; vertical-align: middle; margin-right: 5px; display: inline-block;' . $ico_size . '" title="' . esc_attr($desc) . '"></div>';
                    $maxlength = isset($value['maxlength']) ? ' maxlength="' . $value['maxlength'] . '"' : '';
                    $output .= '<input class="of-input" name="' . esc_attr($name . '[link]') . '" type="text" value="' . esc_attr($soc_link) . '"' . $maxlength . ' style="display: inline-block; width: 300px; vertical-align: middle;" />';
                    $output .= '<input name="' . esc_attr($name . '[src]') . '" type="hidden" value="' . esc_attr($src) . '" /> <br>';
                }
                break;
            case 'slider':
                $output .= '<div class="of-slider"></div>';
                $slider_opts = array('max' => isset($value['options']['max']) ? $value['options']['max'] : 100, 'min' => isset($value['options']['min']) ? $value['options']['min'] : 0, 'step' => isset($value['options']['step']) ? $value['options']['step'] : 1, 'value' => isset($val) ? $val : 0);
                $str = '';
                foreach ($slider_opts as $name => $val) {
                    $str .= ' data-' . $name . '="' . esc_attr($val) . '"';
                }
                $output .= '<input type="text" class="of-slider-value"' . $str . ' name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" readonly />';
                break;
            case 'js_hide_begin':
                $output .= '<div class="of-js-hide hide-if-js">';
                break;
            case 'js_hide_end':
                $output .= '</div>';
                break;
                // beta feature
            // beta feature
            case 'web_fonts':
                $id = esc_attr($value['id']);
                $output .= '<select class="of-input dt-web-fonts" name="' . esc_attr($option_name . '[' . $value['id'] . ']') . '" id="' . $id . '">';
                foreach ($value['options'] as $key => $option) {
                    $selected = '';
                    if ($val != '' && $val == $key) {
                        $selected = ' selected="selected"';
                    }
                    $output .= '<option' . $selected . ' value="' . esc_attr($key) . '">' . esc_html($option) . '</option>';
                }
                $output .= '</select>';
                $output .= '<div class="dt-web-fonts-preview"><iframe id="' . $id . '_preview"></iframe></div>';
                // refresh button
                $output .= '<a href="#" class="dt-web-fonts-refresh button-secondary" onclick="dtWebfontsRefresh( \'' . $id . '\', \'' . wp_create_nonce('dt_webfonts_refresh') . '\' ); return false;">' . _x('refresh', 'backend', LANGUAGE_ZONE) . '</a>';
                $output .= '<img src="' . get_admin_url() . '/images/wpspin_light.gif" class="dt-web-fonts-refresh-ajax-loading" id="' . $id . '-ajax-loading" alt="">';
                // function located in options-functions.php
                $output .= dt_get_google_fonts_errors();
                break;
        }
        if ($value['type'] != "block_begin" && $value['type'] != "block_end" && $value['type'] != "heading" && $value['type'] != "info" && $value['type'] != "page" && $value['type'] != 'js_hide_begin' && $value['type'] != 'js_hide_end') {
            if ($value['type'] != "checkbox") {
                $output .= '<br/>';
            }
            $explain_value = '';
            if (isset($value['explain'])) {
                $explain_value = $value['explain'];
                $output .= '<div class="dt-option-info">' . wp_kses($explain_value, $allowedtags) . '</div>' . "\n";
            }
            $output .= '</div>' . "\n";
            $output .= '<div class="clear"></div></div></div>' . "\n";
        }
    }
    $output .= '</div>';
    return array($output, $menu);
}
Ejemplo n.º 10
0
function dt_metabox_video_options($post)
{
    $box_name = 'dt_video_options';
    $defaults = array('video_link' => '', 'height' => '', 'width' => '');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    // video link
    $link = dt_melement('text', array('name' => $box_name . '_video_link', 'class' => 'widefat', 'description' => _x('Video link:', 'backend video', LANGUAGE_ZONE), 'wrap' => '%2$s%1$s', 'value' => $opts['video_link']));
    // upload button
    // height
    $height = dt_melement('text', array('name' => $box_name . '_height', 'description' => _x(' Set video HEIGHT', 'backend video', LANGUAGE_ZONE), 'value' => $opts['height'], 'style' => 'width: 40px;'));
    $height->generate_id('v_height');
    // width
    $width = dt_melement('text', array('name' => $box_name . '_width', 'description' => _x(' Set video WIDTH', 'backend video', LANGUAGE_ZONE), 'value' => $opts['width'], 'style' => 'width: 40px;'));
    $width->generate_id('v_width');
    echo '<p>' . $link . '</p>';
    echo '<p>' . $width . '<br/>' . $height . '</p>';
}
Ejemplo n.º 11
0
function dt_metabox_testimonials_options($post)
{
    $box_name = 'dt_meta_testimonials_options';
    $defaults = array('content_position' => 'top', 'orderby' => 'date', 'order' => 'DESC', 'ppp' => '');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    $radio_top_bottom = array('top' => array('desc' => _x('Top', 'backend testimonials layout', LANGUAGE_ZONE)), 'bottom' => array('desc' => _x('Bottom', 'backend testimonials layout', LANGUAGE_ZONE)));
    $ppp = dt_melement('text', array('name' => $box_name . '_ppp', 'value' => $opts['ppp'], 'wrap' => '%1$s'));
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    echo '<p class="dt_switcher-box"><strong>' . _x('Content position', 'backend testimonials', LANGUAGE_ZONE) . '</strong>';
    dt_core_mb_draw_radio_switcher($box_name . '_content_position', $opts['content_position'], $radio_top_bottom);
    echo '</p>';
    echo '<p><strong>' . _x('Number of posts to display on one page', 'backend testimonials', LANGUAGE_ZONE) . '</strong></p>';
    echo '<p>' . $ppp . '</p>';
    echo '<div class="dt_hr"></div>';
    echo '<p><strong>' . _x('Ordering settings', 'backend blog', LANGUAGE_ZONE) . '</strong></p>';
    dt_core_mb_draw_order_options(array('box_name' => $box_name, 'order_current' => $opts['order'], 'orderby_current' => $opts['orderby']));
}
Ejemplo n.º 12
0
function dt_metabox_post_options($post)
{
    $box_name = 'dt_meta_post_options';
    $defaults = array('hide_thumb' => 'false');
    $opts = get_post_meta($post->ID, '_' . $box_name, true);
    $opts = wp_parse_args(maybe_unserialize($opts), $defaults);
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), $box_name . '_nonce');
    $hide_desc_el = dt_melement('checkbox', array('name' => $box_name . '_hide_thumb', 'checked' => $opts['hide_thumb'], 'description' => _x('Hide featured image on the Post page', 'backend blog', LANGUAGE_ZONE), 'wrap' => '<label>%1$s&nbsp;%2$s</label>'));
    echo '<p>' . $hide_desc_el . '</p>';
}