Play Zone Settings

// create custom plugin settings menu
add_action(‘admin_menu’, ‘baw_create_menu’);

function baw_create_menu() {

//create new top-level menu
add_menu_page(‘Play Zone Settings’, ‘PlayZone Settings’, ‘administrator’, __FILE__, ‘baw_settings_page’,admin_url(). ‘images/psettings.png’);

//call register settings function
add_action( ‘admin_init’, ‘register_mysettings’ );
}

function register_mysettings() {
//register our settings
register_setting( ‘baw-settings-group’, ‘play_facebook’ );
register_setting( ‘baw-settings-group’, ‘play_twitter’ );
register_setting( ‘baw-settings-group’, ‘play_linkdin’ );
register_setting( ‘baw-settings-group’, ‘play_bb’ );
register_setting( ‘baw-settings-group’, ‘play_wpress’ );
register_setting( ‘baw-settings-group’, ‘play_pintrest’ );
register_setting( ‘baw-settings-group’, ‘play_gplus’ );
register_setting( ‘baw-settings-group’, ‘play_contactus’ );
register_setting( ‘baw-settings-group’, ‘play_map’ );
register_setting( ‘baw-settings-group’, ‘play_mailto’ );
register_setting( ‘baw-settings-group’, ‘play_adminemail’ );
register_setting( ‘baw-settings-group’, ‘play_youtube’ );
register_setting( ‘baw-settings-group’, ‘play_video’ );
register_setting( ‘baw-settings-group’, ‘play_phone1′ );
register_setting( ‘baw-settings-group’, ‘play_phone2′ );
register_setting( ‘baw-settings-group’, ‘play_copyright’ );

}

function baw_settings_page() {
?>
<script type=”text/javascript”>
jQuery(document).ready(function() {
jQuery(“#first_formost”).addClass(“mceEditor”);
if ( typeof( tinyMCE ) == “object” &&
typeof( tinyMCE.execCommand ) == “function” ) {
tinyMCE.execCommand(“mceAddControl”, false, “first_formost”);
}
});
</script>

<h2>Play Zone Setings</h2>
<form method=”post” action=”options.php”>
<?php settings_fields( ‘baw-settings-group’ ); ?>
<div>
<?php include(‘inc/tabsettings.php’); ?>
<?php submit_button(); ?>
</div>

</form>
<?php }

add_action(‘init’, ‘contacts’);
function contacts() {

$labels = array(
‘name’ => _x(‘Contact Us’, ‘post type general name’),
‘singular_name’ => _x(‘Contact List’, ‘post type singular name’),
‘add_new’ => _x(”, ”),
‘add_new_item’ => __(”),s
‘new_item’ => __(”),
‘edit_item’ => __(‘Edit Contact List’),
‘view_item’ => __(‘View Contact List’),
‘search_items’ => __(‘Search Contact’),
‘not_found’ =>  __(‘Nothing found’),
‘not_found_in_trash’ => __(‘Nothing found in Trash’),
‘parent_item_colon’ => ”
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘query_var’ => true,
‘menu_icon’ => admin_url(). ‘images/contacts.png’,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => array(‘title’)
);

register_post_type( ‘contacts’ , $args );
}

add_action(“admin_init”, “contact_init”);

function contact_init(){

add_meta_box(“contact_list”, “Contact Information”, “contact_list”, “contacts”, “normal”, “low”);
}

function contact_list() {
global $post;
$customs = get_post_custom($post->ID);

$email = $customs[“email”][0];
$phonenumber = $customs[“phonenumber”][0];
$pcategory = $customs[“pcategory”][0];
$message = $customs[“message”][0];
$address = $customs[“address”][0];
$fromstart = $customs[“fromstart”][0];
$fromend = $customs[“fromend”][0];
$tostart = $customs[“tostart”][0];
$toend = $customs[“toend”][0];
?>

<p><label>Email:</label><br />
<input type=”text” name=”email” value=”<?php echo $email; ?>” /></p>

<p><label>Phone Number:</label><br />
<input type=”text” name=”phonenumber” value=”<?php echo $phonenumber; ?>” /></p>

<p><label>Product Category:</label><br />
<input type=”text” name=”pcategory” value=”<?php echo $pcategory; ?>” /></p>

<p><label> Event Date / Time (From):</label><br />
<input type=”text” name=”fromstart” value=”<?php echo $fromstart; ?>” />
<input type=”text” name=”fromend” value=”<?php echo $fromend; ?>” />
</p>

<p><label> Event Date / Time (To):</label><br />
<input type=”text” name=”tostart” value=”<?php echo $tostart; ?>” />
<input type=”text” name=”toend” value=”<?php echo $toend; ?>” />
</p>

<p><label>Address:</label><br />
<textarea cols=”80″ rows=”4″ name=”address”><?php echo $address; ?></textarea></p>

<p><label>Mesaage:</label><br />
<textarea cols=”80″ rows=”4″ name=”message”><?php echo $message; ?></textarea></p>
<?php
}

add_action(‘save_post’, ‘save_contactlist’);

function save_contactlist(){
global $post;

update_post_meta($post->ID, “email”, $_POST[“email”]);
update_post_meta($post->ID, “phonenumber”, $_POST[“phonenumber”]);
update_post_meta($post->ID, “pcategory”, $_POST[“pcategory”]);
update_post_meta($post->ID, “address”, $_POST[“address”]);
update_post_meta($post->ID, “message”, $_POST[“message”]);
update_post_meta($post->ID, “message”, $_POST[“tostart”]);
update_post_meta($post->ID, “message”, $_POST[“toend”]);
update_post_meta($post->ID, “message”, $_POST[“fromstart”]);
update_post_meta($post->ID, “message”, $_POST[“fromend”]);
}

add_action(“manage_posts_custom_column”,  “contacts_custom_columns”);
add_filter(“manage_edit-contacts_columns”, “contacts_edit_columns”);

function contacts_edit_columns($pcolumns) {

$pcolumns = array(
“cb” => “<input type=\”checkbox\” />”,
“title” => “Name”,
“email” => “Email”,
“phonenumber” => “Phone Number”,
);

return $pcolumns;
}

function contacts_custom_columns($pcolumn){
global $post;

$meta = get_post_meta($post->ID);

switch ($pcolumn) {
case “email”:

echo  $meta[’email’][0];

break;
case “phonenumber”:

echo  $meta[‘phonenumber’][0];

break;
}
}

function wpbeginner_numeric_posts_nav() {

if( is_singular() )
return;

global $wp_query;

/** Stop execution if there’s only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;

$paged = get_query_var( ‘paged’ ) ? absint( get_query_var( ‘paged’ ) ) : 1;
$max   = intval( $wp_query->max_num_pages );

/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;

/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged – 1;
$links[] = $paged – 2;
}

if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}

echo ‘<ul>’ . “\n”;

/** Previous Post Link */

/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ” : ”;

printf( ‘<li%s><a href=”%s”>%s</a></li>’ . “\n”, $class, esc_url( get_pagenum_link( 1 ) ), ’1′ );

if ( ! in_array( 2, $links ) )
echo ‘<li> << </li>’;
}

/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ” : ”;
printf( ‘<li%s><a href=”%s”>%s</a></li>’ . “\n”, $class, esc_url( get_pagenum_link( $link ) ), $link );
}

/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max – 1, $links ) )
echo ‘<li> >> </li>’ . “\n”;

$class = $paged == $max ? ” : ”;
printf( ‘<li%s><a href=”%s”>%s</a></li>’ . “\n”, $class, esc_url( get_pagenum_link( $max ) ), $max );
}

/** Next Post Link */

echo ‘</ul>’ . “\n”;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s