I have tried different themes so the conflict is not there, when I remark out the get pages code i get the problem, I have also tried a database query to get the pages still the same problem, so I am very confused.
Remark out this block of code and all is well, enable it and you cannot view the Pages > Edit says 'No Pages'
/* add each page to an array for the Style Switcher setup */
if (!$blogpages) $blogpages = get_pages('sort_column=menu_order');
foreach ($blogpages as $pagg) {
$pagename = $pagg->post_title;
$pageref = str_replace(" ","_",$pagename);
$pagetheme = "drf_theme_".$pageref;
$pagename." Page";
array_push($themeoptions, array(
"name" => $pagename,
"type" => "heading"));
array_push($themeoptions, array(
"name" => "Theme",
"id" => $pagetheme,
"type" => "select",
"options" => $themes,
"std" => "Default"));
}
Here is all the code for the admin screen:
<?php
/* Prevent direct access to this file */
if (!defined('ABSPATH')) {
exit(__( "Sorry, you are not allowed to access this file directly.",'Digital Raindrops'));
}
/* This section creates the admin page Style Swapper area */
$themename = get_current_theme();
$themehortname = 'drf_';
$thisplugin->plug_domain;
$themes = drf_get_theme_list();
/* create an array for the admin screen page options */
$themeoptions = array (
array("name" => "ADD THEMES STYLESHEETS TO INDIVDUAL PAGES",
"type" => "heading",
"desc" => "You can choose a different theme Stylesheet for any page<br /><br?> This will not change the theme just the Stylesheet"));
/* add each page to an array for the Style Switcher setup */
if (!$blogpages) $blogpages = get_pages('sort_column=menu_order');
foreach ($blogpages as $pagg) {
$pagename = $pagg->post_title;
$pageref = str_replace(" ","_",$pagename);
$pagetheme = "drf_theme_".$pageref;
$pagename." Page";
array_push($themeoptions, array(
"name" => $pagename,
"type" => "heading"));
array_push($themeoptions, array(
"name" => "Theme",
"id" => $pagetheme,
"type" => "select",
"options" => $themes,
"std" => "Default"));
}
/* Get a list of Installed Themes */
function drf_get_theme_list()
{
$dirname = get_theme_root().'/';
$theme[] = "Default";
foreach(scandir($dirname) as $item)
{
if (is_dir($item))
{
continue;
}
if (!is_file($item))
{
$theme[] = $item;
}
}
return $theme;
}
function drf_ss_update_option($key, $value){
update_option($key, (get_magic_quotes_gpc()) ? stripslashes($value) : $value);
}
function drf_ss_add_admin() {
global $themename, $themeshortname, $themeoptions, $thisplugin;
if ( $_GET['page'] == basename(__FILE__)) {
if ('save' == $_REQUEST['action'] ) {
foreach ($themeoptions as $value) {
if($value['type'] != 'multicheck'){
drf_ss_update_option( $value['id'], $_REQUEST[ $value['id'] ] );
}else{
foreach($value['options'] as $mc_key => $mc_value){
$up_opt = $value['id'].'_'.$mc_key;
drf_ss_update_option($up_opt, $_REQUEST[$up_opt] );
}
}
}
foreach ($themeoptions as $value) {
if($value['type'] != 'multicheck'){
if( isset( $_REQUEST[ $value['id'] ] ) ) { drf_ss_update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); }
}else{
foreach($value['options'] as $mc_key => $mc_value){
$up_opt = $value['id'].'_'.$mc_key;
if( isset( $_REQUEST[ $up_opt ] ) ) { drf_ss_update_option( $up_opt, $_REQUEST[ $up_opt ] ); } else { delete_option( $up_opt ); }
}
}
}
header("Location: options-general.php?page=adminmenu.php&saved=true");
die;
}
}
add_options_page( __("Manage Pagestyles", 'drfss'), __("Page Styles", 'drfss'), MANAGEMENT_PERMISSION, basename(__FILE__), "drf_ss_admin");
}
function drf_ss_admin() {
global $themename, $themeshortname, $themeoptions, $thisplugin;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>settings saved.</strong></p></div>';
?>
<div class="wrap">
<h2>Page Stylesheets</h2>
<form method="post">
<table class="optiontable" style="width:100%;">
<?php foreach ($themeoptions as $value) {
switch ( $value['type'] ) {
case 'text':
drf_ss_option_wrapper_header($value);
?>
<input style="width:35%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />
<?php
drf_ss_option_wrapper_footer($value);
break;
case 'select':
drf_ss_option_wrapper_header($value);
?>
<select style="width:40%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
<option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
<?php } ?>
</select>
<?php
drf_ss_option_wrapper_footer($value);
break;
case "heading":
?>
<tr valign="top">
<td colspan="2" style="text-align: left;"><h3><?php echo $value['name']; ?></h3></td>
</tr>
<?php
break;
default:
break;
}
}
?>
</table>
<p class="submit">
<input name="save" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save" />
</p>
</form>
</div>
<?php
}
function drf_ss_option_wrapper_header($values){
?>
<tr valign="top">
<th scope="row" style="width:1%;white-space: nowrap;"><?php echo $values['name']; ?>:</th>
<td>
<?php
}
function drf_ss_option_wrapper_footer($values){
?>
</td>
</tr>
<tr valign="top">
<td> </td><td><small><?php echo $values['desc']; ?></small></td>
</tr>
<?php
}
add_action('admin_menu', 'drf_ss_add_admin');
?>
Any help is most welcomed.
David :(