function profex_settings_page()
{
    $profex_options = get_option('profex_options');
    function display_elements($elements, $profex_settings_array)
    {
        foreach ($elements as $element) {
            switch ($element['type']) {
                case 'text':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <div class="rt_clearfix"></div>
                    </div>
                    <input name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
" type="text" value="<?php 
                    echo esc_attr(profex_text_check($profex_settings_array, $element['name']));
                    ?>
" />
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
                case 'spliter':
                    ?>
                <h3><?php 
                    _e($element['title'], 'profex');
                    ?>
</h3>
            <?php 
                    break;
                case 'textarea':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <div class="rt_clearfix"></div>
                    </div>
                    <textarea name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
" cols="30" rows="10">
                        <?php 
                    echo esc_attr(profex_text_check($profex_settings_array, $element['name']));
                    ?>
                    </textarea>
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
                case 'pages':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <div class="rt_clearfix"></div>
                    </div>
                    <select name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_page_id">
                        <option value="none" default="default"><?php 
                    _e('Select a page', 'profex');
                    ?>
</option>
                        <?php 
                    $opt = $profex_settings_array[$element['name']];
                    $pages = get_pages('orderby=name');
                    foreach ($pages as $page) {
                        echo '<option value="' . $page->ID . '" ' . selected($opt, $page->ID) . ' >' . $page->post_title . '</option>';
                    }
                    ?>
                    </select>
                    <div class="rt_clearfix"></div>
                </div> 
            <?php 
                    break;
                case 'categories':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="multi_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'multi');
                    ?>
</label>
                        <div class="rt_clearfix"></div>
                    </div>
                    <select name="multi_options[<?php 
                    echo $element['name'];
                    ?>
]" id="multi_page_id">
                        <option value="none" default="default"><?php 
                    _e('Select a category', 'multi');
                    ?>
</option>
                        <?php 
                    $opt = $multi_settings_array[$element['name']];
                    $cats = get_categories('orderby=name');
                    foreach ($cats as $cat) {
                        echo '<option value="' . $cat->cat_ID . '" ' . selected($opt, $cat->cat_ID) . ' >' . $cat->cat_name . '</option>';
                    }
                    ?>
                    </select>
                    <div class="rt_clearfix"></div>
                </div> 
            <?php 
                    break;
            }
        }
    }
    ?>
<div class="rt_wrap">
    <h2 id="rt_title"><?php 
    _e('Theme settings', 'profex');
    ?>
</h2>

    <form method="post" action="options.php" class="rt_opts" id="toeThemeEditOptionForm">

    <?php 
    settings_fields('profex-settings-group');
    ?>
    <div id="rt_tabs">
        <ul>
            <li class="rt_general"><a href="#rt_general"><?php 
    _e('Home page', 'profex');
    ?>
</a></li>
            <li class="rt_social"><a href="#rt_social"><?php 
    _e('Social profiles', 'profex');
    ?>
</a></li>
            <li class="rt_footer"><a href="#rt_footer"><?php 
    _e('Footer', 'profex');
    ?>
</a></li>
        </ul>
                
        <div id="rt_general">
            <?php 
    $elements_general = array('0' => array('title' => 'Header', 'type' => 'spliter'), '1' => array('title' => 'Some link', 'name' => 'link', 'type' => 'text'), '2' => array('title' => 'Header phone', 'name' => 'phone', 'type' => 'text'), '3' => array('title' => 'Home page content', 'type' => 'spliter'), '4' => array('title' => 'Choose a page for special block on home', 'name' => 'special_page_id', 'type' => 'pages'));
    display_elements($elements_general, $profex_options);
    ?>
  
        </div>        
                
        <div id="rt_social">
            <?php 
    $elements_social = array('0' => array('title' => 'Links to social profiles', 'type' => 'spliter'), '1' => array('title' => 'Facebook', 'name' => 'facebook', 'type' => 'text'), '2' => array('title' => 'Twitter', 'name' => 'twitter', 'type' => 'text'), '3' => array('title' => 'Instagram', 'name' => 'instagram', 'type' => 'text'), '4' => array('title' => 'LiveJournal', 'name' => 'livejournal', 'type' => 'text'));
    display_elements($elements_social, $profex_options);
    ?>
        </div>         
        <div id="rt_footer">
            <?php 
    $elements_footer = array('0' => array('title' => 'Copyright text', 'name' => 'copyright', 'type' => 'text'));
    display_elements($elements_footer, $profex_options);
    ?>
          
        </div>
        
        <div class="clear"></div>
        <div id="toeThemeEditFormMsg"><?php 
    if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true) {
        _e('Complete', 'profex');
    }
    ?>
</div>
        <p class="submit">
            <input type="submit" style="margin-left:17px;" class="button-primary" value="<?php 
    _e('Save settings', 'profex');
    ?>
"/>
        </p>
    </div>

    </form>
</div>

<?php 
}
Exemple #2
0
        return "Post Paid Only";
    } else {
        if ($val == 1) {
            return "Pre-Paid Only";
        } else {
            if ($val == 2) {
                return "Both";
            }
        }
    }
}
?>
<div id='zone_network' class='command_response'>
	<table border="1px">
		<?php 
display_elements($view);
?>
	</table>
</div>
<div id='zone_network_action_panel' class='entry'>
	<form name='zone_network_form'>
		<table border=0px>
			<tr>
				<td>
					<select name='zones'>
						<option value=''>Select Zone...</option>
						<?php 
$create_zone_result = mysql_query("select * from zones");
while ($row = mysql_fetch_assoc($create_zone_result)) {
    echo "<option value='" . $row['zone_id'] . "'>" . $row['zone_name'] . "</option>";
}
function profex_settings_page()
{
    $profex_options = get_option('profex_options');
    function display_elements($elements, $profex_settings_array)
    {
        foreach ($elements as $element) {
            switch ($element['type']) {
                case 'spliter':
                    ?>
                <h3><?php 
                    _e($element['title'], 'profex');
                    ?>
</h3>
            <?php 
                    break;
                case 'text':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <?php 
                    if ($element['description']) {
                        echo '<small>' . $element['description'] . '</small>';
                    }
                    ?>
                        <div class="rt_clearfix"></div>
                    </div>
                    <input name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
" type="text" value="<?php 
                    echo esc_attr(profex_text_check($profex_settings_array, $element['name']));
                    ?>
" />
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
                case 'checkbox':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <?php 
                    if ($element['description']) {
                        echo '<small>' . $element['description'] . '</small>';
                    }
                    ?>
                        <div class="rt_clearfix"></div>
                    </div>
                    <input name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
" type="checkbox" value="1" <?php 
                    checked(profex_text_check($profex_settings_array, $element['name']), 1);
                    ?>
 />
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
                case 'textarea':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <?php 
                    if ($element['description']) {
                        echo '<small>' . $element['description'] . '</small>';
                    }
                    ?>
                        <div class="rt_clearfix"></div>
                    </div>
                    <textarea name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
" cols="30" rows="10"><?php 
                    echo esc_attr(profex_text_check($profex_settings_array, $element['name']));
                    ?>
</textarea>
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
                case 'pages':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <?php 
                    if ($element['description']) {
                        echo '<small>' . $element['description'] . '</small>';
                    }
                    ?>
                        <div class="rt_clearfix"></div>
                    </div>
                    <select name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
">
                        <option value="none" default="default"><?php 
                    _e('Select a page', 'profex');
                    ?>
</option>
                        <?php 
                    $opt = $profex_settings_array[$element['name']];
                    $pages = get_pages('orderby=name');
                    foreach ($pages as $page) {
                        echo '<option value="' . $page->ID . '" ' . selected($opt, $page->ID) . ' >' . $page->post_title . '</option>';
                    }
                    ?>
                    </select>
                    <div class="rt_clearfix"></div>
                </div> 
            <?php 
                    break;
                case 'categories':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="profex_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'profex');
                    ?>
</label>
                        <?php 
                    if (isset($element['description']) && $element['description'] != '') {
                        echo '<small>' . $element['description'] . '</small>';
                    }
                    ?>
                        <div class="rt_clearfix"></div>
                    </div>
                    <select name="profex_options[<?php 
                    echo $element['name'];
                    ?>
]" id="profex_<?php 
                    echo $element['name'];
                    ?>
">
                        <option value="none" default="default"><?php 
                    _e('Select a category', 'profex');
                    ?>
</option>
                        <?php 
                    $opt = $profex_settings_array[$element['name']];
                    $cats = get_categories('orderby=name');
                    foreach ($cats as $cat) {
                        echo '<option value="' . $cat->cat_ID . '" ' . selected($opt, $cat->cat_ID) . ' >' . $cat->cat_name . '</option>';
                    }
                    ?>
                    </select>
                    <div class="rt_clearfix"></div>
                </div> 
            <?php 
                    break;
                case 'editor':
                    ?>
                <div class="rt_input rt_text">
                    <div class="rt_description">
                        <label for="multi_<?php 
                    echo $element['name'];
                    ?>
"><?php 
                    _e($element['title'], 'multi');
                    ?>
</label>
                        <div class="rt_clearfix"></div>
                    </div>
                    <?php 
                    $value = multi_text_check($multi_settings_array, $element['name']);
                    wp_editor($value, $element['name'], array('textarea_rows' => 6, 'textarea_name' => 'profex_options[' . $element['name'] . ']'));
                    ?>
                    <div class="rt_clearfix"></div>
                </div>
            <?php 
                    break;
            }
        }
    }
    ?>
<div class="rt_wrap">
    <h2 id="rt_title"><?php 
    _e('Theme settings', 'profex');
    ?>
</h2>

    <form method="post" action="options.php" class="rt_opts" id="toeThemeEditOptionForm">

    <?php 
    settings_fields('profex-settings-group');
    ?>
    <div id="rt_tabs">
        <ul>
            <li class="rt_general"><a href="#rt_general"><?php 
    _e('Home page', 'profex');
    ?>
</a></li>
            <li class="rt_social"><a href="#rt_social"><?php 
    _e('Social profiles', 'profex');
    ?>
</a></li>
            <li class="rt_footer"><a href="#rt_footer"><?php 
    _e('Footer', 'profex');
    ?>
</a></li>
        </ul>
                
        <div id="rt_general">
            <?php 
    $elements_general = array('0' => array('title' => 'Text heading, using like spliter', 'type' => 'spliter'), '1' => array('title' => 'Text example', 'name' => 'test_text', 'type' => 'text', 'description' => 'Text, why you need to write here something'), '2' => array('title' => 'Textarea example', 'name' => 'test_textarea', 'type' => 'textarea'), '3' => array('title' => 'Page selector example', 'name' => 'test_page', 'type' => 'pages'), '4' => array('title' => 'Categories selector example', 'name' => 'test_categories', 'type' => 'categories'), '5' => array('title' => 'Checkbox example', 'name' => 'test_checkbox', 'type' => 'checkbox'));
    display_elements($elements_general, $profex_options);
    ?>
  
        </div>        
                
        <div id="rt_social">
            <p>Heres you can write your fields</p>
        </div>         
        <div id="rt_footer">
            <p>Heres you can write your fields</p>         
        </div>
        
        <div class="clear"></div>
        <div id="toeThemeEditFormMsg"><?php 
    if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true) {
        _e('Complete', 'profex');
    }
    ?>
</div>
        <p class="submit">
            <input type="submit" style="margin-left:17px;" class="button-primary" value="<?php 
    _e('Save settings', 'profex');
    ?>
"/>
        </p>
    </div>

    </form>
</div>

<?php 
}