Exemple #1
0
function nb_fields_builder($field, $value = '')
{
    $data = nb_types_opt($field);
    $pre_code = $data['type'] == 'textarea' ? '<div class="nb_full_field nb_f_' . $field . '_wrap">' : '<div class="nb_field nb_f_' . $field . '_wrap">';
    $pre_code .= '<label>' . $data['label'] . '</label>';
    $def_val = isset($data['def']) ? $data['def'] : '';
    if (empty($value) && $value !== '0' && isset($def_val)) {
        $value = $def_val;
    }
    $optional = isset($data['optional']) ? 'nb_optional_f' : '';
    $class = str_replace('[]', '', $field);
    switch ($data['type']) {
        case 'color':
            $code = '
			<div class="lcwp_colpick">
				<span class="lcwp_colblock" style="background-color: ' . $value . ';"></span>
				<input type="text" name="' . $field . '" value="' . $value . '" class="nb_f_' . $class . ' ' . $optional . '" />
			</div>';
            break;
        case 'slider':
            $code = '
			<div class="lcwp_slider" step="' . $data['step'] . '" max="' . $data['max_val'] . '" min="' . $data['min_val'] . '"></div>
			<input type="text" value="' . $value . '" name="' . $field . '" class="lcwp_slider_input nb_f_' . $class . ' ' . $optional . '" />
			<span>' . $data['value'] . '</span>';
            break;
        case 'select':
            if (isset($data['multiple'])) {
                $multiple = 'multiple="multiple"';
                $mfn = '[]';
            } else {
                $multiple = '';
                $mfn = '';
            }
            $options = '';
            foreach ($data['opts'] as $k => $v) {
                if (is_array($value)) {
                    $sel = in_array($k, $value) ? 'selected="selected"' : '';
                } else {
                    $sel = $value == $k ? 'selected="selected"' : '';
                }
                $options .= '<option value="' . $k . '" ' . $sel . '>' . $v . '</option>';
            }
            $code = '
			<select name="' . $field . $mfn . '" class="lcweb-chosen nb_f_' . $class . ' ' . $optional . '" ' . $multiple . ' data-placeholder="" tabindex="2">
				' . $options . '
			</select> ';
            break;
        case 'bool':
            $sel = $value == 1 ? 'checked="checked"' : '';
            $code = '<input type="checkbox" value="1" name="' . $field . '" class="ip-checkbox nb_f_' . $class . '" ' . $sel . ' />';
            break;
        case 'textarea':
            $code = '<textarea name="' . $field . '" class="nb_f_' . $field . ' ' . $optional . '">' . $value . '</textarea>';
            break;
        case 'padding_arr':
            if (!is_array($value)) {
                $value = array('', '', '', '');
            }
            $code = '
			<input type="text" value="' . $value[0] . '" name="' . $field . '[]" class="lcwp_slider_input nb_f_' . $class . ' ' . $optional . '" maxlength="2" />
			<input type="text" value="' . $value[1] . '" name="' . $field . '[]" class="lcwp_slider_input nb_f_' . $class . ' ' . $optional . '" maxlength="2" />
			<input type="text" value="' . $value[2] . '" name="' . $field . '[]" class="lcwp_slider_input nb_f_' . $class . ' ' . $optional . '" maxlength="2" />
			<input type="text" value="' . $value[3] . '" name="' . $field . '[]" class="lcwp_slider_input nb_f_' . $class . ' ' . $optional . '" maxlength="2" />
			<span>' . $data['value'] . '</span>';
            break;
        default:
            // text
            $code = '<input type="text" name="' . $field . '" class="nb_f_' . $class . ' ' . $optional . '" value="' . nb_sanitize_input($value) . '" />';
            break;
    }
    return $pre_code . $code . '</div>';
}
Exemple #2
0
			
			jQuery.post(ajaxurl, data, function(response) {
				jQuery('.nb_sources').prepend(response);
				nb_is_acting = false;
				
				nb_async_form();
				$loader.empty();
			});
		}
	});
	
	
	// remove news source
	jQuery('body').delegate('.nb_sources h4 .lcwp_del_row', 'click', function() {
		if(confirm('<?php 
echo nb_sanitize_input(__('Remove news source?', 'nb_ml'));
?>
')) {
			var $subj = jQuery(this).parents('.nb_type_block');
			$subj.slideUp(function() {
				$subj.remove();
			});
		}
	});

	
	// preview box
	jQuery('body').delegate('#preview_box', "click", function() {
		var url = jQuery(this).attr('pv-url');
		var char = (url.indexOf('?') != -1) ? '&' : '?';
		
Exemple #3
0
function nb_news_opt_box()
{
    include_once NB_DIR . '/functions.php';
    global $post;
    ?>
    <div class="lcwp_mainbox_meta">
      <table class="widefat lcwp_table lcwp_metabox_table">
        <tr>
          <td class="lcwp_field_td">
              <p style="margin-bottom: 5px;"><label><?php 
    _e('News Link', 'nb_ml');
    ?>
</label></p>
			  <?php 
    $val = trim((string) get_post_meta($post->ID, 'nb_link', true));
    ?>
              <input type="text" name="nb_link" value="<?php 
    echo nb_sanitize_input($val);
    ?>
" style="width: 90%; max-width: 900px;" /><br/>
              <span class="info" style="padding-top: 7px;"><?php 
    _e('Must be a valid URL', 'nb_ml');
    ?>
</span>
          </td>     
        </tr>
        <tr>
          <td class="lcwp_field_td">
              <p style="margin-bottom: 5px;"><label><?php 
    _e('Attached media', 'nb_ml');
    ?>
</label></p>
			  <?php 
    $val = trim((string) get_post_meta($post->ID, 'nb_media', true));
    ?>
              <input type="text" name="nb_media" value="<?php 
    echo nb_sanitize_input($val);
    ?>
" style="width: 90%; max-width: 900px;" /><br/>
              <span class="info" style="padding-top: 7px;"><?php 
    _e('Can be a <strong>youtube or vimeo</strong> video URL as well as a <strong>soundcloud embed</strong> URL', 'nb_ml');
    ?>
</span>
          </td>     
        </tr>
      </table>  
    </div>
    
    <?php 
    // //////////////////////
    ?>
    
    <?php 
    // FIX ADMIN MENU FOR post-new.php PAGE
    ?>
    <script type="text/javascript">
	var curr_url = location.href;
	if(curr_url.indexOf('post-new.php') != -1) {
		var $parent = jQuery('#toplevel_page_nb_menu');
		$parent.find('li, a').removeClass('current');
		$parent.find('li:nth-child(3), li:nth-child(3) a').addClass('current');
	}
	</script>
    
    <?php 
    // security nonce
    ?>
    <input type="hidden" name="nb_nonce" value="<?php 
    echo wp_create_nonce('lcwp');
    ?>
" />   
    <?php 
    return true;
}