WordPress.org

Ready to get started?Download WordPress

Forums

Plugin install script (2 posts)

  1. simon360
    Member
    Posted 7 years ago #

    Hey,

    I have no idea what is going on here... My theme is set to install itself if it detects that it is not installed. However, when the options load for the first time after the install script runs, all of he options simply return null. It's sort of like the cache is interfering.

    I'll post the relevant script:

    if (get_option('spect_is_installed')==NULL) {
    		$postheader = array('author' => '1', 'date' => '1', 'categories' => '1', 'comments' => '1', 'commentlr' => '1');
    		add_option('spect_color', '1', 'Style chosen for Spectra 2');
    		add_option('spect_postheader', $postheader, 'Information for the header of each post.');
    		add_option('spect_style_onoff', '1', 'Allow users to customize the page??');
    		add_option('spect_disabled_styles', '', 'Disabled styles in spect');
    		add_option('spect_bg', 'default', 'What should be used as the background of the page?');
    		add_option('spect_ajax_comments', '1', 'Enable ajax comments?');
    		add_option('spect_next_tooltip','1','Tooltip when mouse goes over the "Next Page" button?');
    		add_option('spect_is_installed', '1.9.5', 'Proves Spectra is installed and working correctly.');
    	}
    <?php
    function check_value($option, $value, $tag) {
    	$getoption 		= $option;
    	if ($tag=="text") {
    		return 'value="'.$getoption.'"';
    	}
    	elseif ($getoption==$value) {
    		if ($tag=="radio") {
    			return 'checked="checked"';
    		}
    		elseif ($tag=="option") {
    			return 'selected="selected"';
    		}
    	}
    }
    
    function spect_admin() { ?>
    		<form method="post">
    			<table>
    				<tr>
    					<td>
    						<?php _e('You can change the default color of your blog here (the default is Midnight).','spectra'); ?>
    					</td>
    					<td>
    						<select name="color">
    							<?php
    							foreach ($styles as $key => $name) {?>
    							<option value="<?php echo $key ?>" <?php echo check_value(get_option("spect_color"), $key, "option"); ?>><?php echo $name['name'] ?> </option><?php } ?>
    						</select>
    					</td>
    				</tr>
    				<tr>
    					<td>
    						<?php _e('These settings can change the layout of posts on your blog.','spectra'); ?>
    					</td>
    					<td>
    						<label for="author"><input type="checkbox" name="postheader[author]" value="1" id="author" <?php echo check_value($postheaderdb['author'], "1", "radio"); ?> /> <?php _e('Display author','spectra'); ?></label>
    						<label for="date"><input type="checkbox" name="postheader[date]" id="date" value="1" <?php echo check_value($postheaderdb['date'], "1", "radio"); ?> /> <?php _e('Display date','spectra'); ?></label>
    						<label for="comments"><input type="checkbox" name="postheader[comments]" id="datebox" value="1" <?php echo check_value($postheaderdb['comments'], "1", "radio"); ?> /> <?php _e('Display link for comments','spectra'); ?></label>
    						<label for="cats"><input type="checkbox" name="postheader[categories]" id="cats" value="1" <?php echo check_value($postheaderdb['categories'], "1", "radio"); ?> /> <?php _e('Display categories','spectra'); ?></label>
    					</td>
    				</tr>
    			</table>
    			<p class="submit">
    			<input type="submit" value="Save" />name="checkforupdates" />
    
    		</form>
    <?php }
    function mt_theme_page() {
    	echo '<div class="wrap"><h2>'.__('Spectra Control Panel','spectra').'</h2>';
    	if (isset($_POST["uninstall_spectlite"]))
    		spect_uninstall_now();
    	else {
    	echo ''.__('Irrelevant welcoming message here.','spectra').'
    ';
    	spect_admin();
    	echo "</div>";
    	}
    }
    
    add_action('admin_menu', 'mt_add_pages');
     ?>

    I cut out a lot of code, since it's several hundred lines, but the full install script is there, and a few parts of the admin panel. When the admin panel loads for the first time, those widgets will show up blank on the page. I have no idea why it's happening, either, but I think it's related to WordPress's caching of options.

  2. simon360
    Member
    Posted 7 years ago #

    Anyone have an idea? It's baffling me...

Topic Closed

This topic has been closed to new replies.

About this Topic