Annulleret

HTML, PHP, WordPress Job by deokib

i need only one code alternation in my function php file. i am attaching my function.php.

actually the work is i have created a custom meta box with 2 text field, one text area and one taxonomy (category field) in one meta box. i need this repeat (entire meta box) by a button clicking. this repeating is unlimited or capping in 30 block or so.

and need to display it dynamically on post

//==========================================================

// Add the Meta Box

//==========================================================

function add_custom_meta_box() {

add_meta_box(

'custom_meta_box', // $id

'Add Coureses', // $title

'show_custom_meta_box', // $callback

'post', // $page

'normal', // $context

'high', // $priority

'repeat');

}

add_action('add_meta_boxes', 'add_custom_meta_box');

// Field Array

$prefix = 'custom_';

$custom_meta_fields = array(

array(

'label' => 'Course Name',

'desc' => 'A description for the field.',

'id' => $prefix.'text',

'type' => 'text'

),

array(

'label' => 'Description',

'desc' => 'A description for the field.',

'id' => $prefix.'textarea',

'type' => 'textarea'

),

array(

'label' => 'Course Category',

'id' => 'category',

'type' => 'tax_select'

),

);

// enqueue scripts and styles, but only if is_admin

if(is_admin()) {

wp_enqueue_script('jquery-ui-datepicker');

wp_enqueue_script('jquery-ui-slider');

wp_enqueue_script('custom-js', get_template_directory_uri().'/js/[url removed, login to view]');

wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/css/[url removed, login to view]');

}

// add some custom js to the head of the page

add_action('admin_head','add_custom_scripts');

function add_custom_scripts() {

global $custom_meta_fields, $post;

$output = '<script type="text/javascript">

jQuery(function() {';

foreach ($custom_meta_fields as $field) { // loop through the fields looking for certain types

// date

if($field['type'] == 'date')

$output .= 'jQuery(".datepicker").datepicker();';

// slider

if ($field['type'] == 'slider') {

$value = get_post_meta($post->ID, $field['id'], true);

if ($value == '') $value = $field['min'];

$output .= '

jQuery( "#'.$field['id'].'-slider" ).slider({

value: '.$value.',

min: '.$field['min'].',

max: '.$field['max'].',

step: '.$field['step'].',

slide: function( event, ui ) {

jQuery( "#'.$field['id'].'" ).val( [url removed, login to view] );

}

});';

}

}

$output .= '});

</script>';

echo $output;

}

// The Callback

function show_custom_meta_box() {

global $custom_meta_fields, $post;

// Use nonce for verification

echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';

// Begin the field table and loop

echo '<table class="form-table">';

foreach ($custom_meta_fields as $field) {

// get value of this field if it exists for this post

$meta = get_post_meta($post->ID, $field['id'], true);

// begin a table row with

echo '<tr>

<th><label for="'.$field['id'].'">'.$field['label'].'</label></th>

<td>';

switch($field['type']) {

// text

case 'text':

echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="30" />

<br /><span class="description">'.$field['desc'].'</span>';

break;

// textarea

case 'textarea':

echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>

<br /><span class="description">'.$field['desc'].'</span>';

break;

// tax_select

case 'tax_select':

echo '<select name="'.$field['id'].'" id="'.$field['id'].'">

<option value="">Select One</option>'; // Select One

$terms = get_terms($field['id'], 'get=all');

$selected = wp_get_object_terms($post->ID, $field['id']);

foreach ($terms as $term) {

if (!empty($s

Færdigheder: HTML, PHP, WordPress

Se mere: this class jquery, row 44, prefix function, val , ui:repeat, taxonomy, meta slider, custom post type, input verification code, jquery css slide, project input output, css jquery slide, code block project, javascript callback, php text array, jquery callback, custom function php, textarea jquery php, javascript slide box, javascript input value event, jquery css slider, css table custom, custom block, slider hidden, javascript array post

Om arbejdsgiveren:
( 0 bedømmelser ) Cochin, India

Projekt-ID: #4109860

1 freelancer byder i gennemsnit $30 for dette job

digi3

Hired by the Employer

$30 USD på 1 dag
(49 bedømmelser)
5.0