• 1.
    // Functions for setting up Brandbox Options
  • 2.
    function dsslider_manager_meta_options(){
  • 3.
    	
  • 4.
    	global $custom_meta_fields, $post;
  • 5.
    	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  • 6.
    		// (integer) (optional) The post ID whose custom fields will be retrieved. 
  • 7.
    		// Default: Current post
  • 8.
    		return $post_id;
  • 9.
    	
  • 10.
    echo '<div class="dsslider_manager_extras">';
  • 11.
    	
  • 12.
    		// Use nonce for verification
  • 13.
    	    echo '<input type="hidden" name="dsmeta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
  • 14.
    	
  • 15.
     
  • 16.
    	
  • 17.
    		foreach ($custom_meta_fields as $field) {
  • 18.
    			// Get value of this field if it exists for this post
  • 19.
    			$meta = get_post_meta($post->ID, $field['id'], true);
  • 20.
    			
  • 21.
    				
  • 22.
    			switch ($field['type']) {
  • 23.
    				
  • 24.
    				// Repeatable
  • 25.
    				case 'repeatable':
  • 26.
    				
  • 27.
    				break;
  • 28.
    				
  • 29.
    				// Image
  • 30.
    				case 'image':
  • 31.
    					$image = get_template_directory_uri().'/images/image.png';
  • 32.
    					
  • 33.
    					echo '<span class="default_image" style="display:none">' . $image . '</span>';
  • 34.
    		
  • 35.
    					if ($meta) { 
  • 36.
    						$image = wp_get_attachment_image_src($meta, 'thumbnail');	
  • 37.
    						$image = $image[0]; 
  • 38.
    						
  • 39.
    					} // End if statement
  • 40.
    					
  • 41.
    					echo '<input name="' . $field['id'] .'" type="hidden" class="upload_image" value="' . $meta . '" />';
  • 42.
    					
  • 43.
    					echo '<img src="' . $image . '" class="preview_image" alt="" />';
  • 44.
    					
  • 45.
    					echo '<input type="button" class="button add-image" value="Add Image">';
  • 46.
    					
  • 47.
    					echo '<small><a href="#" class="remove-image">Remove Image</a></small>';
  • 48.
    				break;
  • 49.
    	
  • 50.
    				// Text
  • 51.
    				case 'text':
  • 52.
    					echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="30" />';
  • 53.
    				break;
  • 54.
    	
  • 55.
    			} // End switch statement
  • 56.
    			
  • 57.
    		
  • 58.
    		} // End foreach loop
  • 59.
     
  • 60.
    echo '</div>'; // End .dsslider_manager_extras
  • 61.
    }
// Functions for setting up Brandbox Options function dsslider_manager_meta_options(){ global $custom_meta_fields, $post; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) // (integer) (optional) The post ID whose custom fields will be retrieved. // Default: Current post return $post_id; echo '<div class="dsslider_manager_extras">'; // Use nonce for verification echo '<input type="hidden" name="dsmeta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />'; 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); switch ($field['type']) { // Repeatable case 'repeatable': break; // Image case 'image': $image = get_template_directory_uri().'/images/image.png'; echo '<span class="default_image" style="display:none">' . $image . '</span>'; if ($meta) { $image = wp_get_attachment_image_src($meta, 'thumbnail'); $image = $image[0]; } // End if statement echo '<input name="' . $field['id'] .'" type="hidden" class="upload_image" value="' . $meta . '" />'; echo '<img src="' . $image . '" class="preview_image" alt="" />'; echo '<input type="button" class="button add-image" value="Add Image">'; echo '<small><a href="#" class="remove-image">Remove Image</a></small>'; break; // Text case 'text': echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="30" />'; break; } // End switch statement } // End foreach loop echo '</div>'; // End .dsslider_manager_extras }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter