Created
October 25, 2016 09:31
-
-
Save aslamhindko/1d5077c4343355893fa14c0f23a6c65c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Ye Code Function file main dena hain themepanel or postype file ko assets k folder rakhna hain --> | |
<!-- require get_template_directory() . '/assets/themepanel.php'; | |
require get_template_directory() . '/assets/post-type.php'; --> | |
<?php | |
function theme_settings_page() | |
{ | |
?> | |
<div class="wrap"> | |
<h1>Theme Panel</h1> | |
<form method="post" action="options.php"> | |
<?php | |
settings_fields("section"); | |
do_settings_sections("theme-options"); | |
submit_button(); | |
?> | |
</form> | |
</div> | |
<?php | |
} | |
function add_theme_menu_item() | |
{ | |
add_menu_page("Theme Panel", "Theme Panel", "manage_options", "theme-panel", "theme_settings_page", null, 99); | |
} | |
add_action("admin_menu", "add_theme_menu_item"); | |
function display_phone_element() | |
{ | |
?> | |
<input type="text" name="phone_no" id="phone_no" value="<?php echo get_option('phone_no'); ?>" /> | |
<?php | |
} | |
function display_email_element() | |
{ | |
?> | |
<input type="text" name="email_address" id="email_address" value="<?php echo get_option('email_address'); ?>" /> | |
<?php | |
} | |
function display_address_element() | |
{ | |
?> | |
<input type="text" name="address" id="address" value="<?php echo get_option('address'); ?>" /> | |
<?php | |
} | |
function display_twitter_element() | |
{ | |
?> | |
<input type="text" name="twitter_url" id="twitter_url" value="<?php echo get_option('twitter_url'); ?>" /> | |
<?php | |
} | |
function display_facebook_element() | |
{ | |
?> | |
<input type="text" name="facebook_url" id="facebook_url" value="<?php echo get_option('facebook_url'); ?>" /> | |
<?php | |
} | |
function display_google_element() | |
{ | |
?> | |
<input type="text" name="google_url" id="google_url" value="<?php echo get_option('google_url'); ?>" /> | |
<?php | |
} | |
function display_linkedin_element() | |
{ | |
?> | |
<input type="text" name="linkedin_url" id="linkedin_url" value="<?php echo get_option('linkedin_url'); ?>" /> | |
<?php | |
} | |
function display_SMS_element() | |
{ | |
?> | |
<input type="text" name="sms_url" id="sms_url" value="<?php echo get_option('sms_url'); ?>" /> | |
<?php | |
} | |
function display_map_element() | |
{ | |
?> | |
<input type="text" name="map_url" id="map_url" value="<?php echo get_option('map_url'); ?>" /> | |
<?php | |
} | |
function display_theme_panel_fields() | |
{ | |
add_settings_section("section", "All Settings", null, "theme-options"); | |
add_settings_field("phone_no", "Phone Number", "display_phone_element", "theme-options", "section"); | |
add_settings_field("email_address", "Email ID", "display_email_element", "theme-options", "section"); | |
add_settings_field("address", "Address", "display_address_element", "theme-options", "section"); | |
add_settings_field("twitter_url", "Twitter Profile Url", "display_twitter_element", "theme-options", "section"); | |
add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "theme-options", "section"); | |
add_settings_field("google_url", "Google Profile Url", "display_google_element", "theme-options", "section"); | |
add_settings_field("linkedin_url", "LinkedIn Profile Url", "display_linkedin_element", "theme-options", "section"); | |
add_settings_field("sms_url", "SMS", "display_sms_element", "theme-options", "section"); | |
add_settings_field("map_url", "MAP", "display_map_element", "theme-options", "section"); | |
register_setting("section", "phone_no"); | |
register_setting("section", "email_address"); | |
register_setting("section", "address"); | |
register_setting("section", "twitter_url"); | |
register_setting("section", "facebook_url"); | |
register_setting("section", "google_url"); | |
register_setting("section", "linkedin_url"); | |
register_setting("section", "sms_url"); | |
register_setting("section", "map_url"); | |
} | |
add_action("admin_init", "display_theme_panel_fields"); | |
?> | |
<!--Postype File --> | |
<?php | |
/** | |
* Registers a new post type | |
* @uses $wp_post_types Inserts new post type object into the list | |
* | |
* @param string Post type key, must not exceed 20 characters | |
* @param array|string See optional args description above. | |
* @return object|WP_Error the registered post type object, or an error object | |
*/ | |
function Sliderhome() { | |
$labels = array( | |
'name' => __( 'Home Slider', 'text-domain' ), | |
'singular_name' => __( 'slide', 'text-domain' ), | |
'add_new' => _x( 'Add New slide', 'text-domain', 'text-domain' ), | |
'add_new_item' => __( 'Add New slide', 'text-domain' ), | |
'edit_item' => __( 'Edit slide', 'text-domain' ), | |
'new_item' => __( 'New slide', 'text-domain' ), | |
'view_item' => __( 'View slide', 'text-domain' ), | |
'search_items' => __( 'Search Home Slider', 'text-domain' ), | |
'not_found' => __( 'No Home Slider found', 'text-domain' ), | |
'not_found_in_trash' => __( 'No Home Slider found in Trash', 'text-domain' ), | |
'parent_item_colon' => __( 'Parent slide:', 'text-domain' ), | |
'menu_name' => __( 'Home Slider', 'text-domain' ), | |
); | |
$args = array( | |
'labels' => $labels, | |
'hierarchical' => false, | |
'description' => 'description', | |
'taxonomies' => array(), | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_admin_bar' => true, | |
'menu_position' => null, | |
'menu_icon' => null, | |
'show_in_nav_menus' => true, | |
'publicly_queryable' => true, | |
'exclude_from_search' => false, | |
'has_archive' => true, | |
'query_var' => true, | |
'can_export' => true, | |
'rewrite' => true, | |
'capability_type' => 'post', | |
'supports' => array( | |
'title', 'editor', 'author', 'thumbnail', | |
'excerpt','custom-fields', 'trackbacks', 'comments', | |
'revisions', 'page-attributes', 'post-formats' | |
) | |
); | |
register_post_type( 'main_slider', $args ); | |
} | |
add_action( 'init', 'Sliderhome' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment