Skip to content

Instantly share code, notes, and snippets.

@leofrozenyogurt
Created August 3, 2013 20:55
Show Gist options
  • Save leofrozenyogurt/6147945 to your computer and use it in GitHub Desktop.
Save leofrozenyogurt/6147945 to your computer and use it in GitHub Desktop.
Event Admin PHP
<?php
/*
Admin
*/
require_once( ABSPATH . 'wp-admin/includes/taxonomy.php' );
class Morgans_Post_Type_Admin {
/*
Constants Section
*/
const POST_NONCENAME = "MHG_Post_Nonce";
const TYPE_POST_NONCENAME = "MHG_Type_Post_Nonce";
const HOME_ORDER_NONCENAME = "MHG_Post_Order_Nonce";
const TRAF_POST_NONCENAME = "MHG_Traf_Post_Nonce";
const FEAT_POST_NONCENAME = "MHG_Feat_Post_Nonce";
const SOURCE_POST_NONCENAME = "MHG_Source_Post_Nonce";
const EVENT_POST_NONCENAME = "MHG_Event_Post_Nonce";
const EVENT_REPETITION_POST_NONCENAME = "MHG_Event_Repetion_Nonce";
const WHERE_POST_NONCENAME = "MHG_Where_Post_Nonce";
const BG_POST_NONCENAME = "MHG_Background_Post_Nonce";
const FEATURED_POSITION_POST_NONCENAME = 'MHG_Featured_Position_Post_Nonce';
const FEATURED_COLOR_POST_NONCENAME = 'MHG_Featured_Color_Post_Nonce';
const CONTENT_WIDTH_POST_NONCENAME = 'MHG_Featured_Position_Post_Nonce';
const POST_TYPE = "Post";
/*
Global Variables
*/
public $galleryArray = array();
/*
Methods Section
*/
/**
* Method called by 'init' hook
*/
function codex_custom_init() {
// Scripts
wp_deregister_script('jquery-ui');
wp_register_script('jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js', array( 'jquery' ) ); wp_enqueue_script( 'jquery-ui' );
wp_deregister_script('morgans-post-admin-js');
wp_register_script('morgans-post-admin-js', plugins_url('admin.js', __FILE__), array( 'jquery', 'morgans-post-carousel-js' ) );
wp_enqueue_script( 'morgans-post-admin-js' );
wp_register_script('morgans-post-carousel-js', plugins_url('jcarousellite_1.0.1.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'morgans-post-carousel-js' );
wp_register_script('morgans-post-chosen-js', plugins_url('chosen.jquery.min.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'morgans-post-chosen-js' );
// Styles
wp_register_style( 'morgans-post-admin', plugins_url('styles.css', __FILE__) );
wp_enqueue_style( 'morgans-post-admin' );
wp_register_style( 'morgans-chosen-admin', plugins_url('chosen.css', __FILE__) );
wp_enqueue_style( 'morgans-chosen-admin' );
}
// MHG Post
/**
* Create the custom meta box for custom event post type
*/
function add_mhg_meta_boxes()
{
$metaBoxTypeTitle = "Post Type";
$metaBoxOrderTitle = "Post Order Configuration";
$metaBoxTrafficTitle = "Traffic";
$metaBoxFeaturedTitle = "Featured";
$metaBoxFeaturedPositionTitle = "Featured Content Location";
$metaBoxColorPositionTitle = "Featured Content Color";
$metaBoxCategoriesTitle = "Categories";
$metaBoxSourceTitle = "Source: ";
$metaBoxPartnerTitle = "Partner: ";
$metaBoxWhereTitle = "Where";
$metaBoxEventTitle = "Event Info";
$metaBoxBackgroundTitle = "Background Image";
$metaBoxContentWidthTitle = "Content Width";
$metaBoxRepeatTitle = "Event Repetion";
$gallery = get_posts('post_type=attachment');
foreach ($gallery as $attach)
{
if (false !== stripos($attach->post_mime_type, 'image'))
{
$attach_id = $attach->ID;
$attach_url = wp_get_attachment_url($attach_id);
$this->galleryArray[] = array('url' =>$attach_url, 'attach_id' => $attach_id);
}
}
remove_meta_box( 'commentsdiv', 'post', 'normal' );
add_meta_box(
'mhg_type_meta_box',
__( $metaBoxTypeTitle, self::POST_TYPE ),
array( &$this, 'render_type_meta_box_content' ),
'post',
'side',
'core'
);
add_meta_box(
'mhg_home_order_meta_box',
__( $metaBoxOrderTitle, self::POST_TYPE ),
array( &$this, 'render_home_order_meta_box_content' ),
'post',
'side',
'core'
);
add_meta_box(
'mhg_traf_meta_box',
__( $metaBoxTrafficTitle, self::POST_TYPE ),
array( &$this, 'render_traf_meta_box_content' ),
'post',
'side',
'low'
);
add_meta_box(
'mhg_content_width_meta_box',
__( $metaBoxContentWidthTitle, self::POST_TYPE ),
array( &$this, 'render_content_width_meta_box_content' ),
'post',
'side',
'low'
);
add_meta_box(
'mhg_feat_position_meta_box',
__( $metaBoxFeaturedPositionTitle, self::POST_TYPE ),
array( &$this, 'render_featured_position_meta_box_content' ),
'post',
'side',
'low'
);
add_meta_box(
'mhg_feat_color_meta_box',
__( $metaBoxColorPositionTitle, self::POST_TYPE ),
array( &$this, 'render_featured_color_meta_box_content' ),
'post',
'side',
'low'
);
add_meta_box(
'mhg_feat_meta_box',
__( $metaBoxFeaturedTitle, self::POST_TYPE ),
array( &$this, 'render_feat_meta_box_content' ),
'post',
'side',
'low'
);
remove_meta_box('formatdiv', 'post', 'side');
add_meta_box(
'mhg_source_meta_box',
__( $metaBoxSourceTitle, self::POST_TYPE ),
array( &$this, 'render_source_meta_box_content' ),
'post',
'advanced',
'low'
);
add_meta_box(
'mhg_event_info_meta_box',
__( $metaBoxEventTitle, self::POST_TYPE ),
array( &$this, 'render_event_info_meta_box_content' ),
'post',
'advanced',
'low'
);
add_meta_box(
'mhg_where_meta_box',
__( $metaBoxWhereTitle, self::POST_TYPE ),
array( &$this, 'render_where_meta_box_content' ),
'post',
'advanced',
'low'
);
add_meta_box(
'mhg_bg_meta_box',
__( $metaBoxBackgroundTitle, self::POST_TYPE ),
array( &$this, 'render_bg_meta_box_content' ),
'post',
'side',
'low'
);
add_meta_box(
'mhg_repeat_meta_box',
__( $metaBoxRepeatTitle, self::POST_TYPE ),
array( &$this, 'render_repeat_meta_box_content' ),
'post',
'advanced',
'low'
);
}
public function render_type_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::TYPE_POST_NONCENAME );
$data = get_post_meta($post->ID, 'mhg_type_data', true );
$options = array();
$options[0] = $data == 'Event'? 'selected': '';
$options[1] = $data == 'Place'? 'selected': '';
$options[2] = $data == 'Article'? 'selected': '';
echo '<select name="typeSelector" id="mpt-type-select" style="width:100px"> ';
echo '<option name="Article" '. $options[2] .'> Article </option>';
echo '<option name="Event" '. $options[0] .'> Event </option>';
echo '<option name="Place" '. $options[1] .'> Place </option>';
echo '</select> ';
}
public function render_home_order_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::HOME_ORDER_NONCENAME );
// Home Order
$data = get_post_meta($post->ID, 'mhg_home_order_data', true );
echo '<label for="homeOrder">Home Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="homeOrder" value="'. $data .'"></input><br><br>';
// Boston Order
$data = get_post_meta($post->ID, 'mhg_boston_order_data', true );
echo '<label for="bostonOrder">Boston Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="bostonOrder" value="'. $data .'"></input><br><br>';
// London Order
$data = get_post_meta($post->ID, 'mhg_london_order_data', true );
echo '<label for="londonOrder">London Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="londonOrder" value="'. $data .'"></input><br><br>';
// Los Angeles Order
$data = get_post_meta($post->ID, 'mhg_losangeles_order_data', true );
echo '<label for="losangelesOrder">Los Angeles Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="losangelesOrder" value="'. $data .'"></input><br><br>';
// Marrakech Order
$data = get_post_meta($post->ID, 'mhg_marrakech_order_data', true );
echo '<label for="marrakechOrder">Marrakech Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="marrakechOrder" value="'. $data .'"></input><br><br>';
// New York Order
$data = get_post_meta($post->ID, 'mhg_newyork_order_data', true );
echo '<label for="newYorkOrder">New York Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="newYorkOrder" value="'. $data .'"></input><br><br>';
// San Francisco Order
$data = get_post_meta($post->ID, 'mhg_sanfrancisco_order_data', true );
echo '<label for="sanfranciscoOrder">San Francisco Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="sanfranciscoOrder" value="'. $data .'"></input><br><br>';
// South Beach Order
$data = get_post_meta($post->ID, 'mhg_southbeach_order_data', true );
echo '<label for="southBeachOrder">South Beach Page Order: </label>';
echo '<input style="width: 35px; text-align: center; margin: 0 0 0 5px;" type="text" name="southBeachOrder" value="'. $data .'"></input><br><br>';
}
public function render_content_width_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::CONTENT_WIDTH_POST_NONCENAME );
$data = get_post_meta($post->ID, 'mhg_content_width', true );
$options = array();
$options[0] = $data == 'normal'? 'selected': '';
$options[1] = $data == 'wide'? 'selected': '';
echo '<select name="widthSelector" id="cWidth-select" style="width:130px"> ';
echo '<option value="wide" '. $options[1] .'> Wide </option>';
echo '<option value="normal" '. $options[0] .'> Narrow </option>';
echo '</select> ';
}
public function render_featured_position_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::FEATURED_POSITION_POST_NONCENAME );
$data = get_post_meta($post->ID, 'featured_content_position', true );
$options = array();
$options[0] = $data == 'top-left'? 'selected': '';
$options[1] = $data == 'top-center'? 'selected': '';
$options[2] = $data == 'top-right'? 'selected': '';
$options[3] = $data == 'bottom-left'? 'selected': '';
$options[4] = $data == 'bottom-center'? 'selected': '';
$options[5] = $data == 'bottom-right'? 'selected': '';
echo '<label class="meta-sub-title">Content Location (when featured):</label><br/>';
echo '<select name="positionSelector" id="fcp-select" style="width:130px"> ';
echo '<option name="top-right" '. $options[2] .'> Top-Right </option>';
echo '<option name="top-left" '. $options[0] .'> Top-Left </option>';
echo '<option name="top-center" '. $options[1] .'> Top-Center </option>';
echo '<option name="bottom-left" '. $options[3] .'> Bottom-Left </option>';
echo '<option name="bottom-center" '. $options[4] .'> Bottom-Center </option>';
echo '<option name="bottom-right" '. $options[5] .'> Bottom-Right </option>';
echo '</select> ';
}
public function render_featured_color_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::FEATURED_COLOR_POST_NONCENAME );
$data = get_post_meta($post->ID, 'featured_content_color', true );
$options = array();
$options[0] = $data == 'black'? 'selected': '';
$options[1] = $data == 'white'? 'selected': '';
$options[2] = $data == 'yellow'? 'selected': '';
echo '<label class="meta-sub-title">Featured Content Text Color:</label><br/>';
echo '<select name="colorSelector" id="fcc-select" style="width:130px"> ';
echo '<option name="blakc" '. $options[0] .'> Black </option>';
echo '<option name="white" '. $options[1] .'> White </option>';
echo '<option name="yellow" '. $options[2] .'> Yellow </option>';
echo '</select> ';
}
public function render_traf_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::TRAF_POST_NONCENAME );
$data = get_post_meta($post->ID, 'mhg_traf_data', true );
$checks = array();
if (isset($data))
{
$temp = array();
if (is_array($data))
{
foreach ( $data as $cat )
{
$temp[$cat] = 'checked';
}
}
$checks[0] = isset($temp['loc_Boston'])? 'checked': '';
$checks[1] = isset($temp['loc_Marrakech'])? 'checked': '';
$checks[2] = isset($temp['loc_SouthB'])? 'checked': '';
$checks[3] = isset($temp['loc_London'])? 'checked': '';
$checks[4] = isset($temp['loc_NY'])? 'checked': '';
$checks[5] = isset($temp['loc_LA'])? 'checked': '';
$checks[6] = isset($temp['loc_SF'])? 'checked': '';
$checks[7] = isset($temp['pro_Ames'])? 'checked': '';
$checks[8] = isset($temp['pro_Clift'])? 'checked': '';
$checks[9] = isset($temp['pro_DL'])? 'checked': '';
$checks[10] = isset($temp['pro_DL_MS'])? 'checked': '';
$checks[11] = isset($temp['pro_DL_SB'])? 'checked': '';
$checks[12] = isset($temp['pro_Hudson'])? 'checked': '';
$checks[13] = isset($temp['pro_Mondrian'])? 'checked': '';
$checks[14] = isset($temp['pro_Md_NY'])? 'checked': '';
$checks[15] = isset($temp['pro_Md_LA'])? 'checked': '';
$checks[16] = isset($temp['pro_Md_SB'])? 'checked': '';
$checks[17] = isset($temp['pro_Morgans'])? 'checked': '';
$checks[18] = isset($temp['pro_Royalton'])? 'checked': '';
$checks[19] = isset($temp['pro_Sanderson'])? 'checked': '';
$checks[20] = isset($temp['pro_SC'])? 'checked': '';
$checks[21] = isset($temp['pro_SML'])? 'checked': '';
}
echo '<input type="checkbox" id="trafficLocationsToggle" name="trafficLocationsToggle" value="toggle"> Select All Locations</input><br>';
echo '<br>';
// Locations
echo '<label class="meta-sub-title">Location</label><br>';
echo '<table id="trafficLocations" border="0" style="width:100%"> <tr>';
echo '<td><input type="checkbox" name="traffic[]" value="loc_Boston" '.$checks[0].'> Boston</input> </td>';
echo '<td><input type="checkbox" name="traffic[]" value="loc_Marrakech" '.$checks[1].'> Marrakech</input> </td>';
echo '<td><input type="checkbox" name="traffic[]" value="loc_SouthB" '.$checks[2].'> South B.</input> </td> </tr>';
echo '<tr> <td><input type="checkbox" name="traffic[]" value="loc_London" '.$checks[3].'> London</input> </td>';
echo '<td><input type="checkbox" name="traffic[]" value="loc_NY" '.$checks[4].'> New York</input> </td> </tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="loc_LA" '.$checks[5].'> LA </input> </td> ';
echo '<td><input type="checkbox" name="traffic[]" value="loc_SF" '.$checks[6].'> SF</input> </td>';
echo '</tr> </table>';
echo '<br>';
echo '<input type="checkbox" id="trafficPropertiesToggle" name="trafficPropertiesToggle" value="toggle"> Select All Properties</input><br>';
echo '<br>';
// Properties
echo '<label class="meta-sub-title">Property</label><br>';
echo '<table border="0" id="trafficProperties"> <tr>';
echo '<td><input type="checkbox" name="traffic[]" value="pro_Ames" '.$checks[7].'> Ames</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Clift" '.$checks[8].'> Clift</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_DL_MS" '.$checks[10].'> Delano Marrakech</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_DL_SB" '.$checks[11].'> Delano South Beach</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Hudson" '.$checks[12].'> Hudson </input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Md_NY" '.$checks[14].'> Mondrian New York</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Md_LA" '.$checks[15].'> Mondrian Los Angeles</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Md_SB" '.$checks[16].'> Mondrian South Beach</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Morgans" '.$checks[17].'> Morgans</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Royalton" '.$checks[18].'> Royalton</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_Sanderson" '.$checks[19].'> Sanderson </input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_SC" '.$checks[20].'> Shore Club</input></td></tr>';
echo '<tr><td><input type="checkbox" name="traffic[]" value="pro_SML" '.$checks[21].'> St Mt Lane</input></td>';
echo '</tr> </table>';
}
public function render_feat_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::FEAT_POST_NONCENAME );
$data = get_post_meta($post->ID, 'mhg_feat_data', true );
$checks = array();
if (isset($data))
{
$temp = array();
if (is_array($data))
{
foreach ( $data as $cat )
{
$temp[$cat] = 'checked';
}
}
$checks[0] = isset($temp['loc_Boston'])? 'checked': '';
$checks[1] = isset($temp['loc_Marrakech'])? 'checked': '';
$checks[2] = isset($temp['loc_SouthB'])? 'checked': '';
$checks[3] = isset($temp['loc_London'])? 'checked': '';
$checks[4] = isset($temp['loc_NY'])? 'checked': '';
$checks[5] = isset($temp['loc_LA'])? 'checked': '';
$checks[6] = isset($temp['loc_SF'])? 'checked': '';
$checks[7] = isset($temp['pro_Ames'])? 'checked': '';
$checks[8] = isset($temp['pro_Clift'])? 'checked': '';
$checks[9] = isset($temp['pro_DL'])? 'checked': '';
$checks[10] = isset($temp['pro_DL_MS'])? 'checked': '';
$checks[11] = isset($temp['pro_DL_SB'])? 'checked': '';
$checks[12] = isset($temp['pro_Hudson'])? 'checked': '';
$checks[13] = isset($temp['pro_Mondrian'])? 'checked': '';
$checks[14] = isset($temp['pro_Md_NY'])? 'checked': '';
$checks[15] = isset($temp['pro_Md_LA'])? 'checked': '';
$checks[16] = isset($temp['pro_Md_SB'])? 'checked': '';
$checks[17] = isset($temp['pro_Morgans'])? 'checked': '';
$checks[18] = isset($temp['pro_Royalton'])? 'checked': '';
$checks[19] = isset($temp['pro_Sanderson'])? 'checked': '';
$checks[20] = isset($temp['pro_SC'])? 'checked': '';
$checks[21] = isset($temp['pro_SML'])? 'checked': '';
$checks[22] = isset($temp['home'])? 'checked': '';
$checks[23] = isset($temp['cat_Culture'])? 'checked': '';
$checks[24] = isset($temp['cat_TheList'])? 'checked': '';
$checks[25] = isset($temp['cat_Stories'])? 'checked': '';
// Culture
$checks[26] = isset($temp['loc+Boston_culture'])? 'checked': '';
$checks[27] = isset($temp['loc+Marrakech_culture'])? 'checked': '';
$checks[28] = isset($temp['loc+SouthB_culture'])? 'checked': '';
$checks[29] = isset($temp['loc+London_culture'])? 'checked': '';
$checks[30] = isset($temp['loc+NY_culture'])? 'checked': '';
$checks[31] = isset($temp['loc+LA_culture'])? 'checked': '';
$checks[32] = isset($temp['loc+SF_culture'])? 'checked': '';
$checks[33] = isset($temp['pro+Ames_culture'])? 'checked': '';
$checks[34] = isset($temp['pro+Clift_culture'])? 'checked': '';
$checks[35] = isset($temp['pro+DL_culture'])? 'checked': '';
$checks[36] = isset($temp['pro+DL_MS_culture'])? 'checked': '';
$checks[37] = isset($temp['pro+DL_SB_culture'])? 'checked': '';
$checks[38] = isset($temp['pro+Hudson_culture'])? 'checked': '';
$checks[39] = isset($temp['pro+Mondrian_culture'])? 'checked': '';
$checks[40] = isset($temp['pro+Md_NY_culture'])? 'checked': '';
$checks[41] = isset($temp['pro+Md_LA_culture'])? 'checked': '';
$checks[42] = isset($temp['pro+Md_SB_culture'])? 'checked': '';
$checks[43] = isset($temp['pro+Morgans_culture'])? 'checked': '';
$checks[44] = isset($temp['pro+Royalton_culture'])? 'checked': '';
$checks[45] = isset($temp['pro+Sanderson_culture'])? 'checked': '';
$checks[46] = isset($temp['pro+SC_culture'])? 'checked': '';
$checks[47] = isset($temp['pro+SML_culture'])? 'checked': '';
// The List
$checks[48] = isset($temp['loc+Boston_list'])? 'checked': '';
$checks[49] = isset($temp['loc+Marrakech_list'])? 'checked': '';
$checks[50] = isset($temp['loc+SouthB_list'])? 'checked': '';
$checks[51] = isset($temp['loc+London_list'])? 'checked': '';
$checks[52] = isset($temp['loc+NY_list'])? 'checked': '';
$checks[53] = isset($temp['loc+LA_list'])? 'checked': '';
$checks[54] = isset($temp['loc+SF_list'])? 'checked': '';
$checks[55] = isset($temp['pro+Ames_list'])? 'checked': '';
$checks[56] = isset($temp['pro+Clift_list'])? 'checked': '';
$checks[57] = isset($temp['pro+DL_list'])? 'checked': '';
$checks[58] = isset($temp['pro+DL_MS_list'])? 'checked': '';
$checks[59] = isset($temp['pro+DL_SB_list'])? 'checked': '';
$checks[60] = isset($temp['pro+Hudson_list'])? 'checked': '';
$checks[61] = isset($temp['pro+Mondrian_list'])? 'checked': '';
$checks[62] = isset($temp['pro+Md_NY_list'])? 'checked': '';
$checks[63] = isset($temp['pro+Md_LA_list'])? 'checked': '';
$checks[64] = isset($temp['pro+Md_SB_list'])? 'checked': '';
$checks[65] = isset($temp['pro+Morgans_list'])? 'checked': '';
$checks[66] = isset($temp['pro+Royalton_list'])? 'checked': '';
$checks[67] = isset($temp['pro+Sanderson_list'])? 'checked': '';
$checks[68] = isset($temp['pro+SC_list'])? 'checked': '';
$checks[69] = isset($temp['pro+SML_list'])? 'checked': '';
// Stories
$checks[70] = isset($temp['loc+Boston_stories'])? 'checked': '';
$checks[71] = isset($temp['loc+Marrakech_stories'])? 'checked': '';
$checks[72] = isset($temp['loc+SouthB_stories'])? 'checked': '';
$checks[73] = isset($temp['loc+London_stories'])? 'checked': '';
$checks[74] = isset($temp['loc+NY_stories'])? 'checked': '';
$checks[75] = isset($temp['loc+LA_stories'])? 'checked': '';
$checks[76] = isset($temp['loc+SF_stories'])? 'checked': '';
$checks[77] = isset($temp['pro+Ames_stories'])? 'checked': '';
$checks[78] = isset($temp['pro+Clift_stories'])? 'checked': '';
$checks[79] = isset($temp['pro+DL_stories'])? 'checked': '';
$checks[80] = isset($temp['pro+DL_MS_stories'])? 'checked': '';
$checks[81] = isset($temp['pro+DL_SB_stories'])? 'checked': '';
$checks[82] = isset($temp['pro+Hudson_stories'])? 'checked': '';
$checks[83] = isset($temp['pro+Mondrian_stories'])? 'checked': '';
$checks[84] = isset($temp['pro+Md_NY_stories'])? 'checked': '';
$checks[85] = isset($temp['pro+Md_LA_stories'])? 'checked': '';
$checks[86] = isset($temp['pro+Md_SB_stories'])? 'checked': '';
$checks[87] = isset($temp['pro+Morgans_stories'])? 'checked': '';
$checks[88] = isset($temp['pro+Royalton_stories'])? 'checked': '';
$checks[89] = isset($temp['pro+Sanderson_stories'])? 'checked': '';
$checks[90] = isset($temp['pro+SC_stories'])? 'checked': '';
$checks[91] = isset($temp['pro+SML_stories'])? 'checked': '';
}
echo '<label class="meta-sub-title">Main Features</label><br>';
echo '<p class="">Feature posts for the home page, specific cities or categories.</p><br>';
echo '<input type="checkbox" name="ft[]" value="home" '.$checks[22].'> Home</input><br>';
echo '<br>';
echo '<input type="checkbox" id="featuredLocationToggle" name="featuredLocationToggle" value="toggle"> Select All Main Locations</input><br>';
echo '<br>';
// Locations
echo '<label class="meta-sub-title">Location</label><br>';
echo '<table id="featuredLocations" border="0" style="width:100%"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc_Boston" '.$checks[0].'> Boston</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc_Marrakech" '.$checks[1].'> Marrakech</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc_SouthB" '.$checks[2].'> South B.</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc_London" '.$checks[3].'> London</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc_NY" '.$checks[4].'> New York</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc_LA" '.$checks[5].'> LA </input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc_SF" '.$checks[6].'> SF</input></td>';
echo '</tr> </table>';
echo '<br>';
echo '<input type="checkbox" id="featuredPropertyToggle" name="featuredPropertyToggle" value="toggle"> Select All Main Properties</input><br>';
echo '<br>';
// Properties
echo '<label class="meta-sub-title">Property</label><br>';
echo '<table border="0" id="featuredProperties"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="pro_Ames" '.$checks[7].'> Ames</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Clift" '.$checks[8].'> Clift</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_DL_MS" '.$checks[10].'> Delano Marrakech</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_DL_SB" '.$checks[11].'> Delano South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Hudson" '.$checks[12].'> Hudson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Md_NY" '.$checks[14].'> Mondrian New York</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Md_LA" '.$checks[15].'> Mondrian Los Angeles</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Md_SB" '.$checks[16].'> Mondrian South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Morgans" '.$checks[17].'> Morgans</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Royalton" '.$checks[18].'> Royalton</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_Sanderson" '.$checks[19].'> Sanderson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_SC" '.$checks[20].'> Shore Club</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro_SML" '.$checks[21].'> St Mt Lane</input></td>';
echo '</tr> </table>';
// Categories
echo '<br>';
echo '<input type="checkbox" id="featuredCategoryToggle" name="featuredCategoryToggle" value="toggle"> Select All Categories</input><br>';
echo '<br><label class="meta-sub-title">Categories</label><br>';
echo '<table border="0" id="featuredCategories"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="cat_Culture" '.$checks[23].'> Culture</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="cat_TheList" '.$checks[24].'> The List</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="cat_Stories" '.$checks[25].'> Inside Stories</input></td></tr>';
echo '</tr> </table>';
// Culture Features
echo '<br><br><label class="meta-sub-title">Culture Features</label><br>';
echo '<p class="">Feature posts inside Culture to specific city or location</p><br>';
echo '<input type="checkbox" id="featuredCultureLocationToggle" name="featuredCultureLocationToggle" value="toggle"> Select All Culture Locations</input><br>';
echo '<br>';
// Culture Locations
echo '<label class="meta-sub-title">Culture Location</label><br>';
echo '<table border="0" style="width:100%" id="featuredCultureLocations"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Boston_culture" '.$checks[26].'> Boston</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Marrakech_culture" '.$checks[27].'> Marrakech</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SouthB_culture" '.$checks[28].'> South B.</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+London_culture" '.$checks[29].'> London</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+NY_culture" '.$checks[30].'> New York</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+LA_culture" '.$checks[31].'> LA </input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SF_culture" '.$checks[32].'> SF</input></td>';
echo '</tr> </table>';
echo '<br>';
echo '<input type="checkbox" id="featuredCulturePropertyToggle" name="featuredCulturePropertyToggle" value="toggle"> Select All Culture Properties</input><br>';
echo '<br>';
// Culture Properties
echo '<label class="meta-sub-title">Culture Property</label><br>';
echo '<table border="0" id="featuredCultureProperties"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="pro+Ames_culture" '.$checks[33].'> Ames</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Clift_culture" '.$checks[34].'> Clift</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_MS_culture" '.$checks[36].'> Delano Marrakech</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_SB_culture" '.$checks[37].'> Delano South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Hudson_culture" '.$checks[38].'> Hudson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_NY_culture" '.$checks[40].'> Mondrian New York</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_LA_culture" '.$checks[41].'> Mondrian Los Angeles</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_SB_culture" '.$checks[42].'> Mondrian South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Morgans_culture" '.$checks[43].'> Morgans</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Royalton_culture" '.$checks[44].'> Royalton</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Sanderson_culture" '.$checks[45].'> Sanderson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SC_culture" '.$checks[46].'> Shore Club</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SML_culture" '.$checks[47].'> St Mt Lane</input></td>';
echo '</tr> </table>';
// The List Features
echo '<br><br><label class="meta-sub-title">The List Features</label><br>';
echo '<p class="">Feature posts inside The List to specific city or location</p><br>';
echo '<input type="checkbox" id="featuredListLocationToggle" name="featuredListLocationToggle" value="toggle"> Select All The List Locations</input><br>';
// The List Locations
echo '<label class="meta-sub-title">The List Location</label><br>';
echo '<table border="0" style="width:100%" id="featuredListLocations"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Boston_list" '.$checks[48].'> Boston</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Marrakech_list" '.$checks[49].'> Marrakech</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SouthB_list" '.$checks[50].'> South B.</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+London_list" '.$checks[51].'> London</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+NY_list" '.$checks[52].'> New York</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+LA_list" '.$checks[53].'> LA </input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SF_list" '.$checks[54].'> SF</input></td>';
echo '</tr> </table>';
echo '<br>';
// The List Properties
echo '<input type="checkbox" id="featuredListPropertyToggle" name="featuredListPropertyToggle" value="toggle"> Select All The List Properties</input><br>';
echo '<br>';
echo '<label class="meta-sub-title">The List Property</label><br>';
echo '<table border="0" id="featuredListProperties"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="pro+Ames_list" '.$checks[55].'> Ames</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Clift_list" '.$checks[56].'> Clift</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_MS_list" '.$checks[58].'> Delano Marrakech</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_SB_list" '.$checks[59].'> Delano South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Hudson_list" '.$checks[60].'> Hudson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_NY_list" '.$checks[62].'> Mondrian New York</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_LA_list" '.$checks[63].'> Mondrian Los Angeles</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_SB_list" '.$checks[64].'> Mondrian South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Morgans_list" '.$checks[65].'> Morgans</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Royalton_list" '.$checks[66].'> Royalton</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Sanderson_list" '.$checks[67].'> Sanderson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SC_list" '.$checks[68].'> Shore Club</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SML_list" '.$checks[69].'> St Mt Lane</input></td>';
echo '</tr> </table>';
// Inside Stories Features
echo '<br><br><label class="meta-sub-title">Inside Stories Features</label><br>';
echo '<p class="">Feature posts inside Inside Stories to specific city or location</p><br>';
echo '<input type="checkbox" id="featuredStoryLocationToggle" name="featuredStoryLocationToggle" value="toggle"> Select All Inside Story Locations</input><br>';
// Inside Stories Locations
echo '<label class="meta-sub-title">Inside Stories Location</label><br>';
echo '<table border="0" style="width:100%" id="featuredStoryLocations"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Boston_stories" '.$checks[70].'> Boston</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+Marrakech_stories" '.$checks[71].'> Marrakech</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SouthB_stories" '.$checks[72].'> South B.</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+London_stories" '.$checks[73].'> London</input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+NY_stories" '.$checks[74].'> New York</input></td> </tr>';
echo '<td><input type="checkbox" name="ft[]" value="loc+LA_stories" '.$checks[75].'> LA </input></td>';
echo '<td><input type="checkbox" name="ft[]" value="loc+SF_stories" '.$checks[76].'> SF</input></td>';
echo '</tr> </table>';
echo '<br>';
// Inside Stories Properties
echo '<input type="checkbox" id="featuredStoryPropertyToggle" name="featuredStoryPropertyToggle" value="toggle"> Select All Inside Story Properties</input><br>';
echo '<br>';
echo '<label class="meta-sub-title">Inside Stories Property</label><br>';
echo '<table border="0" id="featuredStoryProperties"> <tr>';
echo '<td><input type="checkbox" name="ft[]" value="pro+Ames_stories" '.$checks[77].'> Ames</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Clift_stories" '.$checks[78].'> Clift</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_MS_stories" '.$checks[80].'> Delano Marrakech</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+DL_SB_stories" '.$checks[81].'> Delano South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Hudson_stories" '.$checks[82].'> Hudson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_NY_stories" '.$checks[84].'> Mondrian New York</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_LA_stories" '.$checks[85].'> Mondrian Los Angeles</input></td></tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Md_SB_stories" '.$checks[86].'> Mondrian South Beach</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Morgans_stories" '.$checks[87].'> Morgans</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Royalton_stories" '.$checks[88].'> Royalton</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+Sanderson_stories" '.$checks[89].'> Sanderson </input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SC_stories" '.$checks[90].'> Shore Club</input></td> </tr>';
echo '<tr><td><input type="checkbox" name="ft[]" value="pro+SML_stories" '.$checks[91].'> St Mt Lane</input></td>';
echo '</tr> </table>';
}
public function render_source_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::SOURCE_POST_NONCENAME );
$source_url = get_post_meta($post->ID, 'source_url', true );
$download_id = get_post_meta($post->ID, 'source_img_file', true);
$title = get_post_meta($post->ID, 'source_title', true);
echo '<p>Title and image will show only if set, if both are set both will show. If a URL is provided both the title and the image will be linked to that url and open in a new browser tab.</p>';
echo '<div> <div style="width: 100%; height: 130px;"> <div class="meta-img-div meta-div-left">';
echo '<label class="meta-sub-title">Title: </label>';
echo '<input id="current_src_title" name="current_src_title" type="text" value="'.$title.'"/><br><br>';
echo '<input id="current_src_img" name="current_src_img" type="hidden" value="'.$download_id.'"/>';
echo '<input id="selected_src_img" name="selected_src_img" type="hidden" value=""/>';
echo '<img id="source_img" ismap="ismap" width="100%" height="100%" style="display:'.( $download_id ? 'block' : 'none' ).'; margin-right:10px; vertical-align: middle;" alt="No Preview" src="'.$download_id.'"></img> </div> <div class="meta-div-left meta-div-aling-middle">';
echo '<br/></div class="meta-div-right"><div></div> <br/></div>';
echo '<br/><div><input id="source_gallery_btn" type="button" class="button" value="Choose Image"/>';
echo '</div>';
echo '<br/><label class="meta-sub-title">URL:</label>';
echo '<input type="url" name="source_url" style="width: 80%;" value="'.$source_url.'"></input>';
echo '</div>';
}
public function render_where_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::WHERE_POST_NONCENAME );
// Edit Area
$htmlBlock = <<<EDITAREA
<style>
tr.mposttypes_description td {
font-size: .8em;
color: #999;
text-align: left;
padding-bottom: 15px;
}
</style>
<div style="width: 100%;overflow: auto; min-height: 200px;">
<div style="width: 100%; height: 400px;">
<table border="0" style="width:100%">
<tr>
<td class="where-td-left">Location</td>
<td><input id="where_loc" type="text" class="where-td-input"></input></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">What's the place name</td>
</tr>
<tr>
<td class="where-td-left">Address</td>
<td><input id="where_add" type="text" class="where-td-input"></input></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">Address of the given location</td>
</tr>
<tr>
<td class="where-td-left">Zip</td>
<td><input id="where_zip" type="text" class="where-td-input"></input></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">Location's Zip Code</td>
</tr>
<td class="where-td-left">Phone</td>
<td><input id="where_phone" type="text" class="where-td-input"></input></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">Phone number with the format (xxx) xxxxxxxx</td>
</tr>
<tr>
<td class="where-td-left">Map URL</td>
<td><input id="where_url" type="url" class="where-td-input"></input></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">The full URL to be used for the MAP.</td>
</tr>
<tr>
<tr><td class="where-td-left">Website URL</td>
<td><input id="where_website" type="url" class="where-td-input"></input></td>
<td class="mposttypes_description"></td>
</tr>
<tr class="mposttypes_description">
<td colspan="2">Full website URL</td>
</tr>
</table>
<div style="width: 100%; text-align:right;">
<input type="button" class="button" id="where_add_btn" value="Add Location"/>
</div>
</div>
EDITAREA;
// Lets print the edit block
echo $htmlBlock;
// Location list
$data = get_post_meta($post->ID, 'mhg_where_list', true );
echo '<br/><div id="where_list" style="display: none; width: 100%;"> ';
echo '<label class="meta-sub-title">Location </label><br/>';
echo '<ul id="where_ul" class="where_ul">';
if(isset($data))
{
if (is_array($data))
{
foreach ( $data as $key => $where )
{
if(!isset($where['website'])){$where['website'] = '';}
if(!isset($where['phone'])){$where['phone'] = '';}
if(!isset($where['zip'])){$where['zip'] = '';}
echo '<li id="where_li'.$key.'" class="locationRow"> <div>';
// Delete Button
echo '<input data-action="where_delete" type="button" class="button" value="x delete this location" />';
// Editable Items
echo '<table border="0" style="width:100%"> <tr>';
echo '<td class="where-td-left">Location</td>';
echo '<td><input type="text" name="where_loc[]" value="'.$where['location'].'"/></td></tr> <tr>';
echo '<td class="where-td-left">Address</td>';
echo '<td><input type="text" name="where_add[]" value="'.$where['address'].'"/></td></tr>';
echo '<td class="where-td-left">Zip</td>';
echo '<td><input type="text" name="where_zip[]" value="'.$where['zip'].'"/></td></tr>';
echo '<td class="where-td-left">Phone</td>';
echo '<td><input type="text" name="where_phone[]" value="'.$where['phone'].'"/></td></tr>';
echo '<tr><td class="where-td-left">Map URL</td>';
echo '<td><input type="url" name="where_url[]" value="'.$where['url'].'"/></td></tr>';
echo '<tr><td class="where-td-left">Website URL</td>';
echo '<td><input type="url" name="where_website[]" value="'.$where['website'].'"/></td></tr>';
echo ' </table>';
echo '</div> </li> ';
}
}
}
echo '</ul></div>';
echo '<div id="where_dialog" title="Confirmation Required" style="min-height: 40px;">';
echo '<b>Are you sure you want to remove this?</b><br> (you must save the post for changes to take effect)';
echo '</div>';
echo '</div>';
}
public function render_bg_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::BG_POST_NONCENAME );
$dataGallery = get_post_meta($post->ID, 'mhg_bg_image', true );
if ( intval($dataGallery) != '0')
{
$dataGallery_url = wp_get_attachment_url($dataGallery);
} else {
$dataGallery_url = $dataGallery;
}
echo '<div style="width: 100%;overflow: auto">';
echo '<input id="upload_image" type="text" size="36" readonly name="upload_image" value="'. $dataGallery_url .'" />';
echo '<input id="upload_image_button" class="button" type="button" value="Choose Image" />';
echo '</div>';
}
public function render_repeat_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::EVENT_REPETITION_POST_NONCENAME );
$repeatInfo = get_post_meta($post->ID, 'mhg_repeat_interval', true );
$eventsRepeat = isset($repeatInfo['repeat']) && $repeatInfo['repeat'] ? "checked" : "";
$repeatPattern = isset($repeatInfo['repeatPattern']) ? $repeatInfo['repeatPattern'] : array(
"daily" => "checked",
"weekly" => "",
"monthly" => ""
);
//day values
$daily_day_interval = $repeatInfo['daily-day-interval'];
//week values
$weekly_day_interval = $repeatInfo['weekly-day-interval'];
$weeklyDay = $repeatInfo["weekly-day"];
if (!is_array($weeklyDay)) {
$weeklyDay = array($weeklyDay);
}
$weekly = array();
for ($i=0; $i<7; $i++) {
$weekly["".$i] = in_array($i."", $weeklyDay) ? "checked" : "";
}
$dates = $repeatInfo['repeatDates'];
//month values
$day_checked = $repeatInfo['monthly-repeat-type-day'];
$day_interval = $repeatInfo['monthly_day_repetition'];
$pattern_checked = $repeatInfo['monthly-repeat-type-pattern'];
$interval_option = $repeatInfo['monthly-repeat-interval-option'];
$interval_day = $repeatInfo['monthly-repeat-interval-day'];
$options = array('first', 'second', 'third', 'fourth', 'last');
$selectedOptions = array();
foreach ($options as $option) {
$selectedOptions[$option] = $interval_option && $interval_option == $option ? "selected" : "";
}
$days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$selectedDays = array();
foreach ($days as $day) {
$selectedDays[$day] = $interval_day && $interval_day == $day ? "selected" : "";
}
$variable = <<<WP_CONTENT
<div style="width: 100%;overflow: auto">
<input id="repeatCheckbox" type="checkbox" name="repeat" value="repeat" style="margin: 0 0 0 10px;" {$eventsRepeat} > Repeat
<div id="repetition-box" >
<br>
<input class="dailyRadio" type="radio" name="repeatPattern" value="daily" style="margin: 0 0 0 10px;" {$repeatPattern["daily"]}>
Daily
<input class="weeklyRadio" type="radio" name="repeatPattern" value="weekly" style="margin: 0 0 0 10px;" {$repeatPattern["weekly"]}>
Weekly
<input class="montlyRadio" type="radio" name="repeatPattern" value="monthly" style="margin: 0 0 0 10px;" {$repeatPattern["monthly"]}>
Montly
<div id="container" style="margin: 10px;">
<div class="repetition-container daily-container">
<br>
Every <input type="number" name="daily-day-interval" value="{$daily_day_interval}"> day(s)
<br>
</div>
<div class="repetition-container weekly-container">
<div>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="0" name="weekly-day[]" {$weekly["1"]}> Sunday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="1" name="weekly-day[]" {$weekly["2"]}> Monday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="2" name="weekly-day[]" {$weekly["3"]}> Tuesday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="3" name="weekly-day[]" {$weekly["4"]}> Wednesday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="4" name="weekly-day[]" {$weekly["5"]}> Thrusday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="5" name="weekly-day[]" {$weekly["6"]}> Friday </label>
<label class="event-td-title" style="margin-right: 10px;"><input type="checkbox" value="6" name="weekly-day[]" {$weekly["7"]}> Saturday </label>
</div>
<div style=" margin-top:10px;">
Every <input type="number" name="weekly-day-interval" value="{$weekly_day_interval}"> week(s)
</div>
</div>
<div class="repetition-container monthly-container">
<label class="meta-sub-title">Monthly</label>
<div>
<label class="event-td-title" style="margin-right: 10px;">
<input type="radio" name="monthly-type" value="day" {$day_checked}>
Day
<input type="number" name="monthly_day_repetition" placeholder='20' value='{$day_interval}'>
of every month
</label>
<br/>
<br/>
<label class="event-td-title" style="margin-right: 10px;">
<input type="radio" name="monthly-type" value="pattern" {$pattern_checked}>
The
<select name="interval_option">
<option value="first" {$selectedOptions["first"]} >first</option>
<option value="second" {$selectedOptions["second"]}>second</option>
<option value="third" {$selectedOptions["third"]} >third</option>
<option value="fourth" {$selectedOptions["fourth"]}>fourth</option>
<option value="last" {$selectedOptions["last"]} >last</option>
</select>
<select name="interval_day">
<option value="Sunday" {$selectedDays["Sunday"]} > Sunday </option>
<option value="Monday" {$selectedDays["Monday"]} > Monday </option>
<option value="Tuesday" {$selectedDays["Tuesday"]} > Tuesday </option>
<option value="Wednesday" {$selectedDays["Wednesday"]} > Wednesday </option>
<option value="Thrusday" {$selectedDays["Thrusday"]} > Thrusday </option>
<option value="Friday" {$selectedDays["Friday"]} > Friday </option>
<option value="Saturday" {$selectedDays["Saturday"]} > Saturday </option>
</select>
of every month
</label>
</div>
</div>
<br>
<hr>
<div id="range-box">
<label class="event-td-title" style="margin-right: 10px;"> Repetition Interval </label>
<br>
<br>
<label class="event-td-title" style="margin-right: 10px;"> Start: <input type="text" event-action="date-from" name="ev_rep_from_date[]" value="{$dates['from']}"/></label>
<label class="event-td-title" style="margin-right: 10px;"> End: <input type="text" event-action="date-to" name="ev_rep_to_date[]" value="{$dates['to']}"/></label>
</div>
</div>
</div>
</div>
WP_CONTENT;
echo $variable;
}
public function render_event_info_meta_box_content($post, $metabox)
{
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), self::EVENT_POST_NONCENAME );
$events = get_post_meta($post->ID, 'mhg_event_list', true);
$events = empty($events)? array(): $events;
$eventsSize = count($events);
$eventCount = $eventsSize == 0? 1 : $eventsSize;
echo '<div style="width: 100%">';
echo '<div id="eventContainer" style="width: 100%">';
if ($eventsSize != 0)
{
$eventDeleteVisible = $eventsSize > 1? '':'none';
foreach ($events as $key => $event)
{
if ($key != 0)
{
$nextId = $key + 1;
echo '<hr id="ev_hr_'.$nextId.'"/>';
}
$this->addEventInfoStructure($key, $event, $eventDeleteVisible, true);
}
}
else
{
$this->addEventInfoStructure(0, null, 'none', false);
}
echo '</div>';
echo '<input id="event_last_index" type="hidden" value="'.$eventCount.'">';
echo '<div style="text-align: right; width: 100%">';
echo '<input id="event_add_new" class="button" type="button" style="display:none" value="+ Add Another Event"/>';
echo '</div>';
echo '<div id="event_dialog" title="Confirmation Required" style="min-height: 40px;">';
echo '<b>Are you sure you want to remove this?</b><br> (you must save the post for changes to take effect)';
echo '</div>';
echo '<div id="event_dialog_error" title="Date error" style="min-height: 40px;">';
echo '<b>Error: Invalid dates</b> ';
echo '</div>';
echo '</div>';
}
private function addEventInfoStructure($index, $event, $displayDelete, $haveEvent)
{
$index_id = $index + 1;
$title = $haveEvent? $event['title'] : "";
$location = $haveEvent? $event['location'] : "";
$map = $haveEvent? $event['map'] : "";
$website = $haveEvent? $event['website'] : "";
$address = $haveEvent? $event['address'] : "";
$dates = $haveEvent? $event['dates'] : array();
$more = $haveEvent? (isset($event['more'])? $event['more']: array()) : array();
$datePos = !$haveEvent? 1: count($dates);
echo '<div event-info="'.$index_id.'" style="width: 100%">';
echo '<table border="0" style="width:100%;display:'.($index_id==1?'block':'none').'">';
echo '<tr>';
echo '<td class="event-td-title">Web Site</td>';
echo '<td><input id="ev_inf_website'.$index_id.'" name="ev_inf_website'.$index_id.'" type="url" class="where-td-input" value="'.$website.'"></input></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="event-td-title" style="vertical-align: top; padding-top: 8px;">More Info</td>';
echo '<td>';
// More Section
echo '<table id="ev_inf_table'.$index_id.'" style="width: 100%; margin: 0 -3px;">';
foreach ($more as $key => $morefield)
{
$index = $key + 1;
echo '<tr id="ev_inf_tr'.$index_id.'_'.$index.'">';
echo '<td style="width: 150px;">';
echo '<input name="ev_inf_title_more'.$index_id.'[]" type="text" class="where-td-input" readonly="readonly" value="'.$morefield['title'].'"></input>';
echo '</td> <td>';
echo '<input name="ev_inf_desc_more'.$index_id.'[]" type="text" class="where-td-input" readonly="readonly" value="'.$morefield['description'].'"></input>';
echo '</td><td style="width: 30px;">';
echo '<input event-action="del-more" type="button" class="button" value="x"></input>';
echo '</td></tr>';
}
echo '<tr id="ev_inf_add_tr'.$index_id.'">';
echo '<td style="width: 150px;">';
echo '<input id="ev_inf_title_more'.$index_id.'" type="text" class="where-td-input" value=""></input>';
echo '</td>';
echo '<td>';
echo '<input id="ev_inf_desc_more'.$index_id.'" type="text" class="where-td-input" value=""></input>';
echo '</td>';
echo '<td style="width: 30px;">';
echo '<input id="ev_inf_add_more'.$index_id.'" event-action="add-more" event-index="'.$index_id.'" type="button" class="button" value=">"></input>';
echo '</td>';
echo '</tr>';
echo '</table>';
// End More Section
echo '</td>';
echo '</tr>';
echo '</table>';
echo '<hr/>';
echo '<table border="0" style="width:100%">';
echo '<tr>';
echo '<td class="event-td-title">Title</td>';
echo '<td><input id="ev_inf_title'.$index_id.'" name="ev_inf_title'.$index_id.'" type="text" class="where-td-input" value="'.$title.'"></input></td>';
echo '</tr>';
echo '<tr>';
echo '<td />';
echo '<td>(Useful if you want to add multiple distinct events to this article.)</td>';
echo '</tr>';
echo '</table>';
// Date section
echo '<div id="ev_inf_date_container'.$index_id.'" style="width:100%; background-color: #EDEDED;">';
echo '<input id="ev_date_last_index_'.$index_id.'" type="hidden" value="'.$datePos.'" />';
if ($haveEvent)
{
$dateDeleteVisible = count($dates) > 1? '':'none';
foreach ($dates as $key => $date)
{
$this->event_add_date($index_id, $key, $dateDeleteVisible, $date, true);
}
}
else
{
$this->event_add_date($index_id, 0, 'none', null, false);
}
$address_list = array(
'Hudson New York 356 West 58th Street New York, NY',
'Royalton Hotel 44 West 44th Street New York, NY',
'Morgans Hotel 237 Madison Avenue New York, NY',
'Mondrian Soho 9 Crosby Street New York, NY',
'Mr. H 150 Lafayette Street New York, NY 10013',
'Delano South Beach 1685 Collins Avenue Miami Beach, FL',
'The Shore Club 1901 Collins Avenue Miami Beach, FL',
'Mondrian South Beach 1100 West Avenue Miami Beach, FL',
'Sanderson Hotel 50 Berners Street London W1T 3NG, United Kingdom',
'St Martins Lane 45 St Martin\'s Lane London WC2N 4HX, United Kingdom',
'Ames Hotel 1 Court Street Boston, MA',
'Mondrian LA 8440 Sunset Boulevard West Hollywood, CA',
'Delano Marrakech Angle Av. Echouhada et Rue des Temples Marrakech, Mo 40000',
'Clift Hotel 495 Geary Street San Francisco, CA',
);
echo '</div>';
// End Date Section
echo '<table border="0" style="width:100%">';
echo '<tr >';
echo '<td class="event-td-title">Location</td>';
echo '<td><input id="ev_inf_location'.$index_id.'" name="ev_inf_location'.$index_id.'" type="text" class="where-td-input" value="'.$location.'"></input></td>';
echo '</tr>';
echo '<tr>';
echo '<td class="event-td-title">Address</td>';
echo '<td><select style="width:500px" data-placeholder="Choose a hotel..." id="ev_inf_address'.$index_id.'" name="ev_inf_address'.$index_id.'" class="where-td-input chzn-select">';
echo '<option value=""></option>';
foreach ( $address_list as $addr ) {
echo '<option value="'. $addr .'"'. ( $address == $addr ? ' selected': '' ) .'>'. $addr .'</option>';
}
echo '</select> <tr><td></td><td>other address: <input style="width:500px" class="where-td-input-other" type="text" name="ev_inf_address_other'.$index_id.'" value="'. $address .'"></td></tr>';
echo '</tr>';
echo '<tr>';
echo '<td class="event-td-title">Map Url</td>';
echo '<td><input id="ev_inf_map'.$index_id.'" name="ev_inf_map'.$index_id.'" type="url" class="where-td-input" value="'.$map.'"></input></td>';
echo '</tr>';
echo '</table>';
echo '<input id="ev_more_last_index_'.$index_id.'" type="hidden" value="'.count($more).'" />';
echo '<div >';
echo '<input event-action="event-delete" event-id="'.$index_id.'" class="button" type="button" value="- Delete this event" style="display:'.$displayDelete.'"/>';
echo '<input name="event_id[]" value="'.$index_id.'" type="hidden"/>';
echo '</div>';
echo '</div>';
}
function event_add_date($index_id, $pos_index, $displayDelete, $date, $haveDate)
{
$position = $pos_index + 1;
$repeatReadonly = $haveDate? ($date['repeat'] == 'false'? 'readonly="true"': '') : 'readonly="true"';
$repeat = $date['repeat'] == 'true'? 'checked': '';
$fdate = $haveDate? $date['from'] : '';
$fhour = $haveDate? $date['from_hour'] : '12:00 pm';
$tdate = $haveDate? $date['to'] : '';
$thour = $haveDate? $date['to_hour'] : '12:00 pm';
$repeatText = $haveDate? $date['repeat_text'] : '';
$allDay = $fhour == 'All day'? 'checked': '';
$viewTo = $tdate == ''? 'none': '';
$viewButtonTo = $tdate != ''? 'none': '';
echo '<table id="ev_inf_date_table'.$index_id.'_'.$position.'" table-position="main" border="0" style="width:100%">';
echo '<tr>';
echo '<td class="event-td-title">From</td>';
echo '<td>';
echo '<table style="width: 100%; margin: 0 -3px;">';
echo '<tr>';
echo '<td class="event-td-date">';
echo '<input type="text" style="width: 100%;" event-action="date-from" name="ev_inf_from_date'.$index_id.'[]" value="'.$fdate.'"/>';
echo '</td>';
echo '<td class="event-td-date">';
echo '<select id="ev_inf_from_hour'.$index_id.'_'.$position.'" event-action="select-hour" hour-action="select-from" hour-selected="'.$fhour.'" name="ev_inf_from_hour'.$index_id.'[]">';
$this->event_add_hours_options();
echo '</select>';
echo '</td>';
echo '<td class="event-td-date">';
echo '<input id="ev_inf_all_ck'.$index_id.'_'.$position.'" event-action="from-ck" type="checkbox" '.$allDay.'> All day</input>';
echo '</td>';
echo '<td class="event-td-date">';
echo '<input id="ev_inf_add_to'.$index_id.'_'.$position.'" event-action="add-to" type="button" class="button" value="Add end time" style="display: '.$viewButtonTo.';">';
echo '</td>';
echo '<td style="text-align: right;">';
echo '<input class="button" type="button" date-position="'.$position.'" event-id="'.$index_id.'" event-action="del-date" value="Delete this date" style="display:'.$displayDelete.'"/>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
echo '<tr id="ev_inf_to'.$index_id.'_'.$position.'" style="display: '.$viewTo.';" >';
echo '<td class="event-td-title">To</td>';
echo '<td>';
echo '<table style="width: 100%; margin: 0 -3px;">';
echo '<tr>';
echo '<td class="event-td-date">';
echo '<input type="text" style="width: 100%;" event-action="date-to" name="ev_inf_to_date'.$index_id.'[]" value="'.$tdate.'"/>';
echo '</td>';
echo '<td class="event-td-date">';
echo '<select id="ev_inf_to_hour'.$index_id.'_'.$position.'" event-action="select-hour" hour-selected="'.$thour.'" name="ev_inf_to_hour'.$index_id.'[]">';
$this->event_add_hours_options();
echo '</select>';
echo '</td>';
echo '<td class="event-td-date">';
echo '<input id="ev_inf_del_to'.$index_id.'_'.$position.'" event-action="del-to" type="button" class="button" value="x">';
echo '</td>';
echo '<td>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="event-td-title"></td>';
echo '<td>';
echo '<table style="width: 100%; margin: 0 -3px;">';
echo '<tr style="display:none">';
echo '<td style="width:60px;">';
echo '<input id="ev_inf_repeat_ck'.$index_id.'_'.$position.'" event-action="repeat-ck" type="checkbox" '.$repeat.'> Repeat</input> ';
echo '</td>';
echo '<td>';
echo '<input id="ev_inf_repeat_text'.$index_id.'_'.$position.'" name="ev_inf_repeat'.$index_id.'[]" type="text" class="where-td-input" '.$repeatReadonly.' value="'.$repeatText.'"></input></td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
function event_add_hours_options()
{
$hours = array('All day', '12:30 am',
'1:00 am', '1:30 am',
'2:00 am', '2:30 am',
'3:00 am', '3:30 am',
'4:00 am', '4:30 am',
'5:00 am', '5:30 am',
'6:00 am', '6:30 am',
'7:00 am', '7:30 am',
'8:00 am', '8:30 am',
'9:00 am', '9:30 am',
'10:00 am', '10:30 am',
'11:00 am', '11:30 am',
'12:00 pm', '12:30 pm',
'1:00 pm', '1:30 pm',
'2:00 pm', '2:30 pm',
'3:00 pm', '3:30 pm',
'4:00 pm', '4:30 pm',
'5:00 pm', '5:30 pm',
'6:00 pm', '6:30 pm',
'7:00 pm', '7:30 pm',
'8:00 pm', '8:30 pm',
'9:00 pm', '9:30 pm',
'10:00 pm', '10:30 pm',
'11:00 pm', '11:30 pm', '12:00 am');
echo '<options>';
foreach ($hours as $hour)
{
echo '<option >'.$hour.'</option>';
}
echo '</options>';
}
/* When the post is saved, saves our custom data */
function custom_save_postdata( $post_id ) {
// verify if this is an auto save routine.
// If it is our form has not been submitted, so we dont want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post->ID;
if (empty($_POST['post_type']))
return;
if ( strtolower(self::POST_TYPE) == strtolower($_POST['post_type']) )
{
if ( wp_verify_nonce( $_POST[self::TRAF_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$traf = array();
if(isset($_POST['traffic']))
{
$traf = $_POST['traffic'];
}
add_post_meta($post_id, 'mhg_traf_data', $traf, true) or update_post_meta($post_id, 'mhg_traf_data', $traf);
}
if ( wp_verify_nonce( $_POST[self::FEAT_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$feat = array();
if(isset($_POST['ft']))
{
$feat = $_POST['ft'];
}
add_post_meta($post_id, 'mhg_feat_data', $feat, true) or update_post_meta($post_id, 'mhg_feat_data', $feat);
}
if ( wp_verify_nonce( $_POST[self::TYPE_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$type;
$cate;
$tax = 'category';
if (isset($_POST['typeSelector']))
$type = $_POST['typeSelector'];
switch ($_POST['typeSelector'])
{
case 'Event':
$cate = get_category_by_slug('mhg-event-type')->term_id;
break;
case 'Place':
$cate = get_category_by_slug('mhg-place-type')->term_id;
break;
case 'Article':
$cate = get_category_by_slug('mhg-article-type')->term_id;
break;
}
wp_set_post_terms( $post_id, $cate, $tax, true );
add_post_meta($post_id, 'mhg_type_data', $type, true) or update_post_meta($post_id, 'mhg_type_data', $type);
}
//Custom post order meta
if ( wp_verify_nonce( $_POST[self::HOME_ORDER_NONCENAME], plugin_basename( __FILE__ ) ) )
{
//Home Order
if (isset($_POST['homeOrder'])) {
$homeOrder = $_POST['homeOrder'];
}
add_post_meta($post_id, 'mhg_home_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_home_order_data', $homeOrder);
//Boston Order
if (isset($_POST['bostonOrder'])) {
$homeOrder = $_POST['bostonOrder'];
}
add_post_meta($post_id, 'mhg_boston_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_boston_order_data', $homeOrder);
//London Order
if (isset($_POST['londonOrder'])) {
$homeOrder = $_POST['londonOrder'];
}
add_post_meta($post_id, 'mhg_london_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_london_order_data', $homeOrder);
//Los Angeles Order
if (isset($_POST['losangelesOrder'])) {
$homeOrder = $_POST['losangelesOrder'];
}
add_post_meta($post_id, 'mhg_losangeles_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_losangeles_order_data', $homeOrder);
//Marrakech Order
if (isset($_POST['marrakechOrder'])) {
$homeOrder = $_POST['marrakechOrder'];
}
add_post_meta($post_id, 'mhg_marrakech_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_marrakech_order_data', $homeOrder);
//New York Order
if (isset($_POST['newYorkOrder'])) {
$homeOrder = $_POST['newYorkOrder'];
}
add_post_meta($post_id, 'mhg_newyork_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_newyork_order_data', $homeOrder);
//San Francisco Order
if (isset($_POST['sanfranciscoOrder'])) {
$homeOrder = $_POST['sanfranciscoOrder'];
}
add_post_meta($post_id, 'mhg_sanfrancisco_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_sanfrancisco_order_data', $homeOrder);
//South Beach Order
if (isset($_POST['southBeachOrder'])) {
$homeOrder = $_POST['southBeachOrder'];
}
add_post_meta($post_id, 'mhg_southbeach_order_data', $homeOrder, true) or update_post_meta($post_id, 'mhg_southbeach_order_data', $homeOrder);
}
if ( wp_verify_nonce( $_POST[self::FEATURED_POSITION_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
if (isset($_POST['positionSelector']))
$position = strtolower($_POST['positionSelector']);
add_post_meta($post_id, 'featured_content_position', $position, true) or update_post_meta($post_id, 'featured_content_position', $position);
}
if ( wp_verify_nonce( $_POST[self::FEATURED_COLOR_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$position;
if (isset($_POST['colorSelector']))
$color = strtolower($_POST['colorSelector']);
add_post_meta($post_id, 'featured_content_color', $color, true) or update_post_meta($post_id, 'featured_content_color', $color);
}
if ( wp_verify_nonce( $_POST[self::SOURCE_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
if (isset($_POST['source_url']))
add_post_meta($post_id, 'source_url', $_POST['source_url'], true) or update_post_meta($post_id, 'source_url', $_POST['source_url']);
if(isset($_POST['current_src_title']))
{
$title = $_POST['current_src_title'];
add_post_meta($post_id, 'source_title', $title, true) or update_post_meta($post_id, 'source_title', $title);
}
if (!empty($_POST['selected_src_img']))
{
$img_id = $_POST['selected_src_img'];
add_post_meta($post_id, 'source_img_file', $img_id, true) or update_post_meta($post_id, 'source_img_file', $img_id);
}
}
if ( wp_verify_nonce( $_POST[self::SOURCE_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
if (isset($_POST['source_url']))
add_post_meta($post_id, 'source_url', $_POST['source_url'], true) or update_post_meta($post_id, 'source_url', $_POST['source_url']);
if(isset($_POST['current_src_title']))
{
$title = $_POST['current_src_title'];
add_post_meta($post_id, 'source_title', $title, true) or update_post_meta($post_id, 'source_title', $title);
}
if (!empty($_POST['selected_src_img']))
{
$img_id = $_POST['selected_src_img'];
add_post_meta($post_id, 'source_img_file', $img_id, true) or update_post_meta($post_id, 'source_img_file', $img_id);
}
}
if ( wp_verify_nonce( $_POST[self::WHERE_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$locations = $_POST['where_loc'];
$address = $_POST['where_add'];
$zip = $_POST['where_zip'];
$phones = $_POST['where_phone'];
$urls = $_POST['where_url'];
$websites = $_POST['where_website'];
$where_locations = array();
if (is_array($locations) && is_array($address) && is_array($zip) && is_array($urls) && is_array($websites) && is_array($phones))
{
foreach ($locations as $key => $location)
{
$where_locations[] = array('location' =>$locations[$key], 'address'=>$address[$key], 'zip'=>$zip[$key], 'url'=>$urls[$key], 'website'=>$websites[$key], 'phone'=>$phones[$key]);
}
}
add_post_meta($post_id, 'mhg_where_list', $where_locations, true) or update_post_meta($post_id, 'mhg_where_list', $where_locations);
}
if ( wp_verify_nonce( $_POST[self::EVENT_REPETITION_POST_NONCENAME], plugin_basename( __FILE__ ) ) ){
$repeat_info = array();
$event_repeats = isset($_POST['repeat']);
$repeat_info['repeat'] = $event_repeats;
if($event_repeats){
$repeatPattern = $_POST['repeatPattern'];
$repeat_info['repeatPattern'] = array(
"daily" => "",
"weekly" => "",
"monthly" => ""
);
switch($repeatPattern){
case 'daily':
$dailyInterval = isset($_POST['daily-day-interval']) ? $_POST['daily-day-interval'] : 1;
$dailyInterval = intval($dailyInterval) ? (int)$_POST['daily-day-interval'] : 1;
$repeat_info['daily-day-interval'] = $dailyInterval;
$repeat_info['repeatPattern']['daily'] = "checked";
break;
case 'weekly':
$weeklyDayPost = isset($_POST['weekly-day']) ? $_POST['weekly-day'] : array();
$weeklyDay = array();
foreach ($weeklyDayPost as $day) {
if(intval($day)){
array_push($weeklyDay, (int)$day);
}
}
$repeat_info['weekly-day'] = $weeklyDay;
$weeklyInterval = isset($_POST['weekly-day-interval']) ? $_POST['weekly-day-interval'] : 1;
$weeklyInterval = intval($weeklyInterval) ? (int)$_POST['weekly-day-interval'] : 1;
$repeat_info['weekly-day-interval'] = $weeklyInterval;
$repeat_info['repeatPattern']['weekly'] = "checked";
break;
case 'monthly':
$repeat_info['repeatPattern']['monthly'] = "checked";
$monthType = $_POST['monthly-type'];
switch($monthType){
case 'day':
$repeat_info['monthly-repeat-type-day'] = 'checked';
$repeat_info['monthly-repeat-day-interval'] = isset($_POST['monthly_day_repetition']) ? intval($_POST['monthly_day_repetition']) : 1;
break;
case 'pattern':
$repeat_info['monthly-repeat-type-pattern'] = 'checked';
$repeat_info['monthly-repeat-interval-option'] = isset($_POST['interval_option']) ? $_POST['interval_option'] : 'first';
$repeat_info['monthly-repeat-interval-day'] = isset($_POST['interval_day']) ? $_POST['interval_day'] : 'monday';
break;
default:
break;
}
break;
}
$repeat_info['repeatDates'] = array();
$repeat_info['repeatDates']['from'] = isset($_POST['ev_rep_from_date']) && isset($_POST['ev_rep_from_date'][0]) ? $_POST['ev_rep_from_date'][0] : date_format(date('c'), 'm-d-Y');
$repeat_info['repeatDates']['to'] = isset($_POST['ev_rep_to_date']) && isset($_POST['ev_rep_to_date'][0]) ? $_POST['ev_rep_to_date'][0] : date_format(date('c'), 'm-d-Y');
}
add_post_meta($post_id, 'mhg_repeat_interval', $repeat_info, true) or update_post_meta($post_id, 'mhg_repeat_interval', $repeat_info);
}
if ( wp_verify_nonce( $_POST[self::EVENT_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
if (!empty( $_POST['event_id']))
{
$ids = $_POST['event_id'];
$events = array();
$mlocations = false;
$first_location = '';
$maps = 0;
foreach ($ids as $id)
{
$event = array();
if (!empty($_POST['ev_inf_title'.$id]))
{
$location = $_POST['ev_inf_location'.$id];
if ( empty($first_location) ) {
$first_location = $location;
} else {
$mlocations = $first_location !== $location;
}
$map = $_POST['ev_inf_map'.$id];
!empty( $map ) && $maps++;
$event['title'] = $_POST['ev_inf_title'.$id];
$event['location'] = $location;
$event['map'] = $map;
$event['website'] = $_POST['ev_inf_website'.$id];
if ( !empty( $_POST['ev_inf_address_other'.$id] ) ) {
$event['address'] = $_POST['ev_inf_address_other'.$id];
}else{
$event['address'] = $_POST['ev_inf_address'.$id];
}
$dateCount = 0;
$datesFrom = $_POST['ev_inf_from_date'.$id];
$dates = array();
foreach ($datesFrom as $key => $datefrom )
{
if (!empty($datefrom))
{
$dateCount++;
$date = array();
$date['from'] = $datefrom;
$date['from_hour'] = $_POST['ev_inf_from_hour'.$id][$key];
if(!empty($_POST['ev_inf_to_date'.$id][$key]))
{
$date['to'] = $_POST['ev_inf_to_date'.$id][$key];
$date['to_hour'] = $_POST['ev_inf_to_hour'.$id][$key];
}
else
{
$date['to'] = '';
$date['to_hour'] = '';
}
if(!empty($_POST['ev_inf_repeat'.$id][$key]))
{
$date['repeat_text'] = $_POST['ev_inf_repeat'.$id][$key];
$date['repeat'] = true;
}
else
{
$date['repeat_text'] = '';
$date['repeat'] = false;
}
$dates[] = $date;
}
}
if ($dateCount != 0)
{
$event['dates'] = $dates;
if (!empty( $_POST['ev_inf_title_more'.$id]))
{
$mores = array();
$more_titles = $_POST['ev_inf_title_more'.$id];
foreach ($more_titles as $key => $title)
{
$mores[] = array(
'title' => $title,
'description' => $_POST['ev_inf_desc_more'.$id][$key]
);
}
$event['more'] = $mores;
}
$events[] = $event;
}
}
}
$data = array(
'mlocations' => $mlocations,
'mmaps' => $maps > 1
);
add_post_meta($post_id, 'mhg_event_list', $events, true) or update_post_meta($post_id, 'mhg_event_list', $events);
add_post_meta($post_id, 'mhg_event_list_data', $data, true) or update_post_meta($post_id, 'mhg_event_list_data', $data);
}
}
if ( wp_verify_nonce( $_POST[self::BG_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$img = $_POST['upload_image'];
add_post_meta( $post_id, 'mhg_bg_image', $img, true) or update_post_meta( $post_id, 'mhg_bg_image', $img);
}
if ( wp_verify_nonce( $_POST[self::CONTENT_WIDTH_POST_NONCENAME], plugin_basename( __FILE__ ) ) )
{
$width;
if (isset($_POST['widthSelector']))
$width = strtolower($_POST['widthSelector']);
add_post_meta($post_id, 'mhg_content_width', $width, true) or update_post_meta($post_id, 'mhg_content_width', $width);
}
}
}
function post_edit_form_tag() {
echo ' enctype="multipart/form-data"';
}
}
function codex_setup_theme_mhg_post()
{
add_theme_support( 'post-thumbnails', array( 'post' ) );
}
$mpt = new Morgans_Post_Type_Admin;
//hooks...
add_action('admin_enqueue_scripts', array($mpt, 'codex_custom_init'));
add_action( 'save_post', array( $mpt, 'custom_save_postdata') );
add_action('post_edit_form_tag', array( $mpt, 'post_edit_form_tag') );
add_action( 'add_meta_boxes', array( $mpt, 'add_mhg_meta_boxes') );
add_action( 'after_setup_theme', 'codex_setup_theme_mhg_post');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment