Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.75 KB | None | 0 0
  1.  
  2.  
  3. function flourish_options_panel(){
  4.     add_meta_box('flourish_options_panel',__('Theme Options','flourish'),'flourish_options_callback','post','advanced','high');
  5.     add_meta_box('flourish_options_panel',__('Theme Options','flourish'),'flourish_options_callback','page','advanced','high');
  6. }
  7. add_action('add_meta_boxes','flourish_options_panel');
  8.  
  9. //this modifies the options block at the bottom of page/post pages
  10. function flourish_options_callback( $post ) {
  11.     wp_nonce_field( basename( __FILE__ ), 'flourish_nonce' );
  12.     $prfx_stored_meta = get_post_meta( $post->ID );
  13.     ?>
  14.     <p>
  15.         <label for="header_opacity" class="prfx-row-title"><?php _e( 'Header Overlay Transparency', 'flourish' )?></label>
  16.         <input type="text" name="header_opacity" id="header_opacity" value="<?php if ( isset ( $prfx_stored_meta['header_opacity'] ) ) echo $prfx_stored_meta['header_opacity'][0]; ?>" /> <small><?php _e( 'Enter a value between .00 and 1', 'flourish' )?></small>
  17.     </p>
  18.     <p>
  19.         <label for="header_style" class="prfx-row-title"><?php _e( 'Header Display Style', 'flourish' )?></label>
  20.         <select name="header_style" id="header_style">
  21.             <option value="" <?php if ( isset ( $prfx_stored_meta['header_style'] ) ) selected( $prfx_stored_meta['header_style'][0], '' ); ?>><?php _e( 'Default', 'flourish' )?></option>';
  22.             <option value="large-display" <?php if ( isset ( $prfx_stored_meta['header_style'] ) ) selected( $prfx_stored_meta['header_style'][0], 'large-display' ); ?>><?php _e( 'Large', 'flourish' )?></option>';
  23.             <option value="standard-display" <?php if ( isset ( $prfx_stored_meta['header_style'] ) ) selected( $prfx_stored_meta['header_style'][0], 'standard-display' ); ?>><?php _e( 'Standard', 'flourish' )?></option>';
  24.         </select>
  25.     </p>
  26.     <p>
  27.         <label>
  28.             <?php _e('Add this page/post to Front Page Widget','flourish') ?>
  29.             <input type="checkbox" <?php if ($prfx_stored_meta['flourish_fpFeatured'][0]==1){ ?> checked="checked" <?php } ?> name="flourish_fp_featured" id="flourish_fp_featured">
  30.         </label>
  31.     </p>
  32.     <p>
  33.         <label>
  34.             <?php _e('Disable Featured Image in Header','flourish') ?>
  35.             <input type="checkbox" name="flourish_display_image_feature" <?php echo ($prfx_stored_meta['flourish_display_image_feature'][0]==1)?'checked':''?> />
  36.         </label>
  37.     </p>
  38.     <p>
  39.         <label>
  40.             <?php _e('Hide the page title','flourish') ?>
  41.             <input type="checkbox" name="flourish_display_title" <?php echo ($prfx_stored_meta['flourish_display_title'][0]==1)?'checked':'' ?>/>
  42.         </label>
  43.     </p>
  44.     <?php
  45. }
  46. function flourish_options_save($postid){
  47.     $is_autosave = wp_is_post_autosave($postid);
  48.     $is_revision = wp_is_post_revision($postid);
  49.     $is_valid_nonce =  (isset($_POST['flourish_nonce']) && (bool)wp_verify_nonce($_POST[ 'flourish_nonce' ],basename( __FILE__ )));
  50.     if ($is_autosave||$is_revision|| !$is_valid_nonce)
  51.         return;
  52.     if (isset($_POST['header_opacity']))
  53.         update_post_meta($postid,'header_opacity',sanitize_text_field($_POST['header_opacity']));
  54.     if (isset($_POST['header_style']))
  55.         update_post_meta($postid,'header_style',sanitize_text_field($_POST['header_style']));
  56.     if (isset($_POST['flourish_fp_featured']))
  57.         update_post_meta($postid,'flourish_fpFeatured',1);
  58.     else
  59.         update_post_meta($postid,'flourish_fpFeatured',0);
  60.  
  61.     if (isset($_POST['flourish_display_image_feature']))
  62.         update_post_meta($postid,'flourish_display_image_feature',1);
  63.     else
  64.         update_post_meta($postid,'flourish_display_image_feature',0);
  65.  
  66.     if (isset($_POST['flourish_display_title']))
  67.         update_post_meta($postid,'flourish_display_title',1);
  68.     else
  69.         update_post_meta($postid,'flourish_display_title',0);
  70.  
  71.  
  72.  
  73. }
  74. add_action('save_post','flourish_options_save');
  75.  
  76.  
  77.  
  78. //silence ellipsis
  79. function flourish_excerpt_more($more){
  80.     return '';
  81. }
  82. add_filter( 'excerpt_more', 'flourish_excerpt_more' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement