コード例 #1
0
function show_box_funtion($fields, $first = 'no', $width = '60')
{
    global $post, $post_id;
    if ($first == "yes") {
        echo '<input type="hidden" name="sticky_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    }
    if ($width != 0) {
        echo '<table class="form-table">';
    }
    foreach ($fields['fields'] as $field) {
        // get current post meta data
        $meta = get_post_meta($post->ID, $field['id'], true);
        //$post_num = htmlentities($_GET['post']);
        if ($width != 0) {
            echo '<tr>';
            echo '<th style="width:', $width, '%"><label for="', $field['id'], '">', $field['name'], '</label></th>';
            echo '<td>';
        }
        switch ($field['type']) {
            case 'text':
                echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" ', $meta ? ' ' : '', ' value="', $meta ? remove_html_slashes($meta) : remove_html_slashes($field['std']), '"/> ';
                break;
            case 'datepicker':
                echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" ', $meta ? ' ' : '', ' value="', $meta ? date("m/d/y, H:i", remove_html_slashes($meta)) : remove_html_slashes($field['std']), '"/> ';
                break;
            case 'slider_image_box':
                echo '<input class="upload input-text-1 ot-upload-field" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? remove_html_slashes($meta) : remove_html_slashes($field['std']), '" style="width: 140px;"/><a href="#" class="ot-upload-button">Button</a>';
                break;
            case 'image_select':
                ot_gallery_image_select($field['id'], $meta);
                break;
            case 'checkbox':
                echo '<input type="checkbox" value="1" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
                break;
            case 'sidebar_select_box':
                $sidebar_names = get_option(THEME_NAME . "_sidebar_names");
                $sidebar_names = explode("|*|", $sidebar_names);
                echo '	<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                echo "<option value=\"\">Default</option>";
                foreach ($sidebar_names as $sidebar_name) {
                    if ($meta == $sidebar_name) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($sidebar_name != "") {
                        echo "<option value=\"" . $sidebar_name . "\" " . $selected . ">" . $sidebar_name . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'sidebar_select_box_small':
                $sidebar_names = get_option(THEME_NAME . "_sidebar_names");
                $sidebar_names = explode("|*|", $sidebar_names);
                if ($meta == "default") {
                    $selected = "selected=\"selected\"";
                } else {
                    $selected = "";
                }
                echo '	<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                echo "<option value=\"off\">Off</option>";
                echo "<option value=\"default\" " . $selected . ">Default</option>";
                foreach ($sidebar_names as $sidebar_name) {
                    if ($meta == $sidebar_name) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($sidebar_name != "") {
                        echo "<option value=\"" . $sidebar_name . "\" " . $selected . ">" . $sidebar_name . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'category_select':
                global $wpdb;
                $data = get_terms("category", 'parent=0&hide_empty=0');
                echo '	<select name="', $field['id'], '[]" id="', $field['id'], '" style="min-width:200px; min-height:200px;" multiple>';
                foreach ($data as $key => $d) {
                    if (is_array($meta) && in_array($d->term_id, $meta)) {
                        $selected = ' selected';
                    } else {
                        $selected = '';
                    }
                    echo "<option value=\"" . $d->term_id . "\" " . $selected . ">" . $d->name . "</option>";
                }
                echo '	</select>';
                break;
            case 'breaking_cat':
                global $wpdb;
                $data = get_terms("category", 'parent=0&hide_empty=0');
                if ($meta == "slider_off" || !$meta) {
                    $selected = "selected=\"selected\"";
                }
                echo '	<select name="', $field['id'], '[]" id="', $field['id'], '" style="min-width:200px; min-height:200px;" multiple>';
                echo '<option value="slider_off" ' . $selected . '>' . __("Off", THEME_NAME) . '</option>';
                foreach ($data as $key => $d) {
                    if (is_array($meta) && in_array($d->term_id, $meta)) {
                        $selected = ' selected';
                    } else {
                        $selected = '';
                    }
                    echo "<option value=\"" . $d->term_id . "\" " . $selected . ">" . $d->name . "</option>";
                }
                echo '	</select>';
                break;
            case 'category_select_2':
                global $wpdb;
                $data = get_terms("category", 'parent=0&hide_empty=0');
                echo '	<select class="home-cat-select" name="', $field['id'], '[]" id="', $field['id'], '" style="min-width:200px; min-height:200px;" multiple disabled>';
                foreach ($data as $key => $d) {
                    if (is_array($meta) && in_array($d->term_id, $meta)) {
                        $selected = ' selected';
                    } else {
                        $selected = '';
                    }
                    echo "<option value=\"" . $d->term_id . "\" " . $selected . ">" . $d->name . "</option>";
                }
                echo '	</select>';
                break;
            case 'layer_slider_select':
                // Get WPDB Object
                global $wpdb;
                // Table name
                $table_name = $wpdb->prefix . "layerslider";
                // Get sliders
                $sliders = $wpdb->get_results("SELECT * FROM {$table_name}\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE flag_hidden = '0' AND flag_deleted = '0'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY id ASC LIMIT 200");
                echo '	<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                if (!empty($sliders)) {
                    foreach ($sliders as $key => $item) {
                        $name = empty($item->name) ? 'Unnamed' : $item->name;
                        if ($meta == $item->id) {
                            $selected = 'selected="selected"';
                        } else {
                            $selected = '';
                        }
                        echo '<option value="' . $item->id . '" ' . $selected . '>' . $name . '</option>';
                    }
                }
                if (empty($sliders)) {
                    echo '<option value="">' . __("You didn't create a slider yet.", THEME_NAME) . '</option>';
                }
                echo '	</select>';
                echo '	<br/><br/>Sliders You can create with LayerSlider WP (included with the theme). By creating homepage slider, choose <strong>Light</strong> skin. And set The slider size <strong>950px x 350px.</strong>';
                break;
            case 'sidebar_position_box':
                $positions = array('Right', 'Left');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'slider_type':
                $positions = array('Menu Card Items', 'Shop Items', 'Both');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'small_large':
                $positions = array('Small', 'Large');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'large_small':
                $positions = array('Large', 'Small');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'yes_no':
                $positions = array('Yes', 'No');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'no_yes':
                $positions = array('No', 'Yes');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'reviews_style':
                $positions = array('1', '2');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'color':
                echo '<input class="color" type="text" name="', $field['id'], '" id="', $field['id'], '" ', $meta ? ' ' : '', ' value="', $meta ? remove_html_slashes($meta) : remove_html_slashes($field['std']), '"/> ';
                break;
            case 'comment_select':
                $positions = array('Under The Post', 'New Tab');
                $val = array('under', 'new');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $k => $position) {
                    if ($meta == strtolower($val[$k])) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($val[$k]) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'days':
                $positions = array('1 day', '2 days', '3 days', '7 days', '14 days', '21 days');
                $val = array('1', '2', '3', '7', '14', '21');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $k => $position) {
                    if ($meta == strtolower($val[$k])) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($val[$k]) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'gallery_style':
                $positions = array('Default', 'LightBox');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'show_hide':
                $positions = array('Show', 'Hide');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'hide_show':
                $positions = array('Hide', 'Show');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'image_size_box':
                $positions = array('Large', 'Small');
                echo '<select name="', $field['id'], '" id="', $field['id'], '" style="min-width:200px;">';
                foreach ($positions as $position) {
                    if ($meta == strtolower($position)) {
                        $selected = "selected=\"selected\"";
                    } else {
                        $selected = "";
                    }
                    if ($position != "") {
                        echo "<option value=\"" . strtolower($position) . "\" " . $selected . ">" . $position . "</option>";
                    }
                }
                echo '	</select>';
                break;
            case 'textarea':
                echo '<textarea name="', $field['id'], '" id="', $field['id'], '" ', $meta ? ' ' : '', ' style="width:400px; height:100px;">', $meta ? remove_html_slashes($meta) : remove_html_slashes($field['std']), '</textarea>';
                break;
            case 'home_drag_drop':
                global $OTfields;
                $OTfields = new OrangeThemesManagment(THEME_FULL_NAME, THEME_NAME);
                get_template_part(THEME_FUNCTIONS . "drag-drop");
                $options = $OTfields->get_options();
                echo '
					<div style="vertical-align:top;clear: both;">
						' . $OTfields->print_options() . '
					</div>
				
';
                break;
            case 'google_map':
                echo '
				    <div id="map-canvas"></div>

				    <p>' . __("Left click on the map to add markers. Right click on the marker to remove it!", THEME_NAME) . '</p>
				    <input type="hidden" class="ot-coordinates" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? remove_html_slashes($meta) : remove_html_slashes($field['std']), '"/>
					<script type="text/javascript">';
                $markers = json_decode($meta);
                echo '
						var mapOptions = { zoom: 11, mapTypeId: google.maps.MapTypeId.ROADMAP };
						var markerBounds = new google.maps.LatLngBounds();
						var map = new google.maps.Map(document.getElementById(\'map-canvas\'),mapOptions);';
                if (is_array($markers)) {
                    $i = 0;
                    foreach ($markers as $marker) {
                        if ($marker->lb && $marker->mb) {
                            echo '
										cord = new google.maps.LatLng(' . $marker->lb . ',' . $marker->mb . ');
										addMarker(cord);
										markerBounds.extend(cord);';
                            $i++;
                        }
                    }
                }
                if (!isset($i)) {
                    echo 'if(navigator.geolocation) {
						 		navigator.geolocation.getCurrentPosition(function(position) {
						      	var pos = new google.maps.LatLng(position.coords.latitude,
						                                       position.coords.longitude);

						      	var infowindow = new google.maps.InfoWindow({
						        	map: map,
						        	position: pos,
						        	content: "Whereabouts"
						      	});

						      	map.setCenter(pos);
						    }, function() {
						      	handleNoGeolocation(true);
						    	});
						  	} else {
						    	handleNoGeolocation(false);
						  	}
					';
                } else {
                    if ($i == 1) {
                        echo 'map.setZoom(11);
						map.setCenter(cord);';
                    } else {
                        echo 'map.fitBounds(markerBounds);';
                    }
                }
                echo '
					 google.maps.event.addDomListener(window, \'load\', initialize);
					</script>
				';
                break;
        }
        if ($width != 0) {
            echo '<td>', '</tr>';
        }
    }
    if ($width != 0) {
        echo '</table>';
    }
}
コード例 #2
0
ファイル: general.php プロジェクト: trantuanvn/coffeeletsgo
<?php

global $orange_themes_managment;
$orange_themes_managment = new OrangeThemesManagment(THEME_FULL_NAME, THEME_NAME);
//load the files that contain the options
$options_files = array('general', 'reservations', 'style', 'slider', 'sidebar', 'documentation');
foreach ($options_files as $file) {
    get_template_part(THEME_ADMIN_INCLUDES . $file);
}
global $options;
$options = $orange_themes_managment->get_options();
function theme_configuration()
{
    global $themename, $themeslug, $options, $orange_themes_managment;
    if (isset($_REQUEST['saved']) && $_REQUEST['saved']) {
        $orange_themes_managment->print_saved_message();
    }
    if (isset($_REQUEST['reset']) && $_REQUEST['reset']) {
        $orange_themes_managment->print_reset_message();
    }
    $orange_themes_managment->print_heading("get more from Orange Themes!");
    $orange_themes_managment->print_options();
    $orange_themes_managment->print_footer();
}
add_action('admin_menu', 'theme_menu');
function theme_menu()
{
    global $themename, $themeslug, $options, $wpdb;
    $nonsavable_types = array('navigation', 'tab', 'sub_navigation', 'sub_tab', 'homepage_set_test', 'save', 'closesubtab', 'closetab', 'row', 'close');
    // wp-admin custom form settings
    // table name