Hugh's Blog

WordPress 主题常用 functions

创建新的主题时 functions.php 的一些常用设置。 <?php // Remove wpautop // remove_filter('the_content', 'wpautop'); // Remove wp_head or wp_footer actions // Actions added in /wp-includes/default-filters.php // remove_action('wp_head', '_wp_render_title_tag', 1); // remove_action('wp_head', 'wp_enqueue_scripts', 1); // remove_action('wp_head', 'wp_print_styles', 8); // remove_action('wp_head', 'wp_print_head_scripts', 9); // remove_action('wp_footer', 'wp_print_footer_scripts'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'parent_post_rel_link', 10, 0); remove_action('wp_head', ...

 

Yii2 前后台用户分离

Yii2 要分离前后台用户需要把前台与后台的 Session 与 Cookie 区分开来。 环境:高级模板 为了方便,直接使用 Migrate 复制默认的 user 表来建立 manager 表,同时需要建立以下的类。 common\models\User => common\models\Manager ...

 

WordPress Ajax 简单使用

使用 Wordpress 自带的 Ajax 方法,需要先定义 action add_action('wp_ajax_nopriv_example_test', 'example_test'); add_action('wp_ajax_example_test', 'example_test'); function example_test() { $name = $_POST['name']; header('Content-Type: application/json'); $json = array(); $json['msg'] = 'Hello ' . $name; echo json_encode($json); exit; } 然后在前端页面调用就行,例如使用 jQuery jQuery.ajax({ type: 'POST', // url 路径必须带 'wp-admin/admin-ajax.php' url: ...

 

WordPress 跳转到自定义模板

使用 WordPress 进行自定义的模板跳转 function load_custom_emplate_function($template) { global $wp_query; if (!file_exists($template)) return; $wp_query->is_page = true; $wp_query->is_single = false; $wp_query->is_home = false; $wp_query->comments = false; // if we have a 404 status if ($wp_query->is_404) { // set status of 404 to false unset($wp_query->query["error"]); $wp_query->query_vars["error"] = ""; $wp_query->is_404 = false; } // change the header to 200 OK header("HTTP/1.1 200 OK"); //load our ...

 

Git 忽略文件权限修改监控

在使用 git diff 时返回如下信息 old mode 100644 new mode 100755 原因是对文件权限进行了修改,如果要忽略 git 对文件权限的监控,修改下 git 的配置就行 git config core.filemode false 可以添加 --global 参数,但不 ...

 
<< Newer Posts Older Posts >>