using (System.Diagnostics.Process process = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "ipconfig /flushdns";
process.StartInfo = startInfo;
process.Start();
}

本文主要通过分析 WordPress 官方主题 twentytwelve 的中的“顶部模板”来了解 WordPress 主题顶部制作需要用到的函数。

顶部模板的代码将应用于 Wordpress 所有的页面,其他页模板需要通过 get_header() 来调用。

<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8)  ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
</head>

- 阅读剩余部分 -

本文主要通过分析 Wordpress 官方主题 twentytwelve 的中的“首页模板”来了解 Wordpress 主题首页制作需要用到的函数。

首页大概可以分为四个个部分,头部,主体,侧边栏,底部。

<?php get_header(); ?>

get_header():获取头部模板(header.php)文件中的内容,头部模板主要包含的是首页中导航栏的代码,以后再详细分析。

- 阅读剩余部分 -

本文根据 Opera 官方文档编写,介绍如何使用扩展添加右键菜单。

通过 Opera 扩展,可以给网页上下文菜单添加选项,例如给链接右键菜单添加复制链接文本的菜单项,这样就可以方便的复制链接标题了。

要自定义菜单首先得在 manifest.json 文件里声明 contextMenus 权限,同样也可以在其中定义菜单前的图标。

- 阅读剩余部分 -

本文根据 Opera 官方文档编写,介绍扩展中对标签和窗口的简单操作。

无论操作是标签还是窗口都需要在 manifest.json 文件中声明 tabs 权限

{
  ...
  "permissions": ["tabs"],
  ...
}

创建标签

chrome.browserAction.onClicked.addListener(function() {
  chrome.tabs.create({'url': 'http://sxlf.org'});
});

- 阅读剩余部分 -

本文根据 Opera 官方文档编写,介绍扩展中各脚本消息传递相关的内容。

消息传递有两种方式,一种是简单的通信,一种是高级的通信。

简短的通信

直接通过 runtime.sendMessage()tabs.sendMessage() 方法发送消息,通过用 runtime.onMessage() 方法接收消息。

后台脚本消息发送消息用 tabs.sendMessage(),内容脚本发送消息用 runtime.sendMessage()

- 阅读剩余部分 -

register_nav_menu() 用于 WordPress 中注册导航菜单。

调用

//在 function.php中 调用
<?php register_nav_menu( $location, $description ); ?>

参数

<?php register_nav_menu( 
      $location,//菜单的名称
      $description //菜单的描述
      );
?>

同时注册多个导航菜单要用到 register_nav_menus() 函数

<?php
register_nav_menus( array(
    'menu1' => '菜单一',
    'menu2' => '菜单二'
) );
?>

另外,注销导航菜单要用到 unregister_nav_menu( $location ) 函数,可以用在子主题的 function.php 中。