📄 functions.php
字号:
top:6px;
display:block;
text-decoration:none;
font-size:1px;
width:14px;
height:14px;
text-indent:-9999px;
background:url(<?php bloginfo('stylesheet_directory'); ?>/admin/images/icon_delete.gif) 0 0 no-repeat #FFF;
border:none;
}
* html .block ul li a.remove{ right:15px; }
.block-active{
border:1px solid #333;
background:#F2F8FF;
}
#addables li{
list-style-type:none;
margin:1em 1em 1em 0;
background:#F5F5F5;
border:1px solid #CCC;
padding:3px;
width:215px;
float:left;
cursor:move;
}
ul#addables{
margin:0;
padding:0;
width:720px;
position:relative;
}
</style>
<?php if($message) : ?>
<div id="message" class="updated fade"><p><?php echo $message?></p></div>
<?php endif; ?>
<div id="dropmessage" class="updated" style="display:none;"></div>
<div class="wrap" style="position:relative;">
<?php if (get_option('hem_version')) : ?>
<h2><?php _e('Hemingway Options'); ?></h2>
<h3>Custom Styles</h3>
<p>Select a style from the dropdown below to customize hemingway with a special style.</p>
<form name="dofollow" action="" method="post">
<input type="hidden" name="page_options" value="'dofollow_timeout'" />
<select name="custom_styles">
<option value="none"<?php if ($hemingway->style == 'none') echo 'selected="selected"'; ?>>No Custom Style</option>
<?php
$scheme_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/styles');
if ($scheme_dir) {
while(($file = $scheme_dir->read()) !== false) {
if (!preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file))
$scheme_files[] = $file;
}
}
if ($scheme_dir || $scheme_files) {
foreach($scheme_files as $scheme_file) {
if ($scheme_file == $hemingway->style){
$selected = ' selected="selected"';
}else{
$selected = "";
}
echo '<option value="' . $scheme_file . '"' . $selected . '>' . $scheme_file . '</option>';
}
}
?>
</select>
<input type="submit" value="Save" />
</form>
<h3>Hemingway's Bottombar™</h3>
<p>Drag and drop the different blocks into their place below. After you drag the block to the area, it will update with the new contents automatically.</p>
<ul id="addables">
<?php foreach($hemingway->available_blocks as $ref => $name) : ?>
<li id="<?php echo $ref ?>" class="blocks"><?php echo $name ?></li>
<script type="text/javascript">new Draggable('<?php echo $ref ?>', {revert:true})</script>
<?php endforeach; ?>
</ul>
<div class="clear"></div>
<div class="block" id="block_1">
<ul>
<?php
foreach($hemingway->get_block_contents('block_1') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> <a href="#" class="remove" onclick="remove_block('block_1', '<?php echo $block_ref?>'); return false">remove</a></li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_1', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_1', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_1&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true,
onComplete : function(request){
$('dropmessage').innerHTML = "<p>Block added!</p>";
Effect.Appear('dropmessage', { queue: 'front' });
Effect.Fade('dropmessage', { queue: 'end' });
}
}
)
},
hoverclass:'block-active'
}
)
</script>
<div class="block" id="block_2">
<ul>
<?php
foreach($hemingway->get_block_contents('block_2') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> <a href="#" class="remove" onclick="remove_block('block_2', '<?php echo $block_ref?>'); return false">remove</a></li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_2', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_2', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_2&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true,
onComplete : function(request){
$('dropmessage').innerHTML = "<p>Block added!</p>";
Effect.Appear('dropmessage', { queue: 'front' });
Effect.Fade('dropmessage', { queue: 'end' });
}
}
)
},
hoverclass:'block-active'
}
)
</script>
<div class="block" id="block_3">
<ul>
<?php
foreach($hemingway->get_block_contents('block_3') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> <a href="#" class="remove" onclick="remove_block('block_3', '<?php echo $block_ref?>'); return false">remove</a></li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_3', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_3', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_3&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true,
onComplete : function(request){
$('dropmessage').innerHTML = "<p>Block added!</p>";
Effect.Appear('dropmessage', { queue: 'front' });
Effect.Fade('dropmessage', { queue: 'end' });
}
}
)
},
hoverclass:'block-active'
}
)
</script>
<!-- Maybe later...
<div class="clear"></div>
<div class="block" id="block_4">
Block 4
<ul>
<?php
foreach($hemingway->get_block_contents('block_4') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> (<a href="#" onclick="remove_block('block_4', '<?php echo $block_ref?>');">remove</a>)</li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_4', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_4', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_4&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true
}
)
},
hoverclass:'block-active'
}
)
</script>
<div class="block" id="block_5">
Block 5
<ul>
<?php
foreach($hemingway->get_block_contents('block_5') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> (<a href="#" onclick="remove_block('block_5', '<?php echo $block_ref?>');">remove</a>)</li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_5', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_5', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_5&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true
}
)
},
hoverclass:'block-active'
}
)
</script>
<div class="block" id="block_6">
Block 6
<ul>
<?php
foreach($hemingway->get_block_contents('block_6') as $key => $block_ref) :
$block_name = $hemingway->available_blocks[$block_ref];
?>
<li><?php echo $block_name ?> (<a href="#" onclick="remove_block('block_6', '<?php echo $block_ref?>');">remove</a>)</li>
<?php endforeach; ?>
</ul>
</div>
<script type="text/javascript">
Droppables.add(
'block_6', {
accept:'blocks',
onDrop:function(element){
new Ajax.Updater('block_6', 'themes.php?page=functions.php&hem_action=add_block&block_place=block_6&block_ref=' + element.id,
{
evalScripts:true, asynchronous:true
}
)
},
hoverclass:'block-active'
}
)
</script>
-->
<div class="clear"></div>
<?php
$blocks_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/blocks');
if ($blocks_dir) {
while(($file = $blocks_dir->read()) !== false) {
if (!preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file))
$blocks_files[] = $file;
}
}
if ($blocks_dir || $blocks_files) {
foreach($blocks_files as $blocks_file) {
$block_ref = preg_replace('/\.php/', '', $blocks_file);
if (!array_key_exists($block_ref, $hemingway->available_blocks)){
?>
<h3>You have uninstalled blocks!</h3>
<p>Give the block <strong><?php echo $block_ref ?></strong> a display name (such as "About Page")</p>
<form action="" name="dofollow" method="post">
<input type="hidden" name="block_ref" value="<?php echo $block_ref?>" />
<?php echo $block_ref ?> : <input type="text" name="display_name" />
<input type="submit" value="Save" />
</form>
<?php
}
}
}
?>
<h3>Miscellaneous Options</h3>
<form name="dofollow" action="" method="post">
<input type="hidden" name="misc_options" value="1" />
<p><label><input type="checkbox" value="1" name="international_dates" <?php if ($hemingway_options['international_dates'] == 1) echo "checked=\"checked\""; ?> /> Use international dates? (day/month/year)</label></p>
<p><input type="submit" value="Save my options" /></p>
</form>
<h3>Reset / Uninstall</h3>
<form action="" method="post" onsubmit="return confirm('Are you sure you want to reset all of your settings?')">
<input type="hidden" name="reset" value="1" />
<p>If you would like to reset or uninstall Hemingway, push this button. It will erase all of your preferences. <input type="submit" value="Reset" /></p>
</form>
<?php else: ?>
<p>Thank you for using Hemingway! There's two reasons you might be seeing this:</p>
<ol>
<li>You've just installed Hemingway for the first time: If this is the case, simply reload this page or click on Hemingway Options again and you'll be on your way!</li>
<li>You've just uninstalled Hemingway or reset your options. If you'd like to keep using Hemingway, reload this page or click on Hemingway Options again.</li>
</ol>
<?php endif; ?>
</div>
<?php
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -